亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? astarlibrary - demo 5.bb

?? 國外的一個A*算法演示
?? BB
?? 第 1 頁 / 共 3 頁
字號:
	unitX = Floor(unit\xLoc/tileSize)
	unitY = Floor(unit\yLoc/tileSize)		
	For pathLocation = otherUnit\pathLocation To otherUnit\pathLength		
		If unitX = PeekShort (otherUnit\pathBank,pathLocation*4)
			If unitY = PeekShort (otherUnit\pathBank,pathLocation*4+2)		
				Return True
			End If
		End If
		If pathLocation > otherUnit\pathLocation+1 Then Return
	Next
End Function 

;This function is used by the FindPath() function to 
;check whether the given target location is walkable.
;If not, it finds a new, nearby target location that is
;walkable. The new coordinates are written to the
;gInt1 and gInt2 global variables.
Function CheckRedirect(unit.unit, x,y)
	If NodeOccupied(unit.unit,x,y) = True
		For radius = 1 To 10
			For option = 1 To 4
				If option = 1 
					gInt1 = x : gInt2 = y-radius
				Else If option = 2 
					gInt1 = x : gInt2 = y+radius
				Else If option = 3 
					gInt1 = x-radius : gInt2 = y
				Else If option = 4 
					gInt1 = x+radius : gInt2 = y	
				End If			
				If gInt1 >= 0 And gInt1 < mapWidth And gInt2 >= 0 And gInt2 < mapHeight
					If NodeOccupied(unit.unit,gInt1,gInt2) = False
						If x = Floor(unit\targetX/tileSize) And y=Floor(unit\targetY/tileSize)
							unit\targetX = gInt1*tileSize+.5*tileSize 
							unit\targetY = gInt2*tileSize+.5*tileSize 
						End If	
						Return succeeded ;1	
					End If
				End If
			Next
		Next
		Return failed ;unable to find redirect (returns -1).	
	End If
End Function

;This function is used by the CheckRedirect() function to 
;determine whether a given node is walkable for a given unit.
Function NodeOccupied(unit.unit,x,y)
	If walkability(x,y) = unwalkable Then Return True
	If island(x,y) <> island(Floor(unit\xLoc/tileSize),Floor(unit\yLoc/tileSize)) Then Return True		
	If claimedNode(x,y) = Null Or claimedNode(x,y) = unit ;node is free
		Return False
	Else ;there is another unit there
		If claimedNode(x,y)\pathStatus = found ;but if it is moving ...
			If claimedNode(x,y)<>unit\unitCollidingWith ;and unit is not colliding with it
			 	Return False
			End If
		End If	
	End If
	Return True
End Function	

;This function is used by the FindPath() function to lay out
;'footprints' for other nearby units. A node within 1 node of
;the pathfinding unit that is occupied by another unit is
;treated as unwalkable. This function also lays out the
;current paths of any units within two units of the pathfinding
;unit. These nodes are then penalized within the FindPath() 
;function. This encourages paths that do not overlap those 
;of nearby units.
Function CreateFootPrints(unit.unit)
	tempUnwalkable = onClosedList-2
	penalized = onClosedList-3	
	unitX = Floor(unit\xLoc/tileSize) : unitY = Floor(unit\yLoc/tileSize)
	For a = unitX-2 To unitX+2
	For b = unitY-2 To unitY+2
		If a >= 0 And a < mapWidth And b>=0 And b < mapHeight
			If claimedNode(a,b) <> Null And claimedNode(a,b) <> unit
				otherUnit.unit = claimedNode(a,b)
				
				;Lay out penalized paths for units within 2 nodes of 
				;the pathfinding unit.
				For pathLocation = otherUnit\pathLocation-1 To otherUnit\pathLength
					If pathLocation>= 0	
						x = PeekShort (otherUnit\pathBank,pathLocation*4)	
						y = PeekShort (otherUnit\pathBank,pathLocation*4+2)		
						nearByPath(x,y) = penalized
					End If	
				Next
				
				;Designate nodes occupied by units within 1 node 
				;as temporarily unwalkable.
				If Abs(a-unitX) <= 1 And Abs(b-unitY) <= 1 
					tempUnwalkability(a,b) = tempUnwalkable
				End If	
				
			End If							
		End If
	Next
	Next	
