Esempio n. 1
0
        private Dictionary<Tile, object> paintTilesAdjacentTo(Tile startTile)
        {
            Dictionary<Tile, object> visitedTiles = new Dictionary<Tile, object>();
            Stack<Tile> tileStack = new Stack<Tile>();
            tileStack.Push(startTile);
            visitedTiles.Add(startTile, null);
            while (tileStack.Count > 0)
            {
                Tile tile = tileStack.Pop();
                addIfPossible(visitedTiles, tileStack, tile.Position.X - 1, tile.Position.Y);
                addIfPossible(visitedTiles, tileStack, tile.Position.X + 1, tile.Position.Y);
                addIfPossible(visitedTiles, tileStack, tile.Position.X, tile.Position.Y - 1);
                addIfPossible(visitedTiles, tileStack, tile.Position.X, tile.Position.Y + 1);
            }

            return visitedTiles;
        }
Esempio n. 2
0
 private Tile getExpandingTile(int x, int y)
 {
     tileGrid.containCoordinate(x, y);
     Tile t = tileGrid.get(x, y);
     if (t == null)
     {
         t = new Tile(water);
         t.Position = new Point(x, y);
         tileGrid.set(x, y, t);
     }
     return t;
 }
Esempio n. 3
0
 private bool isWalkableTerrain(Tile t)
 {
     return isWalkableTerrain(t.Terrain);
 }
Esempio n. 4
0
 public Tile getTile(int x, int y)
 {
     if (!tileGrid.containsCoordinate(x, y))
     {
         Tile t = new Tile(water);
         t.Position = new Point(x, y);
         return t;
     }
     return getExpandingTile(x, y);
 }