Esempio n. 1
0
        public void FillArea(int width, int height, int cost, bool borders)
        {
            FloorTiles = new List <ITile>();
            for (int col = 0; col < width; col++)
            {
                for (int row = 0; row < height; row++)
                {
                    var tile = new FloorTile(col, row);
                    switch (new Location(col, row))
                    {
                    // Borders
                    case var p when borders && (p.X == 0 || p.X == (width - 1) || p.Y == 0 || p.Y == (height - 1)):
                        tile.Cost  = -1;
                        tile.Notes = "Border";
                        break;

                    default:
                        tile.Cost  = cost;
                        tile.Notes = "Floor";
                        break;
                    }
                    FloorTiles.Add(tile);
                }
            }
        }
        public FloorRoom GenerateRoom(RoomPlan roomType)
        {
            FloorRoom room = new FloorRoom();

            room.FloorTiles = new List <ITile>();

            for (int col = 0; col < roomType.Width; col++)
            {
                for (int row = 0; row < roomType.Height; row++)
                {
                    ITile tile = new FloorTile(col, row);
                    switch (new Location(col, row))
                    {
                    // Door
                    case var p when(roomType.DoorTile?.Point == p):
                        tile = roomType.DoorTile;

                        break;

                    // Walls
                    case var p when(p.X == 0 || p.X == (roomType.Width - 1) ||
                                    p.Y == 0 || p.Y == (roomType.Height - 1)):
                        tile.Cost = roomType.WallValue;

                        tile.Notes = "Wall";
                        break;

                    // Floors
                    default:
                        tile.Cost  = roomType.FloorValue;
                        tile.Notes = "Floor";
                        break;
                    }
                    room.FloorTiles.Add(tile);
                }
            }


            return(room);
        }