blob: 172ffe41996f34e16b5d57ca8723bc1659fdf7b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
using Godot;
using System;
public partial class Character : Actor {
private bool canAct = false;
public override void _Input(InputEvent @event)
{
base._Input(@event);
if (!@event.IsPressed()) return;
if (canAct) {
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 (@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;
}
}
|