blob: 7e9ab0495f9505a4ea6acc8cd2d85d1494e93a7e (
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
|
using Godot;
[GlobalClass]
public abstract partial class Actor : Sprite2D
{
private ActorDefinition definition;
private Vector2I gridPosition = Vector2I.Zero;
public DungeonLevel Map { get; private set; }
public Actor(Vector2I initialPosition, DungeonLevel map, ActorDefinition definition) {
GridPosition = initialPosition;
Map = map;
this.definition = definition;
Texture = definition.texture;
Centered = false;
}
public Vector2I GridPosition {
set {
gridPosition = value;
Position = Grid.GridToWorld(value);
}
get => gridPosition;
}
public bool BlocksMovement {
get => definition.blocksMovement;
}
public string ActorName {
get => definition.name;
}
public override void _Ready()
{
base._Ready();
GridPosition = Grid.WorldToGrid(Position);
}
public void Walk(Vector2I offset) {
GridPosition += offset;
}
}
|