Exemplo n.º 1
0
 private static void GenerateTile(int GridSize, MapTile[,] map, MapTile.MapTileType TileType, int i, int j)
 {
     map[i, j] = new MapTile {
         Type = TileType, Exits = generateExits(map, i, j, GridSize)
     };
 }
Exemplo n.º 2
0
        private static MapTile.MapTileExits[] generateExits(MapTile[,] map, int i, int j, int GridSize)
        {
            MapTile north = (i == 0) ? map[GridSize - 1, j] : map[i - 1, j];
            MapTile east  = (j == GridSize - 1) ? map[i, 0] : map[i, j + 1];
            MapTile west  = (j == 0) ? map[i, GridSize - 1] : map[i, j - 1];
            MapTile south = (i == GridSize - 1) ? map[0, j] : map[i + 1, j];

            List <MapTile.MapTileExits> exits         = new List <MapTile.MapTileExits>();
            List <MapTile.MapTileExits> excludedExits = new List <MapTile.MapTileExits>();


            if (east.Type != MapTile.MapTileType.Empty)
            {
                if (east.Exits.Contains(MapTile.MapTileExits.West))
                {
                    exits.Add(MapTile.MapTileExits.East);
                }
                else
                {
                    excludedExits.Add(MapTile.MapTileExits.East);
                }
            }
            if (south.Type != MapTile.MapTileType.Empty)
            {
                if (south.Exits.Contains(MapTile.MapTileExits.North))
                {
                    exits.Add(MapTile.MapTileExits.South);
                }
                else
                {
                    excludedExits.Add(MapTile.MapTileExits.South);
                }
            }
            if (west.Type != MapTile.MapTileType.Empty)
            {
                if (west.Exits.Contains(MapTile.MapTileExits.East))
                {
                    exits.Add(MapTile.MapTileExits.West);
                }
                else
                {
                    excludedExits.Add(MapTile.MapTileExits.West);
                }
            }
            if (north.Type != MapTile.MapTileType.Empty)
            {
                if (north.Exits.Contains(MapTile.MapTileExits.South))
                {
                    exits.Add(MapTile.MapTileExits.North);
                }
                else
                {
                    excludedExits.Add(MapTile.MapTileExits.North);
                }
            }


            exits.AddRange(randomExits(excludedExits.ToArray()));

            return(exits.Distinct().ToArray());
        }
Exemplo n.º 3
0
 public IteratableTile(MapTile tile, HallsMap halls, MapTile parent)
 {
     this.tile   = tile;
     this.halls  = halls;
     this.parent = parent;
 }