Description:
Subtract towers from budget.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -27,7 +27,8 | |||||
|
27 | typeof(ToolComponent), |
|
27 | typeof(ToolComponent), |
|
28 | typeof(PointComponent))] |
|
28 | typeof(PointComponent))] |
|
29 | [Sends(typeof(ChangeContractStatusMessage), |
|
29 | [Sends(typeof(ChangeContractStatusMessage), |
|
30 |
typeof(PlaySoundMessage) |
|
30 | typeof(PlaySoundMessage), |
|
|
31 | typeof(SingleExpenseMessage))] | ||
|
31 | public class BuildToolEngine : Engine { |
|
32 | public class BuildToolEngine : Engine { |
|
32 |
|
33 | ||
|
33 | private CellMap Map; |
|
34 | private CellMap Map; |
@@ -255,6 +256,8 | |||||
|
255 | new StructureComponent { Structure = Structure.Tower}); |
|
256 | new StructureComponent { Structure = Structure.Tower}); |
|
256 | Destroy(entity); |
|
257 | Destroy(entity); |
|
257 | SendMessage(new PlaySoundMessage { SoundName = "ConstructionShort" }); |
|
258 | SendMessage(new PlaySoundMessage { SoundName = "ConstructionShort" }); |
|
|
259 | SendMessage(new SingleExpenseMessage { category = "Construction", | ||
|
|
260 | amount = 500M }); | ||
|
258 | Logging.Success("Placed Tower!"); |
|
261 | Logging.Success("Placed Tower!"); |
|
259 | } |
|
262 | } |
|
260 |
|
263 |
@@ -21,6 +21,7 | |||||
|
21 | typeof(TreeDeltaComponent), |
|
21 | typeof(TreeDeltaComponent), |
|
22 | typeof(PreserveComponent))] |
|
22 | typeof(PreserveComponent))] |
|
23 | [Writes(typeof(BudgetComponent))] |
|
23 | [Writes(typeof(BudgetComponent))] |
|
|
24 | [Receives(typeof(SingleExpenseMessage))] | ||
|
24 | public class SimulationBridgeEngine : Engine |
|
25 | public class SimulationBridgeEngine : Engine |
|
25 | { |
|
26 | { |
|
26 | public Simulation simulation; |
|
27 | public Simulation simulation; |
@@ -55,6 +56,11 | |||||
|
55 | public override void Update(double dt) |
|
56 | public override void Update(double dt) |
|
56 | { |
|
57 | { |
|
57 |
|
58 | ||
|
|
59 | foreach (ref readonly var message in ReadMessages<SingleExpenseMessage>()) | ||
|
|
60 | { | ||
|
|
61 | this.simulation.AddConstruction(message.amount); | ||
|
|
62 | } | ||
|
|
63 | |||
|
58 | foreach (ref readonly var entity in ReadEntities<BudgetComponent>()) |
|
64 | foreach (ref readonly var entity in ReadEntities<BudgetComponent>()) |
|
59 | { |
|
65 | { |
|
60 | ref readonly var budgetComponent = ref GetComponent<BudgetComponent>(entity); |
|
66 | ref readonly var budgetComponent = ref GetComponent<BudgetComponent>(entity); |
@@ -29,6 +29,7 | |||||
|
29 | public decimal tree_clearing; |
|
29 | public decimal tree_clearing; |
|
30 | public decimal miscellaneous; |
|
30 | public decimal miscellaneous; |
|
31 | public decimal enforcement; |
|
31 | public decimal enforcement; |
|
|
32 | public decimal construction; | ||
|
32 |
|
33 | ||
|
33 |
|
34 | ||
|
34 | public decimal final_money; |
|
35 | public decimal final_money; |
@@ -137,6 +138,7 | |||||
|
137 | return new Budget { }; |
|
138 | return new Budget { }; |
|
138 | } |
|
139 | } |
|
139 | } |
|
140 | } |
|
|
141 | |||
|
140 | } |
|
142 | } |
|
141 |
|
143 | ||
|
142 | public System.Collections.Generic.IEnumerable<Budget> allBudgets() |
|
144 | public System.Collections.Generic.IEnumerable<Budget> allBudgets() |
@@ -391,6 +393,17 | |||||
|
391 | } |
|
393 | } |
|
392 | } |
|
394 | } |
|
393 |
|
395 | ||
|
|
396 | public void AddConstruction(decimal construction_amount) | ||
|
|
397 | { | ||
|
|
398 | if (this.budgets.Count >= 1) { | ||
|
|
399 | var budget = this.budgets[this.budgets.Count - 1]; | ||
|
|
400 | |||
|
|
401 | budget.final_money -= construction_amount; | ||
|
|
402 | budget.construction += construction_amount; | ||
|
|
403 | this.budgets[this.budgets.Count - 1] = budget; | ||
|
|
404 | } | ||
|
|
405 | } | ||
|
|
406 | |||
|
394 | public void updateNews() { |
|
407 | public void updateNews() { |
|
395 | this.latestNewsItems = this.sourceNewsItems.Select(s => s.Flatten(this.grammar)).ToList().Shuffle(); |
|
408 | this.latestNewsItems = this.sourceNewsItems.Select(s => s.Flatten(this.grammar)).ToList().Shuffle(); |
|
396 | } |
|
409 | } |
@@ -402,6 +415,7 | |||||
|
402 | this.updateNews(); |
|
415 | this.updateNews(); |
|
403 | } |
|
416 | } |
|
404 |
|
417 | ||
|
|
418 | |||
|
405 | public void update(TimeSpan deltaTime) |
|
419 | public void update(TimeSpan deltaTime) |
|
406 | { |
|
420 | { |
|
407 | if (!this.paused) |
|
421 | if (!this.paused) |
@@ -122,6 +122,7 | |||||
|
122 | batch.DrawString(font, line_format("Tree Planting", this.budget.tree_planting, this.previous_budget.tree_planting), new Vector2(x, bar_height * 12 + y), Color.Black); |
|
122 | batch.DrawString(font, line_format("Tree Planting", this.budget.tree_planting, this.previous_budget.tree_planting), new Vector2(x, bar_height * 12 + y), Color.Black); |
|
123 | batch.DrawString(font, line_format("Tree Clearing", this.budget.tree_clearing, this.previous_budget.tree_clearing), new Vector2(x, bar_height * 13 + y), Color.Black); |
|
123 | batch.DrawString(font, line_format("Tree Clearing", this.budget.tree_clearing, this.previous_budget.tree_clearing), new Vector2(x, bar_height * 13 + y), Color.Black); |
|
124 | batch.DrawString(font, line_format("Enforcement", this.budget.enforcement, this.previous_budget.enforcement), new Vector2(x, bar_height * 14 + y), Color.Black); |
|
124 | batch.DrawString(font, line_format("Enforcement", this.budget.enforcement, this.previous_budget.enforcement), new Vector2(x, bar_height * 14 + y), Color.Black); |
|
|
125 | batch.DrawString(font, line_format("Construction", this.budget.construction, this.previous_budget.construction), new Vector2(x, bar_height * 15 + y), Color.Black); | ||
|
125 |
|
126 | ||
|
126 | Color cashflow_color = Color.Black; |
|
127 | Color cashflow_color = Color.Black; |
|
127 | if (this.budget.cashflow < 0) { |
|
128 | if (this.budget.cashflow < 0) { |
@@ -132,8 +133,8 | |||||
|
132 | final_color = Color.Red; |
|
133 | final_color = Color.Red; |
|
133 | } |
|
134 | } |
|
134 |
|
135 | ||
|
135 |
batch.DrawString(font, line_format("Cashflow", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 1 |
|
136 | batch.DrawString(font, line_format("Cashflow", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 17 + y), cashflow_color); |
|
136 |
batch.DrawString(font, line_format("Ending Funds", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 1 |
|
137 | batch.DrawString(font, line_format("Ending Funds", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 18 + y), final_color); |
|
137 |
|
138 | ||
|
138 |
|
139 | ||
|
139 | FilledRectangle.drawFilledRectangle(batch, new Rectangle(50, 50, 50, 50), new Color (0, 0,0, 0), 0.99f); |
|
140 | 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