diff options
Diffstat (limited to 'scripts/InputHandling')
| -rw-r--r-- | scripts/InputHandling/CastSpellInputHandler.cs | 17 | ||||
| -rw-r--r-- | scripts/InputHandling/GameOverInputHandler.cs | 8 | ||||
| -rw-r--r-- | scripts/InputHandling/InputHandler.cs | 9 | ||||
| -rw-r--r-- | scripts/InputHandling/MainGameInputHandler.cs | 5 |
4 files changed, 37 insertions, 2 deletions
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); + } + /// <summary> /// 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; } } |
