First builds and stuff done yipewaho
This commit is contained in:
@@ -5,14 +5,21 @@ public partial class Enemy : PathFollow2D
|
||||
{
|
||||
[Export] public EnemyType Type;
|
||||
[Export] public Health Health;
|
||||
[Export] private AudioStreamPlayer2D _audio;
|
||||
|
||||
public event Action<Enemy> Died;
|
||||
public event Action<Enemy> ReachedShrine;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Health.Death += _ => Died?.Invoke(this);
|
||||
Health.Damaged += () =>
|
||||
{
|
||||
_audio?.SetPitchScale(RandomHelper.Float(0.8f, 1.2f));
|
||||
_audio?.Play();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void ResetEnemy()
|
||||
{
|
||||
GlobalPosition = Vector2.Zero;
|
||||
@@ -23,4 +30,9 @@ public partial class Enemy : PathFollow2D
|
||||
Health.Reset();
|
||||
// reset velocity, animation, AI, etc here
|
||||
}
|
||||
|
||||
public void Despawn()
|
||||
{
|
||||
ReachedShrine?.Invoke(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user