Description:
Draw water at the base tile level.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -9,6 +9,8 | |||||
|
9 | public class CellMap |
|
9 | public class CellMap |
|
10 | { |
|
10 | { |
|
11 | public List<List<Cell>> cells; |
|
11 | public List<List<Cell>> cells; |
|
|
12 | public List<Vector2> WaterCells; | ||
|
|
13 | |||
|
12 | //Defaults; overridden by settings from FNAGame in practice: |
|
14 | //Defaults; overridden by settings from FNAGame in practice: |
|
13 | public int MapWidth = 50; |
|
15 | public int MapWidth = 50; |
|
14 | public int MapHeight = 50; |
|
16 | public int MapHeight = 50; |
@@ -68,6 +70,9 | |||||
|
68 |
|
70 | ||
|
69 | this.cells = new List<List<Cell>>(); |
|
71 | this.cells = new List<List<Cell>>(); |
|
70 |
|
72 | ||
|
|
73 | //Cached: | ||
|
|
74 | this.WaterCells = new List<Vector2>(); | ||
|
|
75 | |||
|
71 | this.LinearMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2); |
|
76 | this.LinearMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2); |
|
72 | this.AreaMultiplier = (int)((this.MapWidth * this.MapHeight) / (50 * 50)); |
|
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 | public DateTime Planted; |
|
326 | public DateTime Planted; |
|
316 |
|
327 | ||
|
317 | public void AddTree(DateTime datetime, TreeType type) { |
|
328 | public void AddTree(DateTime datetime, TreeType type) { |
@@ -60,7 +60,9 | |||||
|
60 | var squares_to_add = new HashSet<Vector2>(); |
|
60 | var squares_to_add = new HashSet<Vector2>(); |
|
61 | var odds = 0.50; |
|
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 | foreach (var square in water_squares) |
|
66 | foreach (var square in water_squares) |
|
65 | { |
|
67 | { |
|
66 | foreach (var new_square in new[] {new Vector2(square.X + 1, square.Y), |
|
68 | foreach (var new_square in new[] {new Vector2(square.X + 1, square.Y), |
@@ -82,6 +84,7 | |||||
|
82 | water_squares.AddRange(squares_to_add); |
|
84 | water_squares.AddRange(squares_to_add); |
|
83 | squares_to_add.Clear(); |
|
85 | squares_to_add.Clear(); |
|
84 | } |
|
86 | } |
|
|
87 | this.simulation.map.WaterCells.AddRange(water_squares); | ||
|
85 |
|
88 | ||
|
86 | foreach (var square in water_squares) { |
|
89 | foreach (var square in water_squares) { |
|
87 | this.simulation.map.cells[(int)square.X][(int)square.Y].AddWater(); |
|
90 | this.simulation.map.cells[(int)square.X][(int)square.Y].AddWater(); |
@@ -99,7 +102,7 | |||||
|
99 | foreach (Cell cell in row) |
|
102 | foreach (Cell cell in row) |
|
100 | { |
|
103 | { |
|
101 | var next = this.random_generator.NextDouble(); |
|
104 | var next = this.random_generator.NextDouble(); |
|
102 | if (next > 0.75) |
|
105 | if (next > 0.75 && !cell.HasWater) |
|
103 | { |
|
106 | { |
|
104 | int random_year = (int)MathHelper.Clamp((float)MathUtils.NextNormal(random_generator, 2010.0f, 40.0f), 1800, Simulation.START_YEAR); |
|
107 | int random_year = (int)MathHelper.Clamp((float)MathUtils.NextNormal(random_generator, 2010.0f, 40.0f), 1800, Simulation.START_YEAR); |
|
105 | int random_month = random_generator.Next(1, 13); |
|
108 | int random_month = random_generator.Next(1, 13); |
@@ -589,14 +589,19 | |||||
|
589 | && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height))); |
|
589 | && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height))); |
|
590 | } |
|
590 | } |
|
591 |
|
591 | ||
|
|
592 | |||
|
592 | //Convenience method I'm not super sure about anymore. |
|
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 | float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; |
|
596 | float maxdepth = ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10; |
|
596 |
|
597 | ||
|
597 | float depthOffset = 0.7f - ((x + (y * Tile.TileWidth)) / maxdepth); |
|
598 | float depthOffset = 0.7f - ((x + (y * Tile.TileWidth)) / maxdepth); |
|
598 |
|
599 | ||
|
599 |
Tile.drawTileAt( |
|
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 | protected void drawTileAt(int x, int y, int tileIndex, int height) { |
|
607 | protected void drawTileAt(int x, int y, int tileIndex, int height) { |
@@ -604,9 +609,12 | |||||
|
604 | } |
|
609 | } |
|
605 |
|
610 | ||
|
606 | protected void drawWaterTileAt(int x, int y, int height) { |
|
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 | var tile_index = 85; |
|
616 | var tile_index = 85; |
|
608 | var cells = this.simulation.map.cells; |
|
617 | var cells = this.simulation.map.cells; |
|
609 |
|
|||
|
610 |
|
618 | ||
|
611 | //Unfortunately this is tileset dependent and pretty awkward to type out :( |
|
619 | //Unfortunately this is tileset dependent and pretty awkward to type out :( |
|
612 | var northwest = cells[x-1][y].Status == CellStatus.Water; |
|
620 | var northwest = cells[x-1][y].Status == CellStatus.Water; |
@@ -665,9 +673,7 | |||||
|
665 | tile_index = 101; |
|
673 | tile_index = 101; |
|
666 | } |
|
674 | } |
|
667 |
|
675 | ||
|
668 |
|
676 | drawTileAt(x, y, tile_index, height, Color.White, batch); | |
|
669 |
|
|||
|
670 | drawTileAt(x, y, tile_index, height, Color.White); |
|
||
|
671 | } |
|
677 | } |
|
672 |
|
678 | ||
|
673 |
|
679 | ||
@@ -700,6 +706,7 | |||||
|
700 | //reset |
|
706 | //reset |
|
701 | this.tilesDrawn = 0; |
|
707 | this.tilesDrawn = 0; |
|
702 |
|
708 | ||
|
|
709 | /* | ||
|
703 | var scale_factor = 1; |
|
710 | var scale_factor = 1; |
|
704 | var x_adjust = scale_factor > 1 ? -scale_factor : 0; |
|
711 | var x_adjust = scale_factor > 1 ? -scale_factor : 0; |
|
705 | var y_adjust = scale_factor > 1 ? -scale_factor/2 : 0; |
|
712 | var y_adjust = scale_factor > 1 ? -scale_factor/2 : 0; |
@@ -729,6 +736,18 | |||||
|
729 | this.tilesDrawn++; |
|
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 | batch.End(); |
|
752 | batch.End(); |
|
734 | stopWatch2.Stop(); |
|
753 | stopWatch2.Stop(); |
@@ -904,9 +923,9 | |||||
|
904 | drawTileAt(i, j, 141, 2); |
|
923 | drawTileAt(i, j, 141, 2); |
|
905 | // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j)); |
|
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) { |
|
926 | // else if (this.simulation.map.cells[i][j].Status == CellStatus.Water) { |
|
908 | drawWaterTileAt(i, j, 1); |
|
927 | // drawWaterTileAt(i, j, 1); |
|
909 | } |
|
928 | // } |
|
910 | } |
|
929 | } |
|
911 | } |
|
930 | } |
|
912 | } |
|
931 | } |
You need to be logged in to leave comments.
Login now