示例#1
0
        public static DetailedRoomInfo GenerateRoom(RoomInfo roomInfo, string mapName)
        {
            var detailedRoomInfo = new DetailedRoomInfo(roomInfo, ROOM_WIDTH, ROOM_HEIGHT);
            var template         = ChooseRandomTemplate(mapName);

            for (int j = 0; j < ROOM_HEIGHT; j++)
            {
                for (int i = 0; i < ROOM_WIDTH; i++)
                {
                    var tile = new LevelTile(LevelTile.TileTypes.None);
                    if (IsBoundary(i, j))
                    {
                        tile.Type = LevelTile.TileTypes.Wall;
                    }
                    else
                    {
                        var templateChar = template[j * ROOM_WIDTH + i];
                        switch (templateChar)
                        {
                        case '@':
                            detailedRoomInfo.Spawns.Add(new Vector2Int(i, j));
                            break;

                        case 'X':
                            tile.Type = LevelTile.TileTypes.Wall;
                            break;

                        case '.':
                            break;

                        default:
                            throw new System.Exception($"Not implemented char [{templateChar}]");
                        }
                    }
                    detailedRoomInfo.RoomLayout[i, j] = tile;
                }
            }

            return(detailedRoomInfo);
        }
示例#2
0
 public void SetRoomInfo(DetailedRoomInfo roomInfo)
 {
     DetailedRoomInfo = roomInfo;
 }