# HG changeset patch # User Alys Brooks # Date 2021-06-08 07:00:05 # Node ID 796d32fa41fcc4b9cbefc5f0d15ee0dd6e1f2c8e # Parent 297de4636cacbf60f1415ff8635939b5d67ebace Rudimentary game state. diff --git a/TODO.taskpaper b/TODO.taskpaper --- a/TODO.taskpaper +++ b/TODO.taskpaper @@ -30,8 +30,11 @@ - Add tree simulation @milestone(3: Contracts) @done(2021-04-27) - Add contract generation @milestone(3: Contracts) @done(2021-04-12) - Outline reserved areas @milestone(3: Contracts) @done(2021-04-09) - - Add company images @milestone(3: Contracts) @maybe + - Add company images @milestone(3: Contracts) @maybe @done(2021-05-21) + - Contracts should end + - Trees: + - Add basic maintenance cost @milestone(1: Basic Money) @done(2021-01-27) - Add basic age simulation - Biodiversity @maybe @@ -164,6 +167,7 @@ Bugs: Graphics: - Trees jump around when pressing show/hide grid + - Grids sometimes overlap trees. - Trees sometimes - Sometimes framerate jumps to 180-200 fps. (Better than reverse, but kinda weird) Misc: diff --git a/isometric-park-fna/Engines/GameBridgeEngine.cs b/isometric-park-fna/Engines/GameBridgeEngine.cs --- a/isometric-park-fna/Engines/GameBridgeEngine.cs +++ b/isometric-park-fna/Engines/GameBridgeEngine.cs @@ -10,7 +10,8 @@ [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage), typeof(ToggleVisibilityMessage))] - [Reads(typeof(AreaComponent))] + [Reads(typeof(AreaComponent), + typeof(ContractStatusComponent))] class GameBridgeEngine : Engine { @@ -58,11 +59,16 @@ foreach (ref readonly var entity in ReadEntities()) { var areaComponent = GetComponent(entity); + var contractStatusComponent = GetComponent(entity); foreach (var square in areaComponent.squares) { if (game.mouseGrid == square) { game.in_zone = true; + if(contractStatusComponent.status == ContractStatus.Active) + { + game.in_active_zone = true; + } } } 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 @@ -35,6 +35,7 @@ private SpriteBatch batch; private SoundEffect sound; private SpriteFont monoFont; + private SpriteFont largeMonoFont; private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f }); @@ -65,6 +66,9 @@ //for now public bool in_zone; + public bool in_active_zone; + + public bool isPlaying = false; private ImGuiRenderer _imGuiRenderer; private DebugWindow debugWindow; @@ -305,6 +309,21 @@ } ); + var bakedMonoLarge = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), + 30, + 1024, + 1024, + new[] + { + CharacterRange.BasicLatin, + CharacterRange.Latin1Supplement, + CharacterRange.LatinExtendedA, + CharacterRange.Cyrillic, + CharacterRange.LatinExtendedB, + new CharacterRange((char) 0x00B7) + } + ); + this.output = grammar.Flatten("#greeting#"); var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#"); @@ -339,6 +358,7 @@ //font = fontBakeResult.CreateSpriteFont(GraphicsDevice); monoFont = bakedMono.CreateSpriteFont(GraphicsDevice); + largeMonoFont = bakedMonoLarge.CreateSpriteFont(GraphicsDevice); this.budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0); @@ -443,6 +463,10 @@ { sound.Play(volume, pitch, pan); } + if (keyboardCur.IsKeyDown(Keys.A) && keyboardPrev.IsKeyUp(Keys.A)) + { + this.isPlaying = !this.isPlaying; + } #endregion misc_keys // @@ -527,10 +551,15 @@ frameCounter++; string fps = string.Format("fps: {0}", frameRate); + bool has_tree = false; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); GraphicsDevice.Clear(Color.CornflowerBlue); + + _imGuiRenderer.BeforeLayout(gameTime); + if (this.isPlaying) + { batch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, @@ -728,7 +757,6 @@ drawTileAt(3, 2, 140, 2); #endif - _imGuiRenderer.BeforeLayout(gameTime); World.Draw(); // _imGuiRenderer.AfterLayout(); batch.End(); @@ -741,7 +769,6 @@ null, null); - bool has_tree = false; if (MathUtils.BetweenExclusive(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.BetweenExclusive(this.mouseGrid.Y, 0, this.squaresAcross)) { has_tree = this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree; @@ -753,7 +780,7 @@ { status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y, this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status, - this.in_zone ? "Contracted" : "Unzoned" + this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unzoned") ); } @@ -792,6 +819,51 @@ batch.End(); +#region window + if (this.currentNode != null) + { + this.currentNode = DialogInterface.RenderDialog(ref this.showInitial, + ref this.simulation.paused, debugWindow.monoFont, this.currentNode); + } + + if (this.showForest) + { + ForestWindow.Render(this.showForest, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine); + } + + if (this.showNews) + { + NewsWindow.Render(this.showNews, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine); + } + + bool quit = false; + Menu.Render(debugWindow.monoFont, FNAGame.width, this.imGuiWindowBridgeEngine, ref quit, ref this.simulation.paused, ref this.simulation.currentRate, ref this.showBudget, header_left); + + if (quit) { + System.Environment.Exit(0); + } + + } + else { + GraphicsDevice.Clear(Color.Teal); + batch.Begin(SpriteSortMode.BackToFront, + BlendState.AlphaBlend, + null, + null, + null, + null); + + Vector2 middle_dimensions = monoFont.MeasureString("Isometric Park"); + float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2)); + + batch.DrawString(largeMonoFont, "Isometric Park", + new Vector2(middle_start, 50), + Color.Black, 0.0f, Vector2.Zero, + 1.0f, SpriteEffects.None, 0.5f); + batch.End(); + } +#endregion + #region debug_window //Calcs for debug window: @@ -859,29 +931,6 @@ // new DialogOption{ response="Oh yeah, of course.", choice="..." }}; - if (this.currentNode != null) - { - this.currentNode = DialogInterface.RenderDialog(ref this.showInitial, - ref this.simulation.paused, debugWindow.monoFont, this.currentNode); - } - - if (this.showForest) - { - ForestWindow.Render(this.showForest, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine); - } - - if (this.showNews) - { - NewsWindow.Render(this.showNews, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine); - } - - bool quit = false; - Menu.Render(debugWindow.monoFont, FNAGame.width, this.imGuiWindowBridgeEngine, ref quit, ref this.simulation.paused, ref this.simulation.currentRate, ref this.showBudget, header_left); - - if (quit) { - System.Environment.Exit(0); - } - _imGuiRenderer.AfterLayout();