summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/InputHandler.cs10
-rw-r--r--scripts/actors/actions/BumpAction.cs24
-rw-r--r--scripts/actors/actions/BumpAction.cs.uid1
-rw-r--r--scripts/actors/actions/DirectionalAction.cs11
-rw-r--r--scripts/actors/actions/DirectionalAction.cs.uid1
-rw-r--r--scripts/actors/actions/MeleeAction.cs21
-rw-r--r--scripts/actors/actions/MeleeAction.cs.uid1
-rw-r--r--scripts/actors/actions/MovementAction.cs6
8 files changed, 66 insertions, 9 deletions
diff --git a/scripts/InputHandler.cs b/scripts/InputHandler.cs
index dae990a..5194841 100644
--- a/scripts/InputHandler.cs
+++ b/scripts/InputHandler.cs
@@ -6,15 +6,15 @@ public partial class InputHandler : Node {
Action action = null;
if (Input.IsActionJustPressed("walk-up")) {
- action = new MovementAction(Vector2I.Up);
+ action = new BumpAction(Vector2I.Up);
} else if (Input.IsActionJustPressed("walk-down")) {
- action = new MovementAction(Vector2I.Down);
+ action = new BumpAction(Vector2I.Down);
} else if (Input.IsActionJustPressed("walk-left")) {
- action = new MovementAction(Vector2I.Left);
+ action = new BumpAction(Vector2I.Left);
} else if (Input.IsActionJustPressed("walk-right")) {
- action = new MovementAction(Vector2I.Right);
+ action = new BumpAction(Vector2I.Right);
} else if (Input.IsActionJustPressed("skip-turn")) {
- action = new MovementAction(Vector2I.Zero);
+ action = new BumpAction(Vector2I.Zero);
}
return action;
diff --git a/scripts/actors/actions/BumpAction.cs b/scripts/actors/actions/BumpAction.cs
new file mode 100644
index 0000000..e1fb706
--- /dev/null
+++ b/scripts/actors/actions/BumpAction.cs
@@ -0,0 +1,24 @@
+using Godot;
+using System;
+
+public partial class BumpAction : DirectionalAction
+{
+ public BumpAction(Vector2I offset) : base(offset)
+ {
+ }
+
+ public override void Perform(Game game, Actor actor)
+ {
+ Vector2I destination = actor.GridPosition + Offset;
+
+ Action action;
+
+ if (game.Map.GetBlockingActorAtPosition(destination) != null) {
+ action = new MeleeAction(Offset);
+ } else {
+ action = new MovementAction(Offset);
+ }
+
+ action.Perform(game, actor);
+ }
+}
diff --git a/scripts/actors/actions/BumpAction.cs.uid b/scripts/actors/actions/BumpAction.cs.uid
new file mode 100644
index 0000000..f5ce3f8
--- /dev/null
+++ b/scripts/actors/actions/BumpAction.cs.uid
@@ -0,0 +1 @@
+uid://p6ij0dsuvv7y
diff --git a/scripts/actors/actions/DirectionalAction.cs b/scripts/actors/actions/DirectionalAction.cs
new file mode 100644
index 0000000..7512141
--- /dev/null
+++ b/scripts/actors/actions/DirectionalAction.cs
@@ -0,0 +1,11 @@
+using Godot;
+using System;
+
+public abstract partial class DirectionalAction : Action
+{
+ public Vector2I Offset { get; private set; }
+ public DirectionalAction(Vector2I offset)
+ {
+ Offset = offset;
+ }
+}
diff --git a/scripts/actors/actions/DirectionalAction.cs.uid b/scripts/actors/actions/DirectionalAction.cs.uid
new file mode 100644
index 0000000..901756a
--- /dev/null
+++ b/scripts/actors/actions/DirectionalAction.cs.uid
@@ -0,0 +1 @@
+uid://cxotc2adk05j8
diff --git a/scripts/actors/actions/MeleeAction.cs b/scripts/actors/actions/MeleeAction.cs
new file mode 100644
index 0000000..1a74c22
--- /dev/null
+++ b/scripts/actors/actions/MeleeAction.cs
@@ -0,0 +1,21 @@
+using Godot;
+using System;
+using System.Net.NetworkInformation;
+
+public partial class MeleeAction : DirectionalAction
+{
+ public MeleeAction(Vector2I offset) : base(offset)
+ {
+ }
+
+ public override void Perform(Game game, Actor actor)
+ {
+ Vector2I destination = actor.GridPosition + Offset;
+
+ Actor target = game.Map.GetBlockingActorAtPosition(destination);
+
+ if (target == null) return;
+
+ GD.Print($"Você tenta socar {target.ActorName}, mas como não sobra nada para o beta, você ainda não tem um método de ataque.");
+ }
+}
diff --git a/scripts/actors/actions/MeleeAction.cs.uid b/scripts/actors/actions/MeleeAction.cs.uid
new file mode 100644
index 0000000..bc97619
--- /dev/null
+++ b/scripts/actors/actions/MeleeAction.cs.uid
@@ -0,0 +1 @@
+uid://vbptt0gl1ud0
diff --git a/scripts/actors/actions/MovementAction.cs b/scripts/actors/actions/MovementAction.cs
index 6fa3491..3b203ca 100644
--- a/scripts/actors/actions/MovementAction.cs
+++ b/scripts/actors/actions/MovementAction.cs
@@ -1,12 +1,10 @@
using Godot;
using System;
-public partial class MovementAction : Action
+public partial class MovementAction : DirectionalAction
{
- public Vector2I Offset { get; private set; }
- public MovementAction(Vector2I offset)
+ public MovementAction(Vector2I offset) : base(offset)
{
- Offset = offset;
}
public override void Perform(Game game, Actor actor)