Description:
Add tree planting parameter.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -31,6 +31,22 | |||
|
31 | 31 | } |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | public int tree_capacity | |
|
35 | { | |
|
36 | get | |
|
37 | { | |
|
38 | return MapWidth * MapHeight; | |
|
39 | } | |
|
40 | } | |
|
41 | ||
|
42 | public int remaining_tree_capacity | |
|
43 | { | |
|
44 | get | |
|
45 | { | |
|
46 | return this.tree_capacity - this.tree_count; | |
|
47 | } | |
|
48 | } | |
|
49 | ||
|
34 | 50 | public CellMap() |
|
35 | 51 | { |
|
36 | 52 | //TileMap(MapWidth, MapHeight); |
@@ -347,6 +347,16 | |||
|
347 | 347 | this.camera.Jump(Vector2.Zero); |
|
348 | 348 | |
|
349 | 349 | } |
|
350 | if (keyboardCur.IsKeyDown(Keys.O) && keyboardPrev.IsKeyUp(Keys.O)) | |
|
351 | { | |
|
352 | this.simulation.tree_planting -= 1; | |
|
353 | ||
|
354 | } | |
|
355 | if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P)) | |
|
356 | { | |
|
357 | this.simulation.tree_planting += 1; | |
|
358 | ||
|
359 | } | |
|
350 | 360 | if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift)) |
|
351 | 361 | { |
|
352 | 362 | sound.Play(volume, pitch, pan); |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | //expenses |
|
19 | 19 | public decimal upkeep; |
|
20 | public decimal tree_planting; | |
|
20 | 21 | |
|
21 | 22 | |
|
22 | 23 | public decimal final_money; |
@@ -124,6 +125,20 | |||
|
124 | 125 | |
|
125 | 126 | private Random random; |
|
126 | 127 | |
|
128 | //budget params | |
|
129 | ||
|
130 | public int _tree_planting; | |
|
131 | public int tree_planting | |
|
132 | { | |
|
133 | get { | |
|
134 | return _tree_planting; | |
|
135 | } | |
|
136 | set { | |
|
137 | _tree_planting = MathUtils.Clamp(value, 0, 25); | |
|
138 | } | |
|
139 | } | |
|
140 | ||
|
141 | ||
|
127 | 142 | |
|
128 | 143 | |
|
129 | 144 | public Simulation(int width, int height, float millisecondsPerAdvance) |
@@ -170,6 +185,18 | |||
|
170 | 185 | } |
|
171 | 186 | } |
|
172 | 187 | |
|
188 | int trees_to_plant = this.tree_planting; | |
|
189 | ||
|
190 | while (trees_to_plant > 0 && this.map.remaining_tree_capacity > 0) { | |
|
191 | int y = random.Next(0, this.map.MapHeight); | |
|
192 | int x = random.Next(0, this.map.MapWidth); | |
|
193 | Cell chosen_cell = this.map.cells[x][y]; | |
|
194 | ||
|
195 | if (!chosen_cell.hasTree) { | |
|
196 | chosen_cell.hasTree = true; | |
|
197 | trees_to_plant -= 1; | |
|
198 | } | |
|
199 | } | |
|
173 | 200 | |
|
174 | 201 | //this.money -= (this.map.tree_count * 1); |
|
175 | 202 | //this.money += 1000; |
@@ -180,7 +207,8 | |||
|
180 | 207 | money = this.money, |
|
181 | 208 | trees = this.map.tree_count, |
|
182 | 209 | subsidy = 1000, |
|
183 | upkeep = this.map.tree_count * 1 | |
|
210 | upkeep = this.map.tree_count * 1, | |
|
211 | tree_planting = this.tree_planting * 100 | |
|
184 | 212 | }; |
|
185 | 213 | |
|
186 | 214 | |
@@ -192,7 +220,7 | |||
|
192 | 220 | { |
|
193 | 221 | |
|
194 | 222 | this.money = budget.money |
|
195 | - (budget.upkeep) | |
|
223 | - (budget.upkeep + budget.tree_planting) | |
|
196 | 224 | + (budget.subsidy); |
|
197 | 225 | |
|
198 | 226 |
@@ -104,10 +104,11 | |||
|
104 | 104 | batch.DrawString(font, String.Format("REVENUE", this.budget.upkeep), new Vector2(x, bar_height * 4 + y), Color.Black); |
|
105 | 105 | batch.DrawString(font, String.Format("Subsidy................${0:}....${1:}", this.budget.subsidy, this.previous_budget.subsidy), new Vector2(x, bar_height * 5 + y), Color.Black); |
|
106 | 106 | |
|
107 |
batch.DrawString(font, String.Format("EXPENSES", this.budget.upkeep), new Vector2(x, bar_height * |
|
|
108 |
batch.DrawString(font, String.Format("Upkeep.................${0:}....${1:}", this.budget.upkeep, this.previous_budget.upkeep), new Vector2(x, bar_height * |
|
|
107 | batch.DrawString(font, String.Format("EXPENSES", this.budget.upkeep), new Vector2(x, bar_height * 9 + y), Color.Black); | |
|
108 | batch.DrawString(font, String.Format("Upkeep.................${0:}....${1:}", this.budget.upkeep, this.previous_budget.upkeep), new Vector2(x, bar_height * 10 + y), Color.Black); | |
|
109 | batch.DrawString(font, String.Format("Tree Planting..........${0:}....${1:}", this.budget.tree_planting, this.previous_budget.tree_planting), new Vector2(x, bar_height * 11 + y), Color.Black); | |
|
109 | 110 | |
|
110 |
batch.DrawString(font, String.Format("Ending Funds.........${0:}....${1:}", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 1 |
|
|
111 | batch.DrawString(font, String.Format("Ending Funds.........${0:}....${1:}", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 14 + y), Color.Black); | |
|
111 | 112 | |
|
112 | 113 | |
|
113 | 114 | FilledRectangle.drawFilledRectangle(batch, new Rectangle(50, 50, 50, 50), new Color (0, 0,0, 0), 0.99f); |
You need to be logged in to leave comments.
Login now