Files
GameJam2023/Enemies/Scripts/GodCircuit.cs
2023-09-11 00:43:22 -07:00

28 lines
729 B
C#

using Godot;
public partial class GodCircuit : Node3D
{
[Export]
private AnimationPlayer _animationPlayer;
[Signal]
public delegate void OnEnemyBossHitEventHandler(long damage);
private void OnHit(Node3D node)
{
if (node is Character character && character.HasMethod(Character.MethodName.OnHit))
{
GD.Print("Player hit: " + character.Name);
character.Call(Character.MethodName.OnHit, node);
}
else
{
GD.Print("Hit");
_animationPlayer.Play("OnHit");
var hpComponent = GetNode<HealthPoints>("HP Component");
hpComponent.TakeDamage(800000);
EmitSignal(SignalName.OnEnemyBossHit, hpComponent.CurrentHP);
}
}
}