Basic ending
This commit is contained in:
@@ -4,10 +4,18 @@ public partial class GodCircuit : Node3D
|
||||
{
|
||||
[Export]
|
||||
private AnimationPlayer _animationPlayer;
|
||||
[Export]
|
||||
private Timer _attackTimer;
|
||||
|
||||
[Signal]
|
||||
public delegate void OnEnemyBossHitEventHandler(long damage);
|
||||
|
||||
[Signal]
|
||||
public delegate void OnGameEndingEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void DestroyRemainingOrbsEventHandler();
|
||||
|
||||
private void OnHit(Node3D node)
|
||||
{
|
||||
if (node is Character character && character.HasMethod(Character.MethodName.OnHit))
|
||||
@@ -17,14 +25,22 @@ public partial class GodCircuit : Node3D
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Hit");
|
||||
_animationPlayer.Play("OnHit");
|
||||
var hpComponent = GetNode<HealthPoints>("HP Component");
|
||||
hpComponent.TakeDamage(800000);
|
||||
EmitSignal(SignalName.OnEnemyBossHit, hpComponent.CurrentHP);
|
||||
if (hpComponent.CurrentHP > 0)
|
||||
{
|
||||
GD.Print("Hit");
|
||||
_animationPlayer.Play("OnHit");
|
||||
hpComponent.TakeDamage(800000);
|
||||
EmitSignal(SignalName.OnEnemyBossHit, hpComponent.CurrentHP);
|
||||
|
||||
if (hpComponent.CurrentHP <= 0)
|
||||
QueueFree();
|
||||
if (hpComponent.CurrentHP <= 0)
|
||||
{
|
||||
_attackTimer.Stop();
|
||||
EmitSignal(SignalName.DestroyRemainingOrbs);
|
||||
_animationPlayer.Play("OnDeath");
|
||||
_animationPlayer.AnimationFinished += OnGameFinished;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +54,10 @@ public partial class GodCircuit : Node3D
|
||||
if (hpComponent.CurrentHP <= 0)
|
||||
hpComponent.CurrentHP = 1;
|
||||
}
|
||||
|
||||
private void OnGameFinished(StringName animationName)
|
||||
{
|
||||
QueueFree();
|
||||
EmitSignal(SignalName.OnGameEnding);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user