summaryrefslogtreecommitdiff
path: root/scripts/Actor.cs
diff options
context:
space:
mode:
authormatheus20337 <149222182+matheus20337@users.noreply.github.com>2025-08-16 20:32:15 +0000
committerGitHub <noreply@github.com>2025-08-16 20:32:15 +0000
commit7f6f4df85368a328ce69fb0b244a706b7dbfc6aa (patch)
tree26961e5c63e87c5d1c17422cdf6ab4493b2d8f55 /scripts/Actor.cs
parente159be9bbbf005785bd2d60af8b5c3df608f28b2 (diff)
parentb05cfd5577884d1a398dbb226e2082af5fe8f8fa (diff)
Merge pull request #1 from Simplesmente-O-Grupo/Matheus
Sistema de turnos
Diffstat (limited to 'scripts/Actor.cs')
-rw-r--r--scripts/Actor.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/Actor.cs b/scripts/Actor.cs
new file mode 100644
index 0000000..b360545
--- /dev/null
+++ b/scripts/Actor.cs
@@ -0,0 +1,35 @@
+using Godot;
+
+public abstract partial class Actor : Node2D {
+ static int baseWalkCost = 10;
+ [Export]
+ public TileMapLayer Map { get; set; }
+ [Signal]
+ public delegate void actionPerformedEventHandler();
+
+ [Export]
+ public int Energy { get; set; } = 0;
+ [Export]
+ public int Speed { get; protected set; } = 10;
+
+ protected void Walk(Vector2I offset) {
+ Vector2I toMovePos = Map.LocalToMap(Position);
+ toMovePos += offset;
+
+ TileData tile = Map.GetCellTileData(toMovePos);
+
+ if (tile.HasCustomData("isWalkable") && (bool) tile.GetCustomData("isWalkable")) {
+ GD.Print(toMovePos);
+ Position = Map.MapToLocal(toMovePos);
+ }
+
+ Energy -= baseWalkCost;
+ EndAction();
+ }
+
+ protected virtual void EndAction() {
+ EmitSignal(SignalName.actionPerformed);
+ }
+
+ public abstract void performAction();
+} \ No newline at end of file