Added action per round

This commit is contained in:
cblech
2025-07-10 18:29:18 +02:00
parent 0e028a2cb9
commit 4752002caf
3 changed files with 96 additions and 20 deletions
+19 -2
View File
@@ -6,6 +6,7 @@ public partial class Fighter : Node2D
[Export] public string name;
[Export] public int maxHealth;
[Export] public int attackStrength;
[Export] public int maxActions = 1;
[ExportCategory("References")]
[Export] private Node2D _attackButtons;
@@ -20,6 +21,7 @@ public partial class Fighter : Node2D
private int _health;
private int _actions;
public FightInstance fightInstance;
@@ -47,6 +49,7 @@ public partial class Fighter : Node2D
{
Health = maxHealth;
UpdateHealthVisual();
ResetActions();
}
public void Attack()
@@ -119,7 +122,7 @@ public partial class Fighter : Node2D
tween.TweenCallback(Callable.From(() => attack.target?.HitAnimation(attack)));
tween.TweenProperty(this, "position", new Vector2(0, 0), 0.7)
.SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
}
private void HitAnimation(FightAttack attack)
@@ -127,7 +130,7 @@ public partial class Fighter : Node2D
EmitSignalDamageTaken();
var tween = GetTree().CreateTween();
tween.TweenProperty(this, "scale", new Vector2(1.4f, 0.6f), 0.15);
tween.TweenProperty(this, "scale", new Vector2(1,1), 0.4)
tween.TweenProperty(this, "scale", new Vector2(1, 1), 0.4)
.SetTrans(Tween.TransitionType.Cubic).SetEase(Tween.EaseType.Out);
}
@@ -135,4 +138,18 @@ public partial class Fighter : Node2D
{
return Health <= 0;
}
public void ResetActions()
{
_actions = maxActions;
}
public bool HasActionsLeft()
{
return _actions > 0;
}
public void DecrementActions()
{
_actions--;
}
}