diff --git a/isometric-park-fna/CellMap.cs b/isometric-park-fna/CellMap.cs --- a/isometric-park-fna/CellMap.cs +++ b/isometric-park-fna/CellMap.cs @@ -9,6 +9,8 @@ public class CellMap { public List> cells; + public List WaterCells; + //Defaults; overridden by settings from FNAGame in practice: public int MapWidth = 50; public int MapHeight = 50; @@ -68,6 +70,9 @@ this.cells = new List>(); + //Cached: + this.WaterCells = new List(); + this.LinearMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2); this.AreaMultiplier = (int)((this.MapWidth * this.MapHeight) / (50 * 50)); @@ -312,6 +317,12 @@ } } + public Boolean HasWater { + get { + return this.Status == CellStatus.Water; + } + } + public DateTime Planted; public void AddTree(DateTime datetime, TreeType type) { diff --git a/isometric-park-fna/Engines/Spawners/GameSpawner.cs b/isometric-park-fna/Engines/Spawners/GameSpawner.cs --- a/isometric-park-fna/Engines/Spawners/GameSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/GameSpawner.cs @@ -60,7 +60,9 @@ var squares_to_add = new HashSet(); var odds = 0.50; - while (water_squares.Count < 50) { + var water_size = random_generator.Next(50, 250); + + while (water_squares.Count < water_size) { foreach (var square in water_squares) { foreach (var new_square in new[] {new Vector2(square.X + 1, square.Y), @@ -82,6 +84,7 @@ water_squares.AddRange(squares_to_add); squares_to_add.Clear(); } + this.simulation.map.WaterCells.AddRange(water_squares); foreach (var square in water_squares) { this.simulation.map.cells[(int)square.X][(int)square.Y].AddWater(); @@ -99,7 +102,7 @@ foreach (Cell cell in row) { var next = this.random_generator.NextDouble(); - if (next > 0.75) + if (next > 0.75 && !cell.HasWater) { int random_year = (int)MathHelper.Clamp((float)MathUtils.NextNormal(random_generator, 2010.0f, 40.0f), 1800, Simulation.START_YEAR); int random_month = random_generator.Next(1, 13); diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -589,14 +589,19 @@ && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height))); } + //Convenience method I'm not super sure about anymore. - protected void drawTileAt(int x, int y, int tileIndex, int height, Color color) + protected void drawTileAt(int x, int y, int tileIndex, int height, Color color, SpriteBatch batch) { float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; float depthOffset = 0.7f - ((x + (y * Tile.TileWidth)) / maxdepth); - Tile.drawTileAt(this.tileBatch, x, y, tileIndex, height, depthOffset, color); + Tile.drawTileAt(batch, x, y, tileIndex, height, depthOffset, color); + } + + protected void drawTileAt(int x, int y, int tileIndex, int height, Color color) { + drawTileAt(x, y, tileIndex, height, Color.White, this.tileBatch); } protected void drawTileAt(int x, int y, int tileIndex, int height) { @@ -604,9 +609,12 @@ } protected void drawWaterTileAt(int x, int y, int height) { + drawWaterTileAt(x, y, height, this.tileBatch); + } + + protected void drawWaterTileAt(int x, int y, int height, SpriteBatch batch) { var tile_index = 85; var cells = this.simulation.map.cells; - //Unfortunately this is tileset dependent and pretty awkward to type out :( var northwest = cells[x-1][y].Status == CellStatus.Water; @@ -665,9 +673,7 @@ tile_index = 101; } - - - drawTileAt(x, y, tile_index, height, Color.White); + drawTileAt(x, y, tile_index, height, Color.White, batch); } @@ -700,6 +706,7 @@ //reset this.tilesDrawn = 0; + /* var scale_factor = 1; var x_adjust = scale_factor > 1 ? -scale_factor : 0; var y_adjust = scale_factor > 1 ? -scale_factor/2 : 0; @@ -729,6 +736,18 @@ this.tilesDrawn++; // } } + }*/ + + for (int i = 0; i < this.simulation.map.MapHeight; i++) + { + for (int j = 0; j < this.simulation.map.MapWidth; j += 1) + { + drawTileAt(i, j, 1, 1, Color.White, batch); + this.tilesDrawn++; + } + } + foreach (var cell in this.simulation.map.WaterCells) { + drawWaterTileAt((int)cell.X, (int)cell.Y, 1, batch); } batch.End(); stopWatch2.Stop(); @@ -904,9 +923,9 @@ drawTileAt(i, j, 141, 2); // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j)); } - else if (this.simulation.map.cells[i][j].Status == CellStatus.Water) { - drawWaterTileAt(i, j, 1); - } + // else if (this.simulation.map.cells[i][j].Status == CellStatus.Water) { + // drawWaterTileAt(i, j, 1); + // } } } }