End Function


;This function identifies nodes on the map that are not accessible from other areas
;of the map ("islands"). It assumes that the map does not change during the game.
;If so, this function must be called again. It is not a good idea to do this too often
;during the game, especially if it is a large map, because the function is a little slow.
;The island information is saved to an array called island(x,y).
Function IdentifyIslands()
	Dim island(mapWidth+1,mapHeight+1) 
	For startX = 0 To mapWidth-1
	For startY = 0 To mapHeight-1
		If walkability(startX,startY) = walkable And island(startX,startY) = 0	
			areaID =  areaID + 1		
			onClosedList = onClosedList+5 ;changing the values of onOpenList and onClosed list is faster than redimming whichList() array
			onOpenList = onClosedList-1
			openListItems = 1 : openList(1) = 1 : openX(1) = startX : openY(1) = startY
			Repeat
			parentXval = openX(openList(1)) : parentYVal = openY(openList(1))
			openList(1) = openList(openListItems) ;put last item in slot #1	
			openListItems = openListItems - 1 ;reduce number of open list items by 1
			whichList(parentXval,parentYVal) = onClosedList ;add cell to closed list
			island(parentXval,parentYVal) = areaID ;Assign item to areaID
			For b = parentYVal-1 To parentYVal+1
			For a = parentXval-1 To parentXval+1
				If a <> -1 And b <> -1 And a <> mapWidth And b <> mapHeight
				If whichList(a,b) <> onClosedList And whichList(a,b) <> onOpenList	
				If walkability(a,b) <> unwalkable ;not = walkable because could = occupied
				If (a=parentXVal Or b=parentYVal) ;If an orthogonal square of the right type(s)		
					squaresChecked = squaresChecked + 1
					m = openListItems+1 ;m = new item at end of heap					
					openList(m) = squaresChecked				
					openX(squaresChecked) = a : openY(squaresChecked) = b		
					openListItems = openListItems+1 ;add one to number of items on the open list
					whichList(a,b) = onOpenList
				End If ;If an orthogonal square of the right type(s)		
				End If ;If walkability(a,b) <> unwalkable
				End If ;If not on the open or closed lists
				End If ;If not off the map.
			Next
			Next
			Until openListItems = 0				
		End If	
	Next
	Next	
End Function


