Esempio n. 1
0
        private Tile CreateOrUpdateTileIn(IntPair position, Dictionary<IntPair, Tile> allTiles)
        {
            Tile tile;
            allTiles.TryGetValue(position, out tile);
            if (tile == null)
            {
                tile = new Tile();
                allTiles.Add(position, tile);
            }

            foreach (Direction direction in Utils.GetAllDirections())
            {
                IntPair neighbourPosition = position.Move(direction);
                Tile neighbour;
                allTiles.TryGetValue(neighbourPosition, out neighbour);
                if (neighbour != null)
                {
                    tile.BindNeighbours(neighbour, direction);
                }
            }
            return tile;
        }
Esempio n. 2
0
 private void CreateWalls(IntPair position, Tile tile)
 {
     foreach (Direction direciton in Model.Utils.GetAllDirections())
     {
         if (tile.GetNeighbour(direciton) == null)
         {
             CreateWall(position.Move(direciton));
         }
     }
 }
Esempio n. 3
0
        // Assumes positon is at the end of the corridor
        private IntPair MovePositionFromCorridorBeginningToBottomLeftEndRoom(IntPair position, Corridor corridor)
        {
            int offset;
            switch (corridor.direction)
            {
                case Direction.WEST:
                    offset = corridor.exitRoom.size.x;
                    break;
                case Direction.SOUTH:
                    offset = corridor.exitRoom.size.y;
                    break;
                default:
                    offset = 1;
                    break;
            }

            return position.Move(corridor.direction, offset);
        }
Esempio n. 4
0
 // Assumes position is in top-left corner of room
 private IntPair MovePositionToBorderOfRoomInGivenDirection(IntPair position, Room room, Direction direction)
 {
     int offset;
     // TODO: Add some randomized factor so that rooms are not linked always from top-left corner
     switch (direction)
     {
         case Direction.EAST:
             offset = room.size.x - 1;
             break;
         case Direction.NORTH:
             offset = room.size.y - 1;
             break;
         default:
             offset = 0;
             break;
     }
     return position.Move(direction, offset);
 }
Esempio n. 5
0
 // Assumes position is at end of starting room
 // Returns the position where the corridor ends
 private IntPair GenerateTilesForCorridor(Corridor corridor, IntPair position, Dictionary<IntPair, Tile> allTiles)
 {
     for (int i = 0; i < corridor.length; ++i)
     {
         position = position.Move(corridor.direction);
         CreateOrUpdateTileIn(position, allTiles);
     }
     return position;
 }