From 5ff97f809851d7e47bdd9166357f02791fbfc724 Mon Sep 17 00:00:00 2001 From: Royce551 Date: Sun, 14 Aug 2022 16:10:46 -0500 Subject: [PATCH] More resolution independence --- FrivoloCo/Screens/Menu/CreditsScreen.cs | 14 +++++++--- FrivoloCo/Screens/Menu/GamemodeScreen.cs | 16 +++++++++--- FrivoloCo/Screens/Menu/MenuScreen.cs | 31 ++++++++++++++++++----- FrivoloCo/Screens/Menu/OptionsScreen.cs | 17 +++++++++---- FrivoloCo/Screens/Play/CustomerStation.cs | 6 +++-- FrivoloCo/Screens/Play/FailScreen.cs | 15 ++++++----- FrivoloCo/Screens/Play/ProgressState.cs | 4 +++ 7 files changed, 76 insertions(+), 27 deletions(-) diff --git a/FrivoloCo/Screens/Menu/CreditsScreen.cs b/FrivoloCo/Screens/Menu/CreditsScreen.cs index ef68585..85487d6 100644 --- a/FrivoloCo/Screens/Menu/CreditsScreen.cs +++ b/FrivoloCo/Screens/Menu/CreditsScreen.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Water.Graphics; using Water.Graphics.Containers; using Water.Graphics.Controls; using Water.Graphics.Screens; @@ -32,11 +33,18 @@ namespace FrivoloCo.Screens.Menu { Layout = Water.Graphics.Layout.Fill }; + + var co = new Container() + { + RelativePosition = new(0, 0, 1920, 1080) + }; + rc.AddChild(co); + var sp = new Sprite("Assets/FrivoloCoBackground.png") { RelativePosition = new(0, 0, 1920, 1080) }; - rc.AddChild(Game.AddObject(sp)); + co.AddChild(Game.AddObject(sp)); AddChild(rc); var tb = new TextBlock(new(0, 0, 0, 0), Game.Fonts.Get("Assets/IBMPLEXSANS-MEDIUM.TTF", 40), "", Color.Black) @@ -53,7 +61,7 @@ namespace FrivoloCo.Screens.Menu Margin = 10, Color = Color.White * 0.5f }; - AddChild(Game.AddObject(box)); + co.AddChild(Game.AddObject(box)); box.AddChild(Game.AddObject(tb)); var button = new SpriteButton("Assets/back.png", "Assets/backA.png", () => { ScreenManager.ChangeScreen(new MenuScreen()); }) @@ -62,7 +70,7 @@ namespace FrivoloCo.Screens.Menu RelativePosition = new(0, 0, 250, 100), Margin = 10 }; - AddChild(Game.AddObject(button)); + co.AddChild(Game.AddObject(button)); } public override void Update(GameTime gameTime) diff --git a/FrivoloCo/Screens/Menu/GamemodeScreen.cs b/FrivoloCo/Screens/Menu/GamemodeScreen.cs index 341b9fd..bd49dbe 100644 --- a/FrivoloCo/Screens/Menu/GamemodeScreen.cs +++ b/FrivoloCo/Screens/Menu/GamemodeScreen.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using Water.Graphics; using Water.Graphics.Containers; using Water.Graphics.Controls; using Water.Graphics.Screens; @@ -40,11 +41,18 @@ namespace FrivoloCo.Screens.Menu { Layout = Water.Graphics.Layout.Fill }; + + var co = new Container() + { + RelativePosition = new(0, 0, 1920, 1080) + }; + rc.AddChild(co); + sp = new Sprite("Assets/FrivoloCoBackground.png") { RelativePosition = new(0, 0, 1920, 1080) }; - rc.AddChild(Game.AddObject(sp)); + co.AddChild(Game.AddObject(sp)); AddChild(rc); bt = new SpriteButton("Assets/endless.png", "Assets/endlessA.png", () => { beginGame = true; }) @@ -52,21 +60,21 @@ namespace FrivoloCo.Screens.Menu RelativePosition = new(0, 300, 250, 100), Layout = Water.Graphics.Layout.HorizontalCenter }; - AddChild(Game.AddObject(bt)); + co.AddChild(Game.AddObject(bt)); bt2 = new SpriteButton("Assets/tutorial.png", "Assets/tutorialA.png", () => { ScreenManager.ChangeScreen(new OptionsScreen()); }) { RelativePosition = new(0, 450, 250, 100), Layout = Water.Graphics.Layout.HorizontalCenter }; - AddChild(Game.AddObject(bt2)); + co.AddChild(Game.AddObject(bt2)); bt3 = new SpriteButton("Assets/back.png", "Assets/backA.png", () => { ScreenManager.ChangeScreen(new MenuScreen()); }) { RelativePosition = new(0, 600, 250, 100), Layout = Water.Graphics.Layout.HorizontalCenter }; - AddChild(Game.AddObject(bt3)); + co.AddChild(Game.AddObject(bt3)); } private double counter = 1; diff --git a/FrivoloCo/Screens/Menu/MenuScreen.cs b/FrivoloCo/Screens/Menu/MenuScreen.cs index 3c7add0..c637478 100644 --- a/FrivoloCo/Screens/Menu/MenuScreen.cs +++ b/FrivoloCo/Screens/Menu/MenuScreen.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using Water.Graphics; using Water.Graphics.Containers; using Water.Graphics.Controls; using Water.Graphics.Screens; @@ -33,6 +34,7 @@ namespace FrivoloCo.Screens.Menu private Sprite bt2; private Sprite bt3; private Sprite bt4; + private TextBlock tx; public override void Initialize() { @@ -43,11 +45,19 @@ namespace FrivoloCo.Screens.Menu { Layout = Water.Graphics.Layout.Fill }; + + var co = new Container() + { + RelativePosition = new(0, 0, 1920, 1080) + }; + + rc.AddChild(co); + sp = new Sprite("Assets/FrivoloCoBackground.png") { RelativePosition = new(0, 0, 1920, 1080) }; - rc.AddChild(Game.AddObject(sp)); + co.AddChild(Game.AddObject(sp)); AddChild(rc); logo = new Sprite("Assets/frivologo.png") @@ -56,36 +66,43 @@ namespace FrivoloCo.Screens.Menu Layout = Water.Graphics.Layout.AnchorTop, Margin = 50 }; - AddChild(Game.AddObject(logo)); + co.AddChild(Game.AddObject(logo)); bt = new SpriteButton("Assets/indulge.png", "Assets/indulgeA.png", () => { ScreenManager.ChangeScreen(new GamemodeScreen()); }) { RelativePosition = new(0, 300, 250, 100), Layout = Water.Graphics.Layout.HorizontalCenter }; - AddChild(Game.AddObject(bt)); + co.AddChild(Game.AddObject(bt)); bt2 = new SpriteButton("Assets/options.png", "Assets/optionsA.png", () => { ScreenManager.ChangeScreen(new OptionsScreen()); }) { RelativePosition = new(0, 450, 250, 100), Layout = Water.Graphics.Layout.HorizontalCenter }; - AddChild(Game.AddObject(bt2)); + co.AddChild(Game.AddObject(bt2)); bt3 = new SpriteButton("Assets/credits.png", "Assets/creditsA.png", () => { ScreenManager.ChangeScreen(new CreditsScreen()); }) { RelativePosition = new(0, 600, 250, 100), Layout = Water.Graphics.Layout.HorizontalCenter }; - AddChild(Game.AddObject(bt3)); + co.AddChild(Game.AddObject(bt3)); bt4 = new SpriteButton("Assets/exit.png", "Assets/exitA.png", () => { Environment.Exit(0); }) { RelativePosition = new(0, 750, 250, 100), Layout = Water.Graphics.Layout.HorizontalCenter }; + co.AddChild(Game.AddObject(bt4)); - AddChild(Game.AddObject(bt4)); + tx = new TextBlock(new(0, 0, 400, 18), Game.Fonts.Get("Assets/IBMPLEXSANS-MEDIUM.TTF", 20), "Ver. 1 - initial Game Jam release", Color.White) + { + Layout = Water.Graphics.Layout.AnchorBottomLeft, + HorizontalTextAlignment = HorizontalTextAlignment.Left, + VerticalTextAlignment = VerticalTextAlignment.Bottom + }; + co.AddChild(Game.AddObject(tx)); } private double counter = 0; @@ -93,7 +110,7 @@ namespace FrivoloCo.Screens.Menu { counter += gameTime.ElapsedGameTime.TotalSeconds; - sp.Color = logo.Color = bt.Color = bt2.Color = bt3.Color = bt4.Color = Color.White * (float)counter; + sp.Color = logo.Color = bt.Color = bt2.Color = bt3.Color = bt4.Color = tx.Color = Color.White * (float)counter; } } } diff --git a/FrivoloCo/Screens/Menu/OptionsScreen.cs b/FrivoloCo/Screens/Menu/OptionsScreen.cs index 008c7ea..d7c3c82 100644 --- a/FrivoloCo/Screens/Menu/OptionsScreen.cs +++ b/FrivoloCo/Screens/Menu/OptionsScreen.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Water.Graphics; using Water.Graphics.Containers; using Water.Graphics.Controls; using Water.Graphics.Screens; @@ -31,11 +32,18 @@ namespace FrivoloCo.Screens.Menu { Layout = Water.Graphics.Layout.Fill }; + + var co = new Container() + { + RelativePosition = new(0, 0, 1920, 1080) + }; + rc.AddChild(co); + var sp = new Sprite("Assets/FrivoloCoBackground.png") { RelativePosition = new(0, 0, 1920, 1080) }; - rc.AddChild(Game.AddObject(sp)); + co.AddChild(Game.AddObject(sp)); AddChild(rc); var tb = new TextBlock(new(0, 0, 0, 0), Game.Fonts.Get("Assets/IBMPLEXSANS-MEDIUM.TTF", 40), "", Color.Black) @@ -45,15 +53,14 @@ namespace FrivoloCo.Screens.Menu VerticalTextAlignment = VerticalTextAlignment.Top, Margin = 10 }; - tb.Text = "Since we don't have an actual options menu yet, the config file should have been opened with your text editor.\n" + - "Once you're done, hit the back button and the new settings will be loaded :)"; + tb.Text = "options coming soon :)"; var box = new Box() { Layout = Water.Graphics.Layout.Fill, Margin = 10, Color = Color.White * 0.5f }; - AddChild(Game.AddObject(box)); + co.AddChild(Game.AddObject(box)); box.AddChild(Game.AddObject(tb)); var button = new SpriteButton("Assets/back.png", "Assets/backA.png", () => { ScreenManager.ChangeScreen(new MenuScreen()); }) @@ -62,7 +69,7 @@ namespace FrivoloCo.Screens.Menu RelativePosition = new(0, 0, 250, 100), Margin = 10 }; - AddChild(Game.AddObject(button)); + co.AddChild(Game.AddObject(button)); } public override void Update(GameTime gameTime) diff --git a/FrivoloCo/Screens/Play/CustomerStation.cs b/FrivoloCo/Screens/Play/CustomerStation.cs index 921a8cf..3706f95 100644 --- a/FrivoloCo/Screens/Play/CustomerStation.cs +++ b/FrivoloCo/Screens/Play/CustomerStation.cs @@ -140,11 +140,13 @@ namespace FrivoloCo.Screens.Play { SoundEffect.FromFile(customer.ImDoneSound).Play(); state.Strikes++; + progress.TotalStrikes++; happy = false; } if (happy) { progress.Money += (decimal)(10 * customer.Happiness * progress.Day); + progress.CustomersServed++; SoundEffect.FromFile("Assets/Gameplay/kaching.wav").Play(); } customer = null; @@ -188,6 +190,7 @@ namespace FrivoloCo.Screens.Play { SoundEffect.FromFile(customer.WrongOrderSound).Play(); state.Strikes++; + progress.TotalStrikes++; return; } foreach (var entry in customer.Order) @@ -222,8 +225,7 @@ namespace FrivoloCo.Screens.Play minIntervalBetweenCustomers -= gameTime.ElapsedGameTime.TotalMilliseconds; if (minIntervalBetweenCustomers <= 0) { - //var diceRoll = Random.Shared.Next(0, 5000); - if (/*diceRoll == 5 && */state.TimeDelayBetweenCustomers <= 0) + if (state.TimeDelayBetweenCustomers <= 0) { CustomerEnters(); ResetMinInterval(); diff --git a/FrivoloCo/Screens/Play/FailScreen.cs b/FrivoloCo/Screens/Play/FailScreen.cs index e626db7..5da947b 100644 --- a/FrivoloCo/Screens/Play/FailScreen.cs +++ b/FrivoloCo/Screens/Play/FailScreen.cs @@ -66,17 +66,20 @@ namespace FrivoloCo.Screens.Play HorizontalTextAlignment = HorizontalTextAlignment.Center, VerticalTextAlignment = VerticalTextAlignment.Center }; - tb.Text = $"FAILED\nYour terrible performance caused people to stop going to FrivoloCo,\nso you were fired.\n(press esc to go back)\n\nScore: ${progress.Money:0..00}"; + tb.Text = + $"FAILED\nYour terrible performance caused people to stop going to FrivoloCo,\n" + + $"so you were fired.\n" + + $"(press any key to go back)\n" + + $"\n" + + $"Score: ${progress.Money:0..00}\n" + + $"Mistakes: {progress.TotalStrikes} Customers Served: {progress.CustomersServed}"; co.AddChild(Game.AddObject(tb)); } private void Input_KeyDown(object sender, Water.Input.KeyEventArgs e) { - if (e.Key == Microsoft.Xna.Framework.Input.Keys.Escape) - { - MediaPlayer.Stop(); - ScreenManager.ChangeScreen(new MenuScreen()); - } + MediaPlayer.Stop(); + ScreenManager.ChangeScreen(new MenuScreen()); } private double counter; diff --git a/FrivoloCo/Screens/Play/ProgressState.cs b/FrivoloCo/Screens/Play/ProgressState.cs index b9dfa55..8b4983f 100644 --- a/FrivoloCo/Screens/Play/ProgressState.cs +++ b/FrivoloCo/Screens/Play/ProgressState.cs @@ -13,5 +13,9 @@ namespace FrivoloCo.Screens.Play public decimal Money { get; set; } = 1; public int SongPlayed { get; set; } = 1; + + public int TotalStrikes { get; set; } = 0; + + public int CustomersServed { get; set; } = 0; } }