Description:
Draw water at the base tile level.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r607:200264937666 -

@@ -9,6 +9,8
9 9 public class CellMap
10 10 {
11 11 public List<List<Cell>> cells;
12 public List<Vector2> WaterCells;
13
12 14 //Defaults; overridden by settings from FNAGame in practice:
13 15 public int MapWidth = 50;
14 16 public int MapHeight = 50;
@@ -68,6 +70,9
68 70
69 71 this.cells = new List<List<Cell>>();
70 72
73 //Cached:
74 this.WaterCells = new List<Vector2>();
75
71 76 this.LinearMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2);
72 77 this.AreaMultiplier = (int)((this.MapWidth * this.MapHeight) / (50 * 50));
73 78
@@ -312,6 +317,12
312 317 }
313 318 }
314 319
320 public Boolean HasWater {
321 get {
322 return this.Status == CellStatus.Water;
323 }
324 }
325
315 326 public DateTime Planted;
316 327
317 328 public void AddTree(DateTime datetime, TreeType type) {
@@ -60,7 +60,9
60 60 var squares_to_add = new HashSet<Vector2>();
61 61 var odds = 0.50;
62 62
63 while (water_squares.Count < 50) {
63 var water_size = random_generator.Next(50, 250);
64
65 while (water_squares.Count < water_size) {
64 66 foreach (var square in water_squares)
65 67 {
66 68 foreach (var new_square in new[] {new Vector2(square.X + 1, square.Y),
@@ -82,6 +84,7
82 84 water_squares.AddRange(squares_to_add);
83 85 squares_to_add.Clear();
84 86 }
87 this.simulation.map.WaterCells.AddRange(water_squares);
85 88
86 89 foreach (var square in water_squares) {
87 90 this.simulation.map.cells[(int)square.X][(int)square.Y].AddWater();
@@ -99,7 +102,7
99 102 foreach (Cell cell in row)
100 103 {
101 104 var next = this.random_generator.NextDouble();
102 if (next > 0.75)
105 if (next > 0.75 && !cell.HasWater)
103 106 {
104 107 int random_year = (int)MathHelper.Clamp((float)MathUtils.NextNormal(random_generator, 2010.0f, 40.0f), 1800, Simulation.START_YEAR);
105 108 int random_month = random_generator.Next(1, 13);
@@ -589,14 +589,19
589 589 && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height)));
590 590 }
591 591
592
592 593 //Convenience method I'm not super sure about anymore.
593 protected void drawTileAt(int x, int y, int tileIndex, int height, Color color)
594 protected void drawTileAt(int x, int y, int tileIndex, int height, Color color, SpriteBatch batch)
594 595 {
595 596 float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
596 597
597 598 float depthOffset = 0.7f - ((x + (y * Tile.TileWidth)) / maxdepth);
598 599
599 Tile.drawTileAt(this.tileBatch, x, y, tileIndex, height, depthOffset, color);
600 Tile.drawTileAt(batch, x, y, tileIndex, height, depthOffset, color);
601 }
602
603 protected void drawTileAt(int x, int y, int tileIndex, int height, Color color) {
604 drawTileAt(x, y, tileIndex, height, Color.White, this.tileBatch);
600 605 }
601 606
602 607 protected void drawTileAt(int x, int y, int tileIndex, int height) {
@@ -604,9 +609,12
604 609 }
605 610
606 611 protected void drawWaterTileAt(int x, int y, int height) {
612 drawWaterTileAt(x, y, height, this.tileBatch);
613 }
614
615 protected void drawWaterTileAt(int x, int y, int height, SpriteBatch batch) {
607 616 var tile_index = 85;
608 617 var cells = this.simulation.map.cells;
609
610 618
611 619 //Unfortunately this is tileset dependent and pretty awkward to type out :(
612 620 var northwest = cells[x-1][y].Status == CellStatus.Water;
@@ -665,9 +673,7
665 673 tile_index = 101;
666 674 }
667 675
668
669
670 drawTileAt(x, y, tile_index, height, Color.White);
676 drawTileAt(x, y, tile_index, height, Color.White, batch);
671 677 }
672 678
673 679
@@ -700,6 +706,7
700 706 //reset
701 707 this.tilesDrawn = 0;
702 708
709 /*
703 710 var scale_factor = 1;
704 711 var x_adjust = scale_factor > 1 ? -scale_factor : 0;
705 712 var y_adjust = scale_factor > 1 ? -scale_factor/2 : 0;
@@ -729,6 +736,18
729 736 this.tilesDrawn++;
730 737 // }
731 738 }
739 }*/
740
741 for (int i = 0; i < this.simulation.map.MapHeight; i++)
742 {
743 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
744 {
745 drawTileAt(i, j, 1, 1, Color.White, batch);
746 this.tilesDrawn++;
747 }
748 }
749 foreach (var cell in this.simulation.map.WaterCells) {
750 drawWaterTileAt((int)cell.X, (int)cell.Y, 1, batch);
732 751 }
733 752 batch.End();
734 753 stopWatch2.Stop();
@@ -904,9 +923,9
904 923 drawTileAt(i, j, 141, 2);
905 924 // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j));
906 925 }
907 else if (this.simulation.map.cells[i][j].Status == CellStatus.Water) {
908 drawWaterTileAt(i, j, 1);
909 }
926 // else if (this.simulation.map.cells[i][j].Status == CellStatus.Water) {
927 // drawWaterTileAt(i, j, 1);
928 // }
910 929 }
911 930 }
912 931 }
You need to be logged in to leave comments. Login now