Description:
Add tree clearing parameter.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -72,7 +72,7 | |||
|
72 | 72 | |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | public System.Collections.IEnumerable tree_cells() | |
|
75 | public System.Collections.Generic.IEnumerable<Cell> tree_cells() | |
|
76 | 76 | { |
|
77 | 77 | foreach (List<Cell> row in cells) |
|
78 | 78 | { |
@@ -86,7 +86,7 | |||
|
86 | 86 | } |
|
87 | 87 | } |
|
88 | 88 | |
|
89 | public System.Collections.IEnumerable tree_cells(int zone) | |
|
89 | public System.Collections.Generic.IEnumerable<Cell> tree_cells(int zone) | |
|
90 | 90 | { |
|
91 | 91 | foreach (List<Cell> row in cells) |
|
92 | 92 | { |
@@ -100,7 +100,7 | |||
|
100 | 100 | } |
|
101 | 101 | } |
|
102 | 102 | |
|
103 | public System.Collections.IEnumerable iterate_cells() | |
|
103 | public System.Collections.Generic.IEnumerable<Cell> iterate_cells() | |
|
104 | 104 | { |
|
105 | 105 | foreach (List<Cell> row in cells) |
|
106 | 106 | { |
@@ -116,7 +116,7 | |||
|
116 | 116 | return MathUtils.Between(x, 0, MapWidth - 1) && MathUtils.Between(y, 0, MapHeight - 1); |
|
117 | 117 | } |
|
118 | 118 | |
|
119 | private System.Collections.IEnumerable iterate_neighbors(int x, int y) | |
|
119 | private System.Collections.Generic.IEnumerable<Cell> iterate_neighbors(int x, int y) | |
|
120 | 120 | { |
|
121 | 121 | //iterates over neighbors (clockwise starting at noon/midnight) |
|
122 | 122 | if (inBounds(x, y + 1)) |
@@ -164,7 +164,7 | |||
|
164 | 164 | return count; |
|
165 | 165 | } |
|
166 | 166 | |
|
167 | public System.Collections.IEnumerable iterate_cells_with_neighbors(int neighbors) | |
|
167 | public System.Collections.Generic.IEnumerable<Cell> iterate_cells_with_neighbors(int neighbors) | |
|
168 | 168 | { |
|
169 | 169 | for (int i = 0; i < MapHeight; i++) |
|
170 | 170 | { |
@@ -18,9 +18,11 | |||
|
18 | 18 | //expenses |
|
19 | 19 | public decimal upkeep; |
|
20 | 20 | public decimal tree_planting; |
|
21 | public decimal tree_clearing; | |
|
21 | 22 | |
|
22 | 23 | |
|
23 | 24 | public decimal final_money; |
|
25 | public decimal cashflow; | |
|
24 | 26 | |
|
25 | 27 | |
|
26 | 28 | //misc |
@@ -137,7 +139,16 | |||
|
137 | 139 | _tree_planting = MathUtils.Clamp(value, 0, 25); |
|
138 | 140 | } |
|
139 | 141 | } |
|
140 | ||
|
142 | public int _tree_clearing = 5; | |
|
143 | public int tree_clearing | |
|
144 | { | |
|
145 | get { | |
|
146 | return _tree_clearing; | |
|
147 | } | |
|
148 | set { | |
|
149 | _tree_clearing = MathUtils.Clamp(value, 0, 25); | |
|
150 | } | |
|
151 | } | |
|
141 | 152 | |
|
142 | 153 | |
|
143 | 154 | |
@@ -198,6 +209,18 | |||
|
198 | 209 | } |
|
199 | 210 | } |
|
200 | 211 | |
|
212 | int trees_to_clear = this.tree_clearing; | |
|
213 | ||
|
214 | IEnumerator<Cell> neigh = this.map.iterate_cells_with_neighbors(7).GetEnumerator(); | |
|
215 | ||
|
216 | while (trees_to_clear > 0 && neigh.Current != null) | |
|
217 | { | |
|
218 | Cell current = neigh.Current; | |
|
219 | current.hasTree = false; | |
|
220 | neigh.MoveNext(); | |
|
221 | trees_to_clear -= 1; | |
|
222 | } | |
|
223 | ||
|
201 | 224 | //this.money -= (this.map.tree_count * 1); |
|
202 | 225 | //this.money += 1000; |
|
203 | 226 | |
@@ -208,7 +231,8 | |||
|
208 | 231 | trees = this.map.tree_count, |
|
209 | 232 | subsidy = 1000, |
|
210 | 233 | upkeep = this.map.tree_count * 1, |
|
211 | tree_planting = this.tree_planting * 100 | |
|
234 | tree_planting = this.tree_planting * 100, | |
|
235 | tree_clearing = this.tree_clearing * 100 | |
|
212 | 236 | }; |
|
213 | 237 | |
|
214 | 238 | |
@@ -220,11 +244,12 | |||
|
220 | 244 | { |
|
221 | 245 | |
|
222 | 246 | this.money = budget.money |
|
223 | - (budget.upkeep + budget.tree_planting) | |
|
247 | - (budget.upkeep + budget.tree_planting + budget.tree_clearing) | |
|
224 | 248 | + (budget.subsidy); |
|
225 | 249 | |
|
226 | 250 | |
|
227 | 251 | budget.final_money = this.money; |
|
252 | budget.cashflow = budget.final_money - budget.money; | |
|
228 | 253 | |
|
229 | 254 | return budget; |
|
230 | 255 | } |
@@ -107,8 +107,19 | |||
|
107 | 107 | batch.DrawString(font, String.Format("EXPENSES", this.budget.upkeep), new Vector2(x, bar_height * 9 + y), Color.Black); |
|
108 | 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 | 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); |
|
110 | batch.DrawString(font, String.Format("Tree Clearing..........${0:}....${1:}", this.budget.tree_clearing, this.previous_budget.tree_clearing), new Vector2(x, bar_height * 12 + y), Color.Black); | |
|
110 | 111 | |
|
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); | |
|
112 | Color cashflow_color = Color.Black; | |
|
113 | if (this.budget.cashflow < 0) { | |
|
114 | cashflow_color = Color.Red; | |
|
115 | } | |
|
116 | Color final_color = Color.Black; | |
|
117 | if (this.budget.final_money < 0) { | |
|
118 | final_color = Color.Red; | |
|
119 | } | |
|
120 | ||
|
121 | batch.DrawString(font, String.Format("Cashflow.............${0:}....${1:}", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 14 + y), cashflow_color); | |
|
122 | batch.DrawString(font, String.Format("Ending Funds.........${0:}....${1:}", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 15 + y), final_color); | |
|
112 | 123 | |
|
113 | 124 | |
|
114 | 125 | 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