FindPath nimmt nun Map statt ITile[,] als Map entgegen
This commit is contained in:
@@ -14,7 +14,7 @@ namespace WorldOfPeacecraft
|
||||
public uint Y;
|
||||
}
|
||||
|
||||
public static unsafe LinkedList<Coordinate> FindPath (Coordinate posFrom, Coordinate posTo, ITile[,] map)
|
||||
public static unsafe LinkedList<Coordinate> FindPath (Coordinate posFrom, Coordinate posTo, Map map)
|
||||
{
|
||||
PathNode nFrom;
|
||||
nFrom.X = (uint) posFrom.X;
|
||||
@@ -22,12 +22,13 @@ namespace WorldOfPeacecraft
|
||||
PathNode nTo;
|
||||
nTo.X = (uint) posTo.X;
|
||||
nTo.Y = (uint) posTo.Y;
|
||||
uint mapWidth = (uint) map.GetLength (0);
|
||||
uint mapHeight = (uint) map.GetLength (1);
|
||||
Tile[,] tiles = map.GetTiles();
|
||||
uint mapWidth = (uint) tiles.GetLength (0);
|
||||
uint mapHeight = (uint) tiles.GetLength (1);
|
||||
bool* boolMap = stackalloc bool[(int)(mapWidth * mapHeight)];
|
||||
for (int y = 0; y < mapHeight; y++) {
|
||||
for (int x = 0; x < mapWidth; x++) {
|
||||
boolMap [x + y * mapWidth] = map [x, y].IsWalkable ();
|
||||
boolMap [x + y * mapWidth] = tiles [x, y].IsWalkable ();
|
||||
}
|
||||
}
|
||||
PathNode* result = stackalloc PathNode[(int) (mapHeight * mapWidth)];
|
||||
|
||||
Reference in New Issue
Block a user