;This function chooses separate destinations for each member of
;of a group of selected units. When we choose a destination
;for the group, we don't want them to all try to go that exact
;location. Instead we want them to go to separate locations close 
;to that group target location.
;	If the units are all close enough together, the function merely
;returns that each unit should stay in the same place relative to one
;another. If the units are spread out, the function chooses a relative
;location for the unit.
Function ChooseGroupLocations()

	;Figure out the group center
	For unit.unit = Each unit
		If unit\selected = True
			totalX = totalX + unit\xLoc#
			totalY = totalY + unit\yLoc#	
			numberOfUnitsInGroup = numberOfUnitsInGroup+1
		End If	
	Next
	If numberOfUnitsInGroup = 0 Then Return
	groupCenterX# = totalX/numberOfUnitsInGroup
	groupCenterY# = totalY/numberOfUnitsInGroup	
	
	;Figure out if all of the units in the selected group are close enough to
	;each other to keep them more or less in the same locations relative
	;to one another.
	maxDistance = tileSize*Sqr(numberOfUnitsInGroup)	
	For unit.unit = Each unit
		If unit\selected = True
			unit\xDistanceFromGroupCenter# = unit\xLoc#-groupCenterX#
			unit\yDistanceFromGroupCenter# = unit\yLoc#-groupCenterY#
			If Abs(unit\xDistanceFromGroupCenter#) > maxDistance
				unitOutsideMaxDistance = True
			Else If Abs(unit\yDistanceFromGroupCenter#) > maxDistance
				unitOutsideMaxDistance = True			
			End If
		End If	
	Next
	
	;If they are all close enough together, we don't need to adjust their relative 
	;locations.
	If unitOutsideMaxDistance = False 
		;do nothing

	;If one or more group members is too far away, we need to generate a new
	;set of relative locations for the group members.
	Else If numberOfUnitsInGroup = 2

		For unit.unit = Each unit
			If unit\selected = True
				unit\actualAngleFromGroupCenter = 0			
				unit\assignedAngleFromGroupCenter = 0	
				unit\xDistanceFromGroupCenter# = Sgn(unit\xDistanceFromGroupCenter#)*tileSize/2
				unit\yDistanceFromGroupCenter# = Sgn(unit\yDistanceFromGroupCenter#)*tileSize/2	
			End If	
		Next	
				
	Else ;if 3+ units

		;Figure out the angles between each unit in the group and the group center.
		;Also, save unit type pointers to an array for sorting purposes	
		Dim gGroupUnit.unit(numberOfUnitsInGroup+1)			
		For unit.unit = Each unit
			If unit\selected = True
				x = x+1
				gGroupUnit.unit(x) = unit
				unit\actualAngleFromGroupCenter = GetAngle(groupCenterX#,groupCenterY#,unit\xLoc#,unit\yLoc#)		
			End If	
		Next	
		
		;Sort the units in the group according to their angle, from lowest to highest 
		topItemNotSorted = numberOfUnitsInGroup
		While topItemNotSorted <> 1
	
			;Find the highest value in the list
			highestValueItem = 1
			For sortItem = 1 To topItemNotSorted
				If gGroupUnit(sortItem)\actualAngleFromGroupCenter >= gGroupUnit(highestValueItem)\actualAngleFromGroupCenter 
					highestValueItem = sortItem
				End If
			Next
		
			;Now swap it with the highest item in the list
			temp.unit = gGroupUnit(topItemNotSorted)
			gGroupUnit(topItemNotSorted) = gGroupUnit(highestValueItem)
			gGroupUnit(highestValueItem) = temp
		
			topItemNotSorted = topItemNotSorted - 1			
		Wend
		
		;Now assign angles to each of the units in the group
		gGroupUnit(1)\assignedAngleFromGroupCenter = gGroupUnit(1)\actualAngleFromGroupCenter
		addAngle# = 360/numberOfUnitsInGroup		
		For x = 2 To numberOfUnitsInGroup
			gGroupUnit(x)\assignedAngleFromGroupCenter = gGroupUnit(x-1)\assignedAngleFromGroupCenter + addAngle
 			If gGroupUnit(x)\assignedAngleFromGroupCenter >= 360
				gGroupUnit(x)\assignedAngleFromGroupCenter = gGroupUnit(x)\assignedAngleFromGroupCenter-360
			End If
		Next
	
		;Now assign the xDistanceFromGroupCenter and yDistanceFromGroupCenter
		If numberOfUnitsInGroup <= 6
			radius# = Sqr(numberOfUnitsInGroup)*0.8*tileSize
			For unit.unit = Each unit
				If unit\selected = True
					unit\xDistanceFromGroupCenter# = radius*Cos(unit\assignedAngleFromGroupCenter)+(unit\ID Mod(2))
					unit\yDistanceFromGroupCenter# = -radius*Sin(unit\assignedAngleFromGroupCenter)	+(unit\ID Mod(2))	
				End If	
			Next	
		
		;If there are more than 6 units in the group, create two rings of units.
		Else
			innerRadius# = Sqr(numberOfUnitsInGroup/2)*0.8*tileSize
			outerRadius# = 2.5*Sqr(numberOfUnitsInGroup/2)*0.8*tileSize
			x = 0		
			For unit.unit = Each unit
				If unit\selected = True
					x = x+1
					If x Mod 2 = 0
						unit\xDistanceFromGroupCenter# = innerRadius*Cos(unit\assignedAngleFromGroupCenter)
						unit\yDistanceFromGroupCenter# = -innerRadius*Sin(unit\assignedAngleFromGroupCenter)		
					Else
						unit\xDistanceFromGroupCenter# = outerRadius*Cos(unit\assignedAngleFromGroupCenter)
						unit\yDistanceFromGroupCenter# = -outerRadius*Sin(unit\assignedAngleFromGroupCenter)					
					End If
				End If	
			Next					
		End If
			
	End If  ;If group\numberOfUnitsInGroup = 2

	;Now that the relative locations have been determined, we use this info
	;to generate the units' destination locations.
	For unit.unit = Each unit
		If unit\selected = True
			unit\targetX# = MouseX() + unit\xDistanceFromGroupCenter#
			unit\targetY# = MouseY() + unit\yDistanceFromGroupCenter#
			If unit\targetX < 0 Then unit\targetX = 0			
			If unit\targetX >= 800 Then unit\targetX = 799
			If unit\targetY < 0 Then unit\targetY = 0			
			If unit\targetY >= 600 Then unit\targetY = 599	
		End If	
	Next
		
End Function

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线观看不卡一区| 久久爱www久久做| 99re在线精品| 国产精品毛片大码女人| 国产成人免费高清| 亚洲色图在线视频| 欧美亚一区二区| 日韩电影一区二区三区| 精品久久一区二区| 国产成人久久精品77777最新版本| 国产日韩一级二级三级| 成人一级片网址| 一区二区视频在线| 91精品国产综合久久福利| 狠狠色综合色综合网络| 国产精品美女久久久久久久久 | 日韩一区二区电影网| 精品一区二区在线看| 久久先锋影音av鲁色资源| 成人h动漫精品一区二| 亚洲午夜av在线| 日韩一级成人av| 国产a久久麻豆| 午夜视频一区二区三区| 日韩精品一区二区三区视频播放| 国产黄色精品视频| 亚洲成人免费影院| 久久人人超碰精品| 91国产免费观看| 91麻豆免费看| 日韩国产成人精品| 中文字幕精品一区| 欧美日韩免费在线视频| 国产乱码字幕精品高清av| 亚洲九九爱视频| 精品日韩欧美在线| 欧美在线免费观看亚洲| 久久99精品网久久| 亚洲一区二区视频在线| 国产女人水真多18毛片18精品视频| 在线一区二区三区四区| 国内精品第一页| 亚洲v中文字幕| 国产精品第四页| 日韩一区二区三区精品视频| 色先锋资源久久综合| 国产综合色在线视频区| 亚洲国产精品影院| 国产精品福利一区二区| 精品久久久久久久久久久久包黑料 | 国产日韩欧美综合在线| 欧美日本在线观看| 成人做爰69片免费看网站| 日韩精品成人一区二区三区| 国产成人精品亚洲日本在线桃色 | 久久欧美中文字幕| 欧美日韩一级二级三级| 99久久精品免费精品国产| 精品在线一区二区| 午夜精品久久久久久不卡8050| 国产精品久久久久久久久晋中| 日韩精品最新网址| 欧美三级韩国三级日本三斤| www.av亚洲| 国产福利91精品一区| 美女在线观看视频一区二区| 亚洲第一搞黄网站| 一区二区三区高清在线| 国产精品高潮呻吟| 欧美韩国日本一区| 久久亚洲春色中文字幕久久久| 欧美mv和日韩mv国产网站| 欧美一区二区性放荡片| 欧美精品三级日韩久久| 欧美日韩你懂得| 欧美精品xxxxbbbb| 69堂成人精品免费视频| 欧美蜜桃一区二区三区| 欧美精品乱码久久久久久按摩| 91久久精品一区二区三区| 色天使色偷偷av一区二区| 99re热这里只有精品免费视频| 成人激情午夜影院| 99综合影院在线| 99视频在线精品| 色哟哟国产精品| 在线观看亚洲专区| 欧美日韩一区二区三区四区| 欧美精品久久一区二区三区| 欧美一区二区三区成人| 日韩一卡二卡三卡国产欧美| 精品国产青草久久久久福利| 欧美精品一区在线观看| 久久综合色综合88| 国产亚洲短视频| 国产精品欧美一区喷水| 亚洲日本一区二区| 亚洲综合成人在线| 蜜桃久久久久久| 国产大片一区二区| 91亚洲午夜精品久久久久久| 欧美日韩国产高清一区| 欧美大度的电影原声| 精品粉嫩aⅴ一区二区三区四区| 国产视频视频一区| 亚洲精品久久久蜜桃| 五月天中文字幕一区二区| 九九国产精品视频| 97成人超碰视| 欧美精品精品一区| 亚洲国产精品ⅴa在线观看| 一区二区三区四区在线| 亚洲二区在线观看| 精品在线一区二区三区| 色诱亚洲精品久久久久久| 日韩欧美亚洲国产精品字幕久久久| 亚洲国产精品99久久久久久久久| 香蕉成人啪国产精品视频综合网| 国产综合色在线| 欧美色爱综合网| 久久久不卡网国产精品二区| 一区二区高清视频在线观看| 久久精品国产亚洲高清剧情介绍| 成人禁用看黄a在线| 欧美一卡2卡3卡4卡| 国产精品久久久久久久浪潮网站| 午夜视频一区二区三区| av在线免费不卡| 精品成人一区二区三区四区| 一个色在线综合| 国产a久久麻豆| 日韩一区二区三区视频| 一级中文字幕一区二区| 国产精品中文字幕一区二区三区| 欧美日本在线看| 一区二区三区欧美在线观看| 国产一区二区三区香蕉| 精品视频免费在线| 国产精品成人免费在线| 国内精品久久久久影院色| 欧美老人xxxx18| 一区二区在线免费| 国产91对白在线观看九色| 日韩一区二区在线看| 亚洲综合自拍偷拍| 成人免费看片app下载| 精品国产髙清在线看国产毛片| 午夜欧美在线一二页| 色屁屁一区二区| 国产精品国产成人国产三级| 国内精品视频666| 欧美一级高清片| 丝袜美腿高跟呻吟高潮一区| 91视频观看视频| 国产精品久久久久一区| 国产精品乡下勾搭老头1| 日韩精品资源二区在线| 免费观看日韩av| 91精品久久久久久久99蜜桃 | 青青草伊人久久| 欧美在线视频日韩| 亚洲自拍偷拍综合| 色综合天天天天做夜夜夜夜做| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产福利精品一区| 欧美精品一区二区在线观看| 蜜桃一区二区三区四区| 日韩一级片网站| 久久99精品久久久久久| 欧美一级理论片| 国产在线不卡视频| 久久久久久**毛片大全| 国产一区二区三区久久悠悠色av| 久久久不卡网国产精品一区| 国产麻豆成人精品| 国产精品欧美一区喷水| 91伊人久久大香线蕉| 一区二区三区美女视频| 欧美日韩高清影院| 日本女优在线视频一区二区 | 精品久久久久av影院| 国产美女视频一区| 中文乱码免费一区二区| av午夜一区麻豆| 亚洲高清三级视频| 日韩免费一区二区| 国产a视频精品免费观看| 亚洲色图丝袜美腿| 欧美日韩亚洲综合| 麻豆精品一区二区综合av| 麻豆精品久久精品色综合| 国产欧美日韩在线| 91理论电影在线观看| 亚洲大型综合色站| 精品乱人伦一区二区三区| 成人亚洲一区二区一| 亚洲精品乱码久久久久久久久| 欧美一区二区视频在线观看| 国产乱国产乱300精品| 中文字幕亚洲一区二区va在线|