diff options
Diffstat (limited to 'scripts/actors/Actor.cs')
| -rw-r--r-- | scripts/actors/Actor.cs | 60 |
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 |
