From 4b2afd3e2144e42bfa7f11a870584b9255052cf7 Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 4 Sep 2025 21:08:57 -0300 Subject: INVENTÁRIO PEGÁVEL AAAAAAAAAAAAAAAAAAAAAAAAAAAA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/input/PickupInputHandler.cs | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 scripts/input/PickupInputHandler.cs (limited to 'scripts/input/PickupInputHandler.cs') 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; + +/// +/// Esquema de controles para pegar um item. +/// +public partial class PickupInputHandler : BaseInputHandler { + private readonly Godot.Collections.Dictionary 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().SetInputHandler(InputHandlers.MainGame); + } +} -- cgit v1.2.3