This commit is contained in:
Marco 2025-02-13 11:15:06 +01:00
commit 4be64cf7ec
12 changed files with 220 additions and 33 deletions

View file

@ -51,6 +51,13 @@ public partial class Enemy : CharacterBody2D
set => _navigationEnabled = value;
}
#region Events
[Signal]
public delegate void HealthChangedEventHandler(float newValue);
#endregion
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
@ -220,6 +227,7 @@ public partial class Enemy : CharacterBody2D
if (_isDestroyed) return;
_currentHealth -= damage;
EmitSignal(nameof(HealthChanged), _currentHealth);
if (!(_currentHealth <= 0)) return;
_isDestroyed = true;
Explode();