summaryrefslogtreecommitdiff
path: root/scripts/input/InputHandler.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-08-28 17:01:53 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-08-28 17:01:53 -0300
commit358943907bc9e37d26618ee03adf1ffd97635335 (patch)
tree223b32f5631d3decb679302b489e6d7e124674c8 /scripts/input/InputHandler.cs
parentafcd5055e98dcb7c9fefeabb072ecc56d0456bd7 (diff)
Combate corpo a corpo.
Diffstat (limited to 'scripts/input/InputHandler.cs')
-rw-r--r--scripts/input/InputHandler.cs36
1 files changed, 36 insertions, 0 deletions
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;
+
+/// <summary>
+/// Obtém input do usuário.
+/// </summary>
+public partial class InputHandler : Node {
+ 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},
+ };
+ 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;
+ }
+}