예제 #1
0
 private static void PlaceVerticalRoad(Tileset[,] tilesets)
 {
     var column = GameState.Current.Random.Next(tilesets.GetLength(1));
     foreach (var row in Enumerable.Range(0, tilesets.GetLength(0)))
         tilesets[row, column] = Tileset.City1;
 }
예제 #2
0
 private static void PlaceCrossRoads(Tileset[,] tilesets)
 {
     var crossRow = GameState.Current.Random.Next(tilesets.GetLength(0));
     var crossColumn = GameState.Current.Random.Next(tilesets.GetLength(1));
     foreach (var column in Enumerable.Range(0, tilesets.GetLength(1)))
         tilesets[crossRow, column] = Tileset.City0;
     foreach (var row in Enumerable.Range(0, tilesets.GetLength(0)))
         tilesets[row, crossColumn] = Tileset.City1;
     tilesets[crossRow, crossColumn] = Tileset.City2;
 }
예제 #3
0
 private static Point GetAvailableLocation(Tileset[,] tilesets, int width, int height)
 {
     for (;;)
     {
         var topRow = GameState.Current.Random.Next(tilesets.GetLength(0) - height + 1);
         var leftColumn = GameState.Current.Random.Next(tilesets.GetLength(1) - width + 1);
         var isSpaceAvailable = Enumerable.Range(topRow, height)
             .All(row => Enumerable.Range(leftColumn, width)
                 .All(column => tilesets[row, column] == null));
         if (isSpaceAvailable)
             return new Point { X = leftColumn, Y = topRow };
     }
 }
예제 #4
0
 private static void FillTileset(Tileset[,] tilesets, int row, int column, TerrainCategoryMetadata terrainMetadata)
 {
     var isSpaceForLargeTileset =
         row < (tilesets.GetLength(0) - 1) &&
         column < (tilesets.GetLength(1) - 1) &&
         tilesets[row, column + 1] == null &&
         tilesets[row + 1, column] == null &&
         tilesets[row + 1, column + 1] == null;
     var terrainTilesets = isSpaceForLargeTileset ? terrainMetadata.AllTilesets : terrainMetadata.SmallTilesets;
     FillTileset(tilesets, row, column, terrainTilesets);
 }
예제 #5
0
 private static void FillTerrain(Tileset[,] tilesets, TerrainCategoryMetadata terrainMetadata)
 {
     foreach (var row in Enumerable.Range(0, tilesets.GetLength(0)))
         foreach (var column in Enumerable.Range(0, tilesets.GetLength(1)))
             if (tilesets[row, column] == null)
                 FillTileset(tilesets, row, column, terrainMetadata);
 }
예제 #6
0
 private static Level CreateLevel(Tileset[,] tilesets, int levelIndex)
 {
     var level = new Level { Tiles = new Tile[10 * tilesets.GetLength(0), 10 * tilesets.GetLength(1)] };
     foreach (var row in Enumerable.Range(0, tilesets.GetLength(0)))
         foreach (var column in Enumerable.Range(0, tilesets.GetLength(1)))
             if (tilesets[row, column] != placeholder)
                 level.LoadTileset(tilesets[row, column], levelIndex, row * 10, column * 10);
     return level;
 }