diff --git a/isometric-park-fna/BudgetWindow.cs b/isometric-park-fna/BudgetWindow.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/BudgetWindow.cs @@ -0,0 +1,96 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; + +namespace isometricparkfna +{ + public class BudgetWindow + { + private Budget budget; + private SpriteFont font; + public int x; + public int y; + + + private Vector2 mouseEnd; + private Vector2 mouseStart; + private MouseState mousePrev; + + public BudgetWindow(Budget budget, SpriteFont font, int start_x, int start_y) + { + + this.budget = budget; + this.font = font; + this.x = start_x; + this.y = start_y; + } + + public void update(MouseState mouseCur, Budget budget) + { + this.budget = budget; + + if ((mouseCur.LeftButton == ButtonState.Pressed) + && MathUtils.Between(mouseCur.X, x, 700+x) + && MathUtils.Between(mouseCur.Y, y, 500 + y)) + { + if (mousePrev.LeftButton == ButtonState.Released) + { + this.mouseStart = new Vector2(mouseCur.X, mouseCur.Y); + + } + else + { + this.mouseEnd = new Vector2(mouseCur.X, mouseCur.Y); + } + } + else if (mousePrev.LeftButton == ButtonState.Pressed) + { + this.x = MathUtils.Clamp(this.x + (int)(this.mouseEnd.X - this.mouseStart.X), 0, 700); + this.y = MathUtils.Clamp(this.y + (int)(this.mouseEnd.Y - this.mouseStart.Y), 0, 400); + + } + + this.mousePrev = mouseCur; + + //if ((mouseCur.LeftButton == ButtonState.Pressed) + // && MathUtils.Between(mouseCur.X, x, 700 + x) + // && MathUtils.Between(mouseCur.Y, y, 500 + y)) + //{ + // this.x += 50; + //} + } + + public void draw(SpriteBatch batch) + { + int bar_height = 25; + int height = 500; + + for (int i = 1; i < (height / bar_height); i++) + { + Rectangle position = new Rectangle(this.x, bar_height * i + this.y, + 700, bar_height); + + if ((i % 2) == 0) + { + FilledRectangle.drawFilledRectangle(batch, position, Color.LightGreen, 0.99f); + } + else + { + FilledRectangle.drawFilledRectangle(batch, position, Color.White, 0.99f); + } + } + + batch.DrawString(font, String.Format("Starting Funds.........${0:}", this.budget.money), new Vector2(x, bar_height * 1 + y), Color.Black); + + batch.DrawString(font, String.Format("REVENUE", this.budget.upkeep), new Vector2(x, bar_height * 3 + y), Color.Black); + batch.DrawString(font, String.Format("Subsidy................${0:}", this.budget.upkeep), new Vector2(x, bar_height * 4 + y), Color.Black); + + batch.DrawString(font, String.Format("EXPENSES", this.budget.upkeep), new Vector2(x, bar_height * 6 + y), Color.Black); + batch.DrawString(font, String.Format("Upkeep.................${0:}", this.budget.upkeep), new Vector2(x, bar_height * 7 + y), Color.Black); + + batch.DrawString(font, String.Format("Ending Funds.........${0:}", this.budget.final_money), new Vector2(x, bar_height * 10 + y), Color.Black); + + } + } +} diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -75,11 +75,13 @@ private Queue> remainingDialog; - private bool showGrid = true; + private bool showGrid; private Grammar grammar; private string output; private bool showSecond = true; private GraphicsDeviceManager gdm; + private bool showBudget; + private BudgetWindow budgetWindow; private static void Main(string[] args) { @@ -127,6 +129,8 @@ showInitial = true; messageIndex = 0; + showBudget = false; + showGrid = true; this.Window.Title = "Isometric Park"; @@ -134,7 +138,8 @@ currentNode = DialogTrees.introTree; - + + } @@ -193,6 +198,9 @@ //font = fontBakeResult.CreateSpriteFont(GraphicsDevice); monoFont = bakedMono.CreateSpriteFont(GraphicsDevice); + this.budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0); + + } protected override void UnloadContent() @@ -328,6 +336,11 @@ this.showGrid = !this.showGrid; } + if (keyboardCur.IsKeyDown(Keys.B) && keyboardPrev.IsKeyUp(Keys.B)) + { + this.showBudget = !this.showBudget; + + } if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C)) { this.camera.Jump(Vector2.Zero); @@ -392,8 +405,15 @@ #endregion input + + this.simulation.update(gameTime.ElapsedGameTime); + if (this.showBudget) + { + this.budgetWindow.update(mouseCur, this.simulation.latestBudget); + } + if (!this.showInitial && this.remainingDialog.Count > 0) { @@ -789,10 +809,20 @@ batch.DrawString(monoFont, header_left, new Vector2(1, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); batch.DrawString(monoFont, header_middle, new Vector2(middle_start, 1), Color.Black, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.5f); -#endregion draw_header + #endregion draw_header - batch.End(); + #region budget + + if (this.showBudget) + { + budgetWindow.draw(batch); + + } + + #endregion budget + + batch.End(); #region debug_window //Calcs for debug window: 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 @@ -7,6 +7,8 @@ public struct Budget { public DateTime DateTime; + + //assets public decimal money; @@ -17,6 +19,9 @@ public decimal upkeep; + public decimal final_money; + + //misc public int trees; @@ -183,12 +188,15 @@ this.applyBudget(newBudget); ; } - public void applyBudget(Budget budget) + public void applyBudget(Budget budget) ///hacky { this.money = budget.money - (budget.upkeep) + (budget.subsidy); + + + budget.final_money = this.money; } public void update(TimeSpan deltaTime) diff --git a/isometric-park-fna/Utils/MathUtils.cs b/isometric-park-fna/Utils/MathUtils.cs --- a/isometric-park-fna/Utils/MathUtils.cs +++ b/isometric-park-fna/Utils/MathUtils.cs @@ -19,6 +19,22 @@ } + public static int Clamp(int val, int min, int max) + { + if(val > max) + { + return max; + } + else if (val < min) + { + return min; + } + else + { + return val; + } + } + protected float Decrement(float value, float delta) { float magnitude = Math.Abs(value); diff --git a/isometric-park-fna/isometric-park-fna.csproj b/isometric-park-fna/isometric-park-fna.csproj --- a/isometric-park-fna/isometric-park-fna.csproj +++ b/isometric-park-fna/isometric-park-fna.csproj @@ -47,6 +47,7 @@ +