From 358943907bc9e37d26618ee03adf1ffd97635335 Mon Sep 17 00:00:00 2001 From: Matheus Date: Thu, 28 Aug 2025 17:01:53 -0300 Subject: Combate corpo a corpo. --- scripts/input/BaseInputHandler.cs.uid | 1 + scripts/input/InputHandler.cs | 36 +++++++++++++++++++++++++++++++++++ scripts/input/InputHandler.cs.uid | 1 + 3 files changed, 38 insertions(+) create mode 100644 scripts/input/BaseInputHandler.cs.uid create mode 100644 scripts/input/InputHandler.cs create mode 100644 scripts/input/InputHandler.cs.uid (limited to 'scripts/input') diff --git a/scripts/input/BaseInputHandler.cs.uid b/scripts/input/BaseInputHandler.cs.uid new file mode 100644 index 0000000..deae303 --- /dev/null +++ b/scripts/input/BaseInputHandler.cs.uid @@ -0,0 +1 @@ +uid://cl1of0602byx0 diff --git a/scripts/input/InputHandler.cs b/scripts/input/InputHandler.cs new file mode 100644 index 0000000..838790e --- /dev/null +++ b/scripts/input/InputHandler.cs @@ -0,0 +1,36 @@ +using System.Numerics; +using Godot; + +/// +/// Obtém input do usuário. +/// +public partial class InputHandler : Node { + 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}, + }; + public Action GetAction(Player player) { + Action action = null; + + if (player.IsAlive) { + foreach (var direction in directions) { + if (Input.IsActionJustPressed(direction.Key)) { + action = new BumpAction(player, direction.Value); + } + } + + if (Input.IsActionJustPressed("skip-turn")) { + action = new WaitAction(player); + } + } + + return action; + } +} diff --git a/scripts/input/InputHandler.cs.uid b/scripts/input/InputHandler.cs.uid new file mode 100644 index 0000000..302a3b5 --- /dev/null +++ b/scripts/input/InputHandler.cs.uid @@ -0,0 +1 @@ +uid://ejqmdbc0524i -- cgit v1.2.3