Description:
Factor out some details into Simulation.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r27:acd09f0eea20 -

@@ -0,0 +1,45
1 using System;
2
3 namespace isometricparkfna
4 {
5 public class Simulation
6 {
7 public const int START_YEAR = 2020;
8 public const int START_MONTH = 1;
9 public const int START_DAY = 1;
10
11 public int Tick
12 {
13 get;
14
15 private set;
16 }
17
18 public DateTime DateTime
19 {
20 get;
21
22 private set;
23 }
24
25 public decimal money;
26
27 public TileMap map;
28
29 public Simulation(int width, int height)
30 {
31 this.DateTime = new DateTime(START_YEAR, START_MONTH, START_DAY);
32
33 this.map = new TileMap(width, height);
34 this.money = 1000;
35 }
36
37 public void advanceClock()
38 {
39 this.Tick++;
40
41 this.DateTime.AddMonths(1);
42
43 }
44 }
45 }
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -49,7 +49,7
49 49
50 50 GraphicsDevice device;
51 51
52 TileMap map;
52 Simulation simulation;
53 53
54 54 Vector2 mouseGrid;
55 55 Vector2 original_point;
@@ -92,9 +92,9
92 92 //gdm.SynchronizeWithVerticalRetrace = false;
93 93 IsFixedTimeStep = false;
94 94
95 this.map = new TileMap(this.squaresAcross, this.squaresDown);
95 this.simulation = new Simulation(this.squaresAcross, this.squaresDown);
96 96
97 foreach (List<Cell> row in this.map.cells)
97 foreach (List<Cell> row in this.simulation.map.cells)
98 98 {
99 99 foreach (Cell cell in row)
100 100 {
@@ -147,8 +147,7
147 147 {
148 148 CharacterRange.BasicLatin,
149 149 CharacterRange.Latin1Supplement,
150 CharacterRange.LatinExtendedA,
151 CharacterRange.Cyrillic
150 CharacterRange.LatinExtendedA
152 151 }
153 152 );
154 153
@@ -162,10 +161,13
162 161 CharacterRange.BasicLatin,
163 162 CharacterRange.Latin1Supplement,
164 163 CharacterRange.LatinExtendedA,
165 CharacterRange.Cyrillic
164 CharacterRange.Cyrillic,
165 CharacterRange.LatinExtendedB,
166 new CharacterRange((char) 0x00B7)
166 167 }
167 168 );
168 169
170
169 171 #if DEBUG
170 172 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice);
171 173 #endif
@@ -655,14 +657,21
655 657 }//*/
656 658
657 659
658 for (int i = 0; i < this.map.MapHeight; i++)
660 for (int i = 0; i < this.simulation.map.MapHeight; i++)
659 661 {
660 for (int j = 0; j < this.map.MapWidth; j += 1)
662 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
661 663 {
662 664
663 if (this.map.cells[i][j].hasTree)
664 {
665 drawTileAt(i, j, 142, 2);
665 if (this.simulation.map.cells[i][j].hasTree)
666 { //until we actually simulate:
667 if((i+j)%8 == 0)
668 {
669 drawTileAt(i, j, 141, 2);
670 }
671 else
672 {
673 drawTileAt(i, j, 142, 2);
674 }
666 675
667 676 }
668 677
@@ -686,15 +695,15
686 695 bool has_tree = false;
687 696 if (MathUtils.Between(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.Between(this.mouseGrid.Y, 0, this.squaresAcross))
688 697 {
689 has_tree = this.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree;
698 has_tree = this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree;
690 699 //batch.DrawString(font, has_tree.ToString(), new Vector2(500, 33), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f);
691 700 //batch.DrawString(font, has_tree.ToString(), new Vector2(499, 32), Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.49f);
692 701 }
693 702 //*/
694 703
695
696 String header_left = String.Format("$1000");
697 String header_middle = String.Format("January 2020");
704
705 String header_left = String.Format("${0:}|{1:} trees⚘𐂷🌳", this.simulation.money, this.simulation.map.tree_count);
706 String header_middle = String.Format("{0:yyyy MMMMM}", this.simulation.DateTime);
698 707 Vector2 dimensions = monoFont.MeasureString(header_middle);
699 708
700 709 float middle_start = (FNAGame.width / 2) - (dimensions.X / 2);
@@ -722,7 +731,7
722 731 pastFps = past_fps.ToArray(),
723 732 cameraPosition = camera.position,
724 733 drawTime = this.drawTime,
725 treeCount = this.map.tree_count,
734 treeCount = this.simulation.map.tree_count,
726 735 mouseGrid = this.mouseGrid,
727 736 hasTree = has_tree,
728 737 tilesDrawn = this.tilesDrawn
@@ -41,6 +41,7
41 41 <Compile Include="ImGuiRenderer.cs" />
42 42 <Compile Include="DebugWindow.cs" />
43 43 <Compile Include="FilledRectangle.cs" />
44 <Compile Include="Simulation.cs" />
44 45 </ItemGroup>
45 46 <ItemGroup>
46 47 <ProjectReference Include="..\FNA\FNA.csproj">
You need to be logged in to leave comments. Login now