diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-04 21:08:57 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-04 21:08:57 -0300 |
| commit | 4b2afd3e2144e42bfa7f11a870584b9255052cf7 (patch) | |
| tree | 11bcb45e3c93532d2aeaea69b4387ccda365bc22 /scripts/input | |
| parent | 1e248d3dd18f7c6bfaf8066c4662facbbb89e8f9 (diff) | |
INVENTÁRIO PEGÁVEL AAAAAAAAAAAAAAAAAAAAAAAAAAAA
Diffstat (limited to 'scripts/input')
| -rw-r--r-- | scripts/input/InputHandler.cs | 4 | ||||
| -rw-r--r-- | scripts/input/MainGameInputHandler.cs | 4 | ||||
| -rw-r--r-- | scripts/input/PickupInputHandler.cs | 41 | ||||
| -rw-r--r-- | scripts/input/PickupInputHandler.cs.uid | 1 |
4 files changed, 49 insertions, 1 deletions
diff --git a/scripts/input/InputHandler.cs b/scripts/input/InputHandler.cs index 4f5b4e1..7ee2be1 100644 --- a/scripts/input/InputHandler.cs +++ b/scripts/input/InputHandler.cs @@ -4,7 +4,8 @@ public enum InputHandlers { MainGame, GameOver, - Inspect + Inspect, + Pickup } /// <summary> @@ -27,6 +28,7 @@ public partial class InputHandler : Node // Controles para quando o jogador está morto. inputHandlers.Add(InputHandlers.GameOver, GetNode<GameOverInputHandler>("GameOverInputHandler")); inputHandlers.Add(InputHandlers.Inspect, GetNode<InspectInputHandler>("InspectInputHandler")); + inputHandlers.Add(InputHandlers.Pickup, GetNode<PickupInputHandler>("PickupInputHandler")); SetInputHandler(startingInputHandler); } diff --git a/scripts/input/MainGameInputHandler.cs b/scripts/input/MainGameInputHandler.cs index c7bf26a..6fb6aac 100644 --- a/scripts/input/MainGameInputHandler.cs +++ b/scripts/input/MainGameInputHandler.cs @@ -25,6 +25,10 @@ public partial class MainGameInputHandler : BaseInputHandler { } } + if (Input.IsActionJustPressed("pick-item")) { + GetParent<InputHandler>().SetInputHandler(InputHandlers.Pickup); + } + if (Input.IsActionJustPressed("inspect")) { GetParent<InputHandler>().SetInputHandler(InputHandlers.Inspect); } diff --git a/scripts/input/PickupInputHandler.cs b/scripts/input/PickupInputHandler.cs new file mode 100644 index 0000000..8f4f9b2 --- /dev/null +++ b/scripts/input/PickupInputHandler.cs @@ -0,0 +1,41 @@ +using Godot; + +/// <summary> +/// Esquema de controles para pegar um item. +/// </summary> +public partial class PickupInputHandler : BaseInputHandler { + private readonly Godot.Collections.Dictionary<string, Vector2I> directions = new() + { + {"walk-up", Vector2I.Up}, + {"walk-down", Vector2I.Down}, + {"walk-left", Vector2I.Left}, + {"walk-right", Vector2I.Right}, + {"walk-up-right", Vector2I.Up + Vector2I.Right}, + {"walk-up-left", Vector2I.Up + Vector2I.Left}, + {"walk-down-right", Vector2I.Down + Vector2I.Right}, + {"walk-down-left", Vector2I.Down + Vector2I.Left}, + {"skip-turn", Vector2I.Zero} + }; + public override Action GetAction(Player player) { + Action action = null; + + if (player.IsAlive) { + foreach (var direction in directions) { + if (Input.IsActionJustPressed(direction.Key)) { + action = new PickupAction(player, direction.Value); + Quit(); + } + } + + if (Input.IsActionJustPressed("quit")) { + Quit(); + } + } + + return action; + } + + private void Quit() { + GetParent<InputHandler>().SetInputHandler(InputHandlers.MainGame); + } +} diff --git a/scripts/input/PickupInputHandler.cs.uid b/scripts/input/PickupInputHandler.cs.uid new file mode 100644 index 0000000..139dd25 --- /dev/null +++ b/scripts/input/PickupInputHandler.cs.uid @@ -0,0 +1 @@ +uid://dspqgdxg5jji0 |
