From b05cfd5577884d1a398dbb226e2082af5fe8f8fa Mon Sep 17 00:00:00 2001 From: Matheus Date: Sat, 16 Aug 2025 15:56:28 -0300 Subject: Sistema de turnos básico MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Character.cs | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'scripts/Character.cs') diff --git a/scripts/Character.cs b/scripts/Character.cs index e3707f5..172ffe4 100644 --- a/scripts/Character.cs +++ b/scripts/Character.cs @@ -2,6 +2,7 @@ using Godot; using System; public partial class Character : Actor { + private bool canAct = false; public override void _Input(InputEvent @event) { @@ -9,23 +10,42 @@ public partial class Character : Actor { if (!@event.IsPressed()) return; - Vector2I offset = Vector2I.Zero; + if (canAct) { + - if (@event.IsActionPressed("walk-up")) { - offset += Vector2I.Up; - } - if (@event.IsActionPressed("walk-down")) { - offset += Vector2I.Down; - } - if (@event.IsActionPressed("walk-left")) { - offset += Vector2I.Left; - } - if (@event.IsActionPressed("walk-right")) { - offset += Vector2I.Right; - } + if (@event.IsActionPressed("walk-up")) { + Walk(Vector2I.Up); + } + if (@event.IsActionPressed("walk-down")) { + Walk(Vector2I.Down); + } + if (@event.IsActionPressed("walk-left")) { + Walk(Vector2I.Left); + } + if (@event.IsActionPressed("walk-right")) { + GD.Print("Hello!"); + Walk(Vector2I.Right); + } - if (offset != Vector2I.Zero) { - Walk(offset); + if (@event.IsActionPressed("skip-turn")) { + SkipTurn(); + } } } + + private void SkipTurn() { + GD.Print("Skipped the turn."); + Energy = 0; + EndAction(); + } + + protected override void EndAction() { + canAct = false; + base.EndAction(); + } + + public override void performAction() { + GD.Print("I can act"); + canAct = true; + } } -- cgit v1.2.3