public DungeonMap CreateRooms() { map.Initialize(width, heigth); IMapCreationStrategy <Map> strategy = new RandomRoomsMapCreationStrategy <Map>(width, heigth, 35, 20, 5); map.Copy(strategy.CreateMap()); foreach (Cell cell in map.GetAllCells()) { map.SetCellProperties(cell.X, cell.Y, cell.IsTransparent, cell.IsWalkable, true); } return(map); }
private void CreateDefaultMap() { _map.ClearAllTiles(); var mapCreationStrategy = new RandomRoomsMapCreationStrategy <Map>( _mapWidth, _mapHeight, _maxRooms, _maxRoomSize, _minRoomSize, _random); Map = mapCreationStrategy.CreateMap(); var tilePosition = new Vector3Int(); for (var x = 0; x < _mapWidth; x++) { for (var y = 0; y < _mapHeight; y++) { var cell = Map.GetCell(x, y); tilePosition.Set(x, y, 0); if (cell.IsWalkable) { _map.SetTile(tilePosition, _wallTile); _map.SetColor(tilePosition, Visibility.Invisible); _map.RefreshTile(tilePosition); } else { if (y >= _mapHeight - 1) { continue; } var cellAbove = Map.GetCell(x, y + 1); if (cellAbove != null && cellAbove.IsWalkable) { _map.SetTile(tilePosition, _bottomTile); _map.SetColor(tilePosition, Visibility.Invisible); _map.RefreshTile(tilePosition); } } } } }