From 862b399fa37e6ca692d38177a22ee34860d2251e Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 15 Sep 2025 20:00:47 -0300 Subject: Menu principal --- scripts/InputHandling/CastSpellInputHandler.cs | 17 ++++++++++++++++- scripts/InputHandling/GameOverInputHandler.cs | 8 +++++++- scripts/InputHandling/InputHandler.cs | 9 +++++++++ scripts/InputHandling/MainGameInputHandler.cs | 5 +++++ 4 files changed, 37 insertions(+), 2 deletions(-) (limited to 'scripts/InputHandling') diff --git a/scripts/InputHandling/CastSpellInputHandler.cs b/scripts/InputHandling/CastSpellInputHandler.cs index 1c5d005..904bfab 100644 --- a/scripts/InputHandling/CastSpellInputHandler.cs +++ b/scripts/InputHandling/CastSpellInputHandler.cs @@ -36,12 +36,15 @@ public partial class CastSpellInputHandler : BaseInputHandler [Export] private Map map; + SignalBus.PlayerSpellChooseLocationEventHandler spellLocationLambda; + public override void _Ready() { base._Ready(); + spellLocationLambda = (SpellResource spell) => selectedSpell = spell; // O jogador informa qual feitiço será usado. - SignalBus.Instance.PlayerSpellChooseLocation += (SpellResource spell) => selectedSpell = spell; + SignalBus.Instance.PlayerSpellChooseLocation += spellLocationLambda; } public override void Enter() @@ -90,4 +93,16 @@ public partial class CastSpellInputHandler : BaseInputHandler return action; } + + public override void _Notification(int what) + { + if (what == NotificationPredelete) + { + if (spellLocationLambda != null) + { + SignalBus.Instance.PlayerSpellChooseLocation -= spellLocationLambda; + } + } + base._Notification(what); + } } \ No newline at end of file diff --git a/scripts/InputHandling/GameOverInputHandler.cs b/scripts/InputHandling/GameOverInputHandler.cs index e11e98a..bfd6d79 100644 --- a/scripts/InputHandling/GameOverInputHandler.cs +++ b/scripts/InputHandling/GameOverInputHandler.cs @@ -1,3 +1,4 @@ +using Godot; using TheLegendOfGustav.Entities.Actions; using TheLegendOfGustav.Entities.Actors; @@ -11,6 +12,11 @@ public partial class GameOverInputHandler : BaseInputHandler // Por enquanto não tem nada. public override Action GetAction(Player player) { - return null; + Action action = null; + if (Input.IsActionJustPressed("quit")) + { + action = new EscapeAction(player); + } + return action; } } \ No newline at end of file diff --git a/scripts/InputHandling/InputHandler.cs b/scripts/InputHandling/InputHandler.cs index ce265a1..3c39587 100644 --- a/scripts/InputHandling/InputHandler.cs +++ b/scripts/InputHandling/InputHandler.cs @@ -57,6 +57,15 @@ public partial class InputHandler : Node return SelectedInputHandler.GetAction(player); } + public override void _Notification(int what) + { + if (what == NotificationPredelete) + { + SignalBus.Instance.CommandInputHandler -= SetInputHandler; + } + base._Notification(what); + } + /// /// Define o esquema de controle atual do jogo /// para o estado informado. diff --git a/scripts/InputHandling/MainGameInputHandler.cs b/scripts/InputHandling/MainGameInputHandler.cs index 6a110d7..bbfb9ca 100644 --- a/scripts/InputHandling/MainGameInputHandler.cs +++ b/scripts/InputHandling/MainGameInputHandler.cs @@ -58,6 +58,11 @@ public partial class MainGameInputHandler : BaseInputHandler action = new WaitAction(player); } + if (Input.IsActionJustPressed("quit")) + { + action = new EscapeAction(player); + } + return action; } } -- cgit v1.2.3