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