From c13cbb367a8591b3ffc3f9827b992e765b4b4a14 Mon Sep 17 00:00:00 2001 From: LifeHckr Date: Sun, 2 Mar 2025 12:30:20 -0800 Subject: [PATCH 1/2] Added clearer win/lose screens --- Globals/StageProducer.cs | 8 +- .../BattleDirector/scripts/BattleDirector.cs | 16 +++- scenes/UI/LoseScreen.tscn | 83 +++++++++++++++++++ scenes/UI/RewardSelectionUI.tscn | 9 +- scenes/UI/scripts/LoseScreen.cs | 35 ++++++++ scenes/UI/scripts/RewardSelect.cs | 8 +- 6 files changed, 148 insertions(+), 11 deletions(-) create mode 100644 scenes/UI/LoseScreen.tscn create mode 100644 scenes/UI/scripts/LoseScreen.cs diff --git a/Globals/StageProducer.cs b/Globals/StageProducer.cs index 4c9ab37b..7d6e126a 100644 --- a/Globals/StageProducer.cs +++ b/Globals/StageProducer.cs @@ -10,7 +10,7 @@ public partial class StageProducer : Node public static RandomNumberGenerator GlobalRng = new RandomNumberGenerator(); private ulong _seed; private ulong _lastRngState; - private bool _isInitialized = false; + public static bool IsInitialized; private Stages _curStage = Stages.Title; //TODO: State Machine kinda deal? private Node _curScene; @@ -34,7 +34,7 @@ public void StartGame() PlayerStats = new PlayerStats(); CurRoom = Map.GetRooms()[0]; - _isInitialized = true; + IsInitialized = true; } public static void ChangeCurRoom(MapGrid.Room room) @@ -53,7 +53,7 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1) switch (nextStage) { case Stages.Title: - _isInitialized = false; + IsInitialized = false; GetTree().ChangeSceneToFile("res://scenes/SceneTransitions/TitleScreen.tscn"); break; case Stages.Battle: @@ -73,7 +73,7 @@ public void TransitionStage(Stages nextStage, int nextRoomIdx = -1) break; case Stages.Map: GetTree().ChangeSceneToFile("res://scenes/Maps/cartographer.tscn"); - if (!_isInitialized) + if (!IsInitialized) { StartGame(); } diff --git a/scenes/BattleDirector/scripts/BattleDirector.cs b/scenes/BattleDirector/scripts/BattleDirector.cs index 751e08de..b1c6a4ca 100644 --- a/scenes/BattleDirector/scripts/BattleDirector.cs +++ b/scenes/BattleDirector/scripts/BattleDirector.cs @@ -200,9 +200,7 @@ private void CheckBattleStatus(PuppetTemplate puppet) { if (puppet == Player) { - GD.Print("Player is Dead"); - Audio.StreamPaused = true; - GetNode("/root/StageProducer").TransitionStage(Stages.Title); + LostBattle(); return; } @@ -215,12 +213,22 @@ private void CheckBattleStatus(PuppetTemplate puppet) } } + private void LostBattle() + { + GD.Print("Player is Dead"); + Audio.StreamPaused = true; + AddChild(GD.Load("res://scenes/UI/LoseScreen.tscn").Instantiate()); + GetTree().Paused = true; + } + private void ShowRewardSelection(int amount) { string type = "Note"; if (StageProducer.Config.RoomType == Stages.Boss) type = "Relic"; - RewardSelect.CreateSelection(this, Player.Stats, amount, type).Selected += EndBattle; + var rewardSelect = RewardSelect.CreateSelection(this, Player.Stats, amount, type); + rewardSelect.GetNode