Description:
Add initial version of money.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r51:09bd57319dcf -

@@ -829,7 +829,15
829 additionalInfo.Add("mouse delta", delta.ToString());
829 additionalInfo.Add("mouse delta", delta.ToString());
830
830
831 additionalInfo.Add("Tracery Test", this.output);
831 additionalInfo.Add("Tracery Test", this.output);
832 debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window);
832
833 additionalInfo.Add("Budget Money", this.simulation.latestBudget.money.ToString());
834 additionalInfo.Add("Budget Subsidy", this.simulation.latestBudget.subsidy.ToString());
835 additionalInfo.Add("Budget Upkeep", this.simulation.latestBudget.upkeep.ToString());
836 additionalInfo.Add("Budget Money Prior", this.simulation.previousBudget.money.ToString());
837 additionalInfo.Add("Budget Subsidy Prior", this.simulation.previousBudget.subsidy.ToString());
838 additionalInfo.Add("Budget Upkeep Prior", this.simulation.previousBudget.upkeep.ToString());
839
840 debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window);
833
841
834
842
835 debugWindow.ImGuiLayout();
843 debugWindow.ImGuiLayout();
@@ -1,8 +1,27
1 using System;
1 using System;
2 using System.Collections.Generic;
2 using static isometricparkfna.TileMap;
3 using static isometricparkfna.TileMap;
3
4
4 namespace isometricparkfna
5 namespace isometricparkfna
5 {
6 {
7 public struct Budget
8 {
9 public DateTime DateTime;
10 public decimal money;
11
12
13 //revenue
14 public decimal subsidy;
15
16 //expenses
17 public decimal upkeep;
18
19
20 //misc
21 public int trees;
22
23 }
24
6 public class Simulation
25 public class Simulation
7 {
26 {
8 public const int START_YEAR = 2020;
27 public const int START_YEAR = 2020;
@@ -37,6 +56,39
37
56
38 public decimal money;
57 public decimal money;
39
58
59 private List<Budget> budgets;
60
61
62 public Budget latestBudget
63 {
64 get
65 {
66 if (this.budgets.Count >= 1) {
67 return this.budgets[this.budgets.Count - 1];
68
69 }
70 else
71 {
72 return new Budget { };
73 }
74 }
75 }
76
77 public Budget previousBudget
78 {
79 get
80 {
81 if (this.budgets.Count >= 2) {
82 return this.budgets[this.budgets.Count - 2];
83
84 }
85 else
86 {
87 return new Budget { };
88 }
89 }
90 }
91
40 public float millisecondsPerAdvance { get; private set; }
92 public float millisecondsPerAdvance { get; private set; }
41 public String Season { get
93 public String Season { get
42 {
94 {
@@ -65,7 +117,9
65 private float lastAdvance;
117 private float lastAdvance;
66 public bool paused;
118 public bool paused;
67
119
68 private Random random;
120 private Random random;
121
122
69
123
70 public Simulation(int width, int height, float millisecondsPerAdvance)
124 public Simulation(int width, int height, float millisecondsPerAdvance)
71 {
125 {
@@ -74,10 +128,12
74 this.DateTime = new DateTime(START_YEAR, START_MONTH, START_DAY);
128 this.DateTime = new DateTime(START_YEAR, START_MONTH, START_DAY);
75
129
76 this.map = new TileMap(width, height);
130 this.map = new TileMap(width, height);
77 this.money = 1000;
131 this.money = 100000;
78 this.millisecondsPerAdvance = millisecondsPerAdvance;
132 this.millisecondsPerAdvance = millisecondsPerAdvance;
79
133
80 this.paused = true;
134 this.paused = true;
135
136 this.budgets = new List<Budget>();
81 }
137 }
82
138
83 private void advanceSimulation()
139 private void advanceSimulation()
@@ -108,7 +164,33
108 cell.hasTree = false;
164 cell.hasTree = false;
109 }
165 }
110 }
166 }
167
168
169 //this.money -= (this.map.tree_count * 1);
170 //this.money += 1000;
171
172 Budget newBudget = new Budget
173 {
174 DateTime = this.DateTime,
175 money = this.money,
176 trees = this.map.tree_count,
177 subsidy = 1000,
178 upkeep = this.map.tree_count * 1
179 };
180
181 this.budgets.Add(newBudget);
182
183 this.applyBudget(newBudget); ;
111 }
184 }
185
186 public void applyBudget(Budget budget)
187 {
188
189 this.money = budget.money
190 - (budget.upkeep)
191 + (budget.subsidy);
192 }
193
112 public void update(TimeSpan deltaTime)
194 public void update(TimeSpan deltaTime)
113 {
195 {
114 //this.Tick++;
196 //this.Tick++;
You need to be logged in to leave comments. Login now