Zombie flash

This commit is contained in:
Фёдор Веселов 2024-09-25 15:47:51 +05:00
commit eb2159811e
4 changed files with 73 additions and 2 deletions

View file

@ -3,6 +3,9 @@ using System;
public partial class RuntimeZombieData : Node2D, IEntity
{
[Signal]
public delegate void OnHPChangedEventHandler(int deltaHP);
private int _hp;
[Export]
private int _maxHP;
@ -22,6 +25,7 @@ public partial class RuntimeZombieData : Node2D, IEntity
public void Heal(int amount)
{
_hp += amount;
EmitSignal(SignalName.OnHPChanged,amount);
if (MaxHp > 0)
{
@ -32,10 +36,12 @@ public partial class RuntimeZombieData : Node2D, IEntity
public void TakeDamage(int amount)
{
_hp -= amount;
EmitSignal(SignalName.OnHPChanged,-amount);
if (_hp <= 0)
{
QueueFree();
}
}
}