Added audio to fight
This commit is contained in:
@@ -14,6 +14,10 @@ public partial class Fighter : Node2D
|
||||
[Export] private Label _healthText;
|
||||
[Export] private Node2D _visualSprite;
|
||||
|
||||
[Signal] public delegate void DamageTakenEventHandler();
|
||||
[Signal] public delegate void AttackingEventHandler();
|
||||
[Signal] public delegate void DieingEventHandler();
|
||||
|
||||
|
||||
private int _health;
|
||||
|
||||
@@ -36,6 +40,7 @@ public partial class Fighter : Node2D
|
||||
private void Die()
|
||||
{
|
||||
_visualSprite.Scale = new Vector2(1, 0.3f);
|
||||
EmitSignalDieing();
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
@@ -108,6 +113,7 @@ public partial class Fighter : Node2D
|
||||
|
||||
public void AttackAnimation(FightAttack attack)
|
||||
{
|
||||
EmitSignalAttacking();
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.TweenProperty(this, "global_position", attack.target.GlobalPosition, 0.15);
|
||||
tween.TweenCallback(Callable.From(() => attack.target?.HitAnimation(attack)));
|
||||
@@ -118,6 +124,7 @@ public partial class Fighter : Node2D
|
||||
|
||||
private void HitAnimation(FightAttack attack)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://clcirtaf47g5p
|
||||
Reference in New Issue
Block a user