Player can die now

This commit is contained in:
MaddoScientisto 2024-08-18 17:38:32 +02:00
commit 360b4dfe6a
6 changed files with 87 additions and 24 deletions

View file

@ -15,6 +15,8 @@ public partial class Enemy : Area2D, IDestructible
[Export] public double RateOfFire = 0.4f;
[Export] public float BulletSpeed = 100f;
private float _currentHealth = 0f;
private bool _isDestroyed = false;
@ -71,6 +73,7 @@ public partial class Enemy : Area2D, IDestructible
// bullet.Transform = this.GlobalTransform;
// bullet.Position = this.Position;
bullet.SetDirection((_cachedPlayer.GlobalPosition - this.GlobalPosition).Normalized());
bullet.Speed = BulletSpeed;
_cooldownTimer.Start(RateOfFire);
}
}
@ -117,6 +120,14 @@ public partial class Enemy : Area2D, IDestructible
}
private void Explode()
{
Debug.WriteLine("Ded");
//CreateParticles();
//CreateDebris();
QueueFree();
}
public void Hit(float damage)
{
if (_isDestroyed) return;
@ -127,14 +138,6 @@ public partial class Enemy : Area2D, IDestructible
Explode();
}
private void Explode()
{
Debug.WriteLine("Ded");
//CreateParticles();
//CreateDebris();
QueueFree();
}
public bool IsDestroyed()
{
return _isDestroyed;