summaryrefslogtreecommitdiff
path: root/scripts/input/MainGameInputHandler.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-08-30 23:21:20 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-08-30 23:21:20 -0300
commit50ba75c55e9e7a483c8a98a9e3f88214678a5244 (patch)
tree1d075999afd5449c13e2ee7a4d9238ba77257aea /scripts/input/MainGameInputHandler.cs
parent178f9e3363f1b0bb2a04ef53ae98b689a13570f3 (diff)
MĂșltiplas formas de input
Diffstat (limited to 'scripts/input/MainGameInputHandler.cs')
-rw-r--r--scripts/input/MainGameInputHandler.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/input/MainGameInputHandler.cs b/scripts/input/MainGameInputHandler.cs
new file mode 100644
index 0000000..1c5ac6e
--- /dev/null
+++ b/scripts/input/MainGameInputHandler.cs
@@ -0,0 +1,35 @@
+using Godot;
+
+/// <summary>
+/// Esquema de controles principal do jogo.
+/// </summary>
+public partial class MainGameInputHandler : 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},
+ };
+ public override 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;
+ }
+}