# HG changeset patch # User alys # Date 2021-02-04 05:20:24 # Node ID 2ba450025c9ebfa5027c3fe0e37eb04d6ba18f7b # Parent a564078e6ec55203f346c9989d88a1a2690e62d0 Add tree clearing parameter. diff --git a/isometric-park-fna/CellMap.cs b/isometric-park-fna/CellMap.cs --- a/isometric-park-fna/CellMap.cs +++ b/isometric-park-fna/CellMap.cs @@ -72,7 +72,7 @@ } - public System.Collections.IEnumerable tree_cells() + public System.Collections.Generic.IEnumerable tree_cells() { foreach (List row in cells) { @@ -86,7 +86,7 @@ } } - public System.Collections.IEnumerable tree_cells(int zone) + public System.Collections.Generic.IEnumerable tree_cells(int zone) { foreach (List row in cells) { @@ -100,7 +100,7 @@ } } - public System.Collections.IEnumerable iterate_cells() + public System.Collections.Generic.IEnumerable iterate_cells() { foreach (List row in cells) { @@ -116,7 +116,7 @@ return MathUtils.Between(x, 0, MapWidth - 1) && MathUtils.Between(y, 0, MapHeight - 1); } - private System.Collections.IEnumerable iterate_neighbors(int x, int y) + private System.Collections.Generic.IEnumerable iterate_neighbors(int x, int y) { //iterates over neighbors (clockwise starting at noon/midnight) if (inBounds(x, y + 1)) @@ -164,7 +164,7 @@ return count; } - public System.Collections.IEnumerable iterate_cells_with_neighbors(int neighbors) + public System.Collections.Generic.IEnumerable iterate_cells_with_neighbors(int neighbors) { for (int i = 0; i < MapHeight; i++) { diff --git a/isometric-park-fna/Simulation.cs b/isometric-park-fna/Simulation.cs --- a/isometric-park-fna/Simulation.cs +++ b/isometric-park-fna/Simulation.cs @@ -18,9 +18,11 @@ //expenses public decimal upkeep; public decimal tree_planting; + public decimal tree_clearing; public decimal final_money; + public decimal cashflow; //misc @@ -137,7 +139,16 @@ _tree_planting = MathUtils.Clamp(value, 0, 25); } } - + public int _tree_clearing = 5; + public int tree_clearing + { + get { + return _tree_clearing; + } + set { + _tree_clearing = MathUtils.Clamp(value, 0, 25); + } + } @@ -198,6 +209,18 @@ } } + int trees_to_clear = this.tree_clearing; + + IEnumerator neigh = this.map.iterate_cells_with_neighbors(7).GetEnumerator(); + + while (trees_to_clear > 0 && neigh.Current != null) + { + Cell current = neigh.Current; + current.hasTree = false; + neigh.MoveNext(); + trees_to_clear -= 1; + } + //this.money -= (this.map.tree_count * 1); //this.money += 1000; @@ -208,7 +231,8 @@ trees = this.map.tree_count, subsidy = 1000, upkeep = this.map.tree_count * 1, - tree_planting = this.tree_planting * 100 + tree_planting = this.tree_planting * 100, + tree_clearing = this.tree_clearing * 100 }; @@ -220,11 +244,12 @@ { this.money = budget.money - - (budget.upkeep + budget.tree_planting) + - (budget.upkeep + budget.tree_planting + budget.tree_clearing) + (budget.subsidy); budget.final_money = this.money; + budget.cashflow = budget.final_money - budget.money; return budget; } diff --git a/isometric-park-fna/UI/BudgetWindow.cs b/isometric-park-fna/UI/BudgetWindow.cs --- a/isometric-park-fna/UI/BudgetWindow.cs +++ b/isometric-park-fna/UI/BudgetWindow.cs @@ -107,8 +107,19 @@ batch.DrawString(font, String.Format("EXPENSES", this.budget.upkeep), new Vector2(x, bar_height * 9 + y), Color.Black); batch.DrawString(font, String.Format("Upkeep.................${0:}....${1:}", this.budget.upkeep, this.previous_budget.upkeep), new Vector2(x, bar_height * 10 + y), Color.Black); 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); + 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); - 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); + Color cashflow_color = Color.Black; + if (this.budget.cashflow < 0) { + cashflow_color = Color.Red; + } + Color final_color = Color.Black; + if (this.budget.final_money < 0) { + final_color = Color.Red; + } + + batch.DrawString(font, String.Format("Cashflow.............${0:}....${1:}", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 14 + y), cashflow_color); + 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); FilledRectangle.drawFilledRectangle(batch, new Rectangle(50, 50, 50, 50), new Color (0, 0,0, 0), 0.99f);