summaryrefslogtreecommitdiff
path: root/scripts/actors/Actor.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-08-26 22:59:57 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-08-26 22:59:57 -0300
commit6c7e2ac133986efa57b43df52a5498c6f7efcf75 (patch)
tree8404bfd3415a8dfcf7073191cbfdf58cc7c905ed /scripts/actors/Actor.cs
parenta3103718796a472da76838bf6fd72ba5d8409d79 (diff)
AI
Diffstat (limited to 'scripts/actors/Actor.cs')
-rw-r--r--scripts/actors/Actor.cs60
1 files changed, 50 insertions, 10 deletions
diff --git a/scripts/actors/Actor.cs b/scripts/actors/Actor.cs
index e8d728a..199c301 100644
--- a/scripts/actors/Actor.cs
+++ b/scripts/actors/Actor.cs
@@ -3,18 +3,10 @@ using Godot;
[GlobalClass]
public abstract partial class Actor : Sprite2D
{
- private ActorDefinition definition;
- private Vector2I gridPosition = Vector2I.Zero;
+ protected ActorDefinition definition;
public MapData Map_Data { get; set; }
- public Actor(Vector2I initialPosition, MapData map, ActorDefinition definition) {
- GridPosition = initialPosition;
- Map_Data = map;
- this.definition = definition;
- Texture = definition.texture;
- Centered = false;
- }
-
+ private Vector2I gridPosition = Vector2I.Zero;
public Vector2I GridPosition {
set {
gridPosition = value;
@@ -31,6 +23,30 @@ public abstract partial class Actor : Sprite2D
get => definition.name;
}
+ private int hp;
+ public int MaxHp { get; private set; }
+ public int Hp {
+ get => hp;
+ set {
+ hp = int.Clamp(value, 0, MaxHp);
+ }
+ }
+
+ private int mp;
+ public int MaxMp { get; private set; }
+ public int Mp {
+ get => mp;
+ set {
+ mp = int.Clamp(value, 0, MaxMp);
+ }
+ }
+
+ public int Atk { get; private set; }
+
+ public int Def { get; private set; }
+
+ public int Men { get; private set; }
+
public override void _Ready()
{
base._Ready();
@@ -38,6 +54,30 @@ public abstract partial class Actor : Sprite2D
}
public void Walk(Vector2I offset) {
+ Map_Data.UnregisterBlockingActor(this);
GridPosition += offset;
+ Map_Data.RegisterBlockingActor(this);
+ }
+
+ public Actor(Vector2I initialPosition, MapData map, ActorDefinition definition) {
+ GridPosition = initialPosition;
+ Map_Data = map;
+ Centered = false;
+
+ SetDefinition(definition);
+ }
+
+ public virtual void SetDefinition(ActorDefinition definition) {
+ this.definition = definition;
+ Texture = definition.texture;
+
+ MaxHp = definition.Hp;
+ Hp = definition.Hp;
+ MaxMp = definition.Mp;
+ Mp = definition.Mp;
+
+ Atk = definition.Atk;
+ Def = definition.Def;
+ Men = definition.Men;
}
} \ No newline at end of file