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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? astarlibrary - demo 5.bb

?? A STAR 算法源碼, 比較初級(jí)的算法, 適合初學(xué)的朋友研究
?? BB
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
	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

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲女子a中天字幕| 亚洲一区国产视频| 欧美在线你懂的| 国产高清精品在线| 亚洲成人免费影院| 一区免费观看视频| 欧美精品一区二区在线观看| 99国产精品一区| 国产美女av一区二区三区| 亚洲精品视频一区二区| 久久午夜免费电影| 欧美一区二区视频在线观看2022| 色哟哟一区二区三区| 狠狠色狠狠色合久久伊人| 一区二区三区丝袜| 亚洲国产精品精华液ab| 在线观看一区日韩| av亚洲精华国产精华精华| 蜜臀av国产精品久久久久| 综合久久久久久久| 久久欧美一区二区| 欧美肥妇毛茸茸| 91欧美一区二区| 激情五月激情综合网| 亚洲黄色录像片| 久久久久久久久久看片| 91精品国产综合久久国产大片| 成人av第一页| 国产在线播精品第三| 亚洲第一会所有码转帖| 国产精品久久免费看| 欧美电视剧在线看免费| 5858s免费视频成人| 91老司机福利 在线| 国产精品亚洲午夜一区二区三区 | 国产日韩影视精品| 日韩欧美一区中文| 欧美精品亚洲一区二区在线播放| 波多野洁衣一区| 精品婷婷伊人一区三区三| 色先锋久久av资源部| 波多野结衣在线一区| 国产成人无遮挡在线视频| 日本欧美一区二区在线观看| 亚洲国产精品久久一线不卡| 亚洲欧美成人一区二区三区| 中文字幕一区不卡| 中文字幕一区二区三区视频| 欧美精品一区二区三区一线天视频| 欧美老女人在线| 91久久一区二区| 国产福利不卡视频| 麻豆传媒一区二区三区| 婷婷开心久久网| 日韩av中文字幕一区二区| 日韩国产欧美在线观看| 亚洲二区在线观看| 亚洲高清免费在线| 一区二区在线免费| 亚洲成a人v欧美综合天堂| 亚洲激情图片一区| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲日本电影在线| 亚洲精品欧美激情| 亚洲自拍偷拍综合| 日韩一区二区高清| 日韩亚洲欧美一区二区三区| 欧美老女人第四色| 欧美tickling网站挠脚心| 日韩精品一区二区三区中文精品 | 北条麻妃国产九九精品视频| 国产精品自产自拍| 成人深夜福利app| a在线欧美一区| 福利一区二区在线| 国产乱对白刺激视频不卡| 国产成人午夜精品5599| jiyouzz国产精品久久| 色欧美乱欧美15图片| 欧美制服丝袜第一页| 欧美久久久久免费| 欧美一级片在线看| 国产亚洲欧美日韩日本| 国产嫩草影院久久久久| 亚洲免费看黄网站| 日av在线不卡| 久久99国产精品久久99| 麻豆91在线播放免费| 裸体一区二区三区| 日本不卡一区二区| 日韩在线卡一卡二| 成人av手机在线观看| 欧美美女一区二区在线观看| 久久嫩草精品久久久精品一| 国产欧美日本一区二区三区| 亚洲男人天堂av| 麻豆精品精品国产自在97香蕉| 国产黄色91视频| 欧美三级电影网| 久久久久久一二三区| 有码一区二区三区| 久久超级碰视频| 色婷婷av一区二区三区软件| 日韩精品一区二区三区视频在线观看 | 蜜桃久久精品一区二区| av毛片久久久久**hd| 91精品国产免费| 亚洲欧洲精品一区二区精品久久久| 婷婷激情综合网| 国产99精品国产| 欧美美女视频在线观看| 国产精品免费看片| 美美哒免费高清在线观看视频一区二区| 国产91丝袜在线观看| 精品视频一区二区不卡| 中文字幕精品一区| 丝袜美腿亚洲综合| 国产在线精品一区二区| 99久久久免费精品国产一区二区| 6080yy午夜一二三区久久| 亚洲私人黄色宅男| 国产99久久精品| 欧美一区二区精品久久911| 国产清纯白嫩初高生在线观看91 | 在线成人高清不卡| 亚洲视频图片小说| 国产精品一区二区黑丝| 日韩亚洲欧美在线| 亚洲无人区一区| 色综合久久88色综合天天6 | 色综合久久久久久久| 久久午夜电影网| 日韩不卡一区二区三区| 欧美日韩二区三区| 亚洲一级片在线观看| 成人自拍视频在线| 久久久久国产成人精品亚洲午夜| 亚洲国产精品麻豆| 丁香亚洲综合激情啪啪综合| 日韩一级成人av| 日韩国产欧美在线观看| 欧洲另类一二三四区| 亚洲欧美日韩系列| 99久久久久免费精品国产 | 国产精品国模大尺度视频| 成人夜色视频网站在线观看| 久久久www成人免费毛片麻豆 | 国产一区二区三区电影在线观看| 这里是久久伊人| 天堂蜜桃一区二区三区 | 99国产精品久久久久久久久久| 久久久久久久久免费| 国产麻豆一精品一av一免费| 日韩欧美国产不卡| 蜜臀av一区二区在线观看| 7777精品伊人久久久大香线蕉 | 麻豆精品蜜桃视频网站| 欧美日韩一区在线观看| 亚洲va欧美va天堂v国产综合| 成人免费看视频| 日本一区二区免费在线| 久久激情综合网| 精品久久久久一区| 婷婷丁香久久五月婷婷| 欧美高清视频不卡网| 五月天网站亚洲| 欧美喷潮久久久xxxxx| 亚洲成人综合网站| 欧美精品自拍偷拍| 亚洲成在人线在线播放| 欧美日韩国产一级| 日韩国产欧美一区二区三区| 欧美中文字幕一区二区三区亚洲| 亚洲一区欧美一区| 日韩一区二区三区四区| 另类小说视频一区二区| 欧美成人官网二区| www.亚洲色图.com| 国产精品美女久久久久久久 | 91精品国产一区二区三区| 久久99久久久欧美国产| 中文字幕免费不卡在线| 日本乱人伦一区| 免费成人美女在线观看.| 国产性色一区二区| 国产一区二区看久久| 国产精品久久久一区麻豆最新章节| 99国产一区二区三精品乱码| 亚洲国产成人av网| 久久午夜羞羞影院免费观看| 波多野结衣视频一区| 日韩中文字幕91| 中文字幕欧美日本乱码一线二线| 欧美中文字幕一二三区视频| 久久精品国产久精国产爱| 国产精品麻豆欧美日韩ww| 欧美日韩美女一区二区| 国产成人在线色| 视频一区二区欧美| 国产精品护士白丝一区av|