Exemplo n.º 1
0
 public static void InitPathFindingMap(Tilemap tilemap)
 {
     PathFinding.map = new Dictionary <Vector3Int, Node>();
     foreach (var position in tilemap.cellBounds.allPositionsWithin)
     {
         MyTile tile = tilemap.GetTile <MyTile>(position);
         Node   node = new Node(position, tile.GetTileMoveConsume());
         PathFinding.map.Add(position, node);
     }
 }
Exemplo n.º 2
0
        private static List <Vector3Int> GetNextWalkableTiles(Tilemap tilemap, Vector3Int point)
        {
            List <Vector3Int> ret = new List <Vector3Int>();

            Vector3Int leftPoint = point + Vector3Int.left;
            MyTile     tile      = tilemap.GetTile <MyTile>(leftPoint);

            if (tile != null && tile.GetTileMoveConsume() >= 0)
            {
                ret.Add(leftPoint);
            }

            Vector3Int rightPoint = point + Vector3Int.right;

            tile = tilemap.GetTile <MyTile>(rightPoint);
            if (tile != null && tile.GetTileMoveConsume() >= 0)
            {
                ret.Add(rightPoint);
            }

            Vector3Int upPoint = point + Vector3Int.up;

            tile = tilemap.GetTile <MyTile>(upPoint);
            if (tile != null && tile.GetTileMoveConsume() >= 0)
            {
                ret.Add(upPoint);
            }

            Vector3Int downPoint = point + Vector3Int.down;

            tile = tilemap.GetTile <MyTile>(downPoint);
            if (tile != null && tile.GetTileMoveConsume() >= 0)
            {
                ret.Add(downPoint);
            }

            return(ret);
        }