52 lines
1.1 KiB
C#
52 lines
1.1 KiB
C#
using Godot;
|
|
|
|
public partial class BossOrb : RigidBody3D
|
|
{
|
|
[Export]
|
|
private HealthPoints _hp;
|
|
|
|
[Signal]
|
|
public delegate void OnBossOrbExplodedEventHandler();
|
|
|
|
[Export]
|
|
private PackedScene _attack;
|
|
|
|
[Export]
|
|
private AnimationPlayer _animationPlayer;
|
|
|
|
public bool CanAttack = false;
|
|
|
|
public void OnOrbHit(Node node)
|
|
{
|
|
if (node is Character character && character.HasMethod(Character.MethodName.OnHit))
|
|
{
|
|
GD.Print("Player hit: " + character.Name);
|
|
character.Call(Character.MethodName.OnHit, node);
|
|
}
|
|
else
|
|
{
|
|
_hp.TakeDamage(1);
|
|
if (_animationPlayer != null)
|
|
_animationPlayer.Play("OnHit");
|
|
GD.Print(_hp.CurrentHP);
|
|
if (_hp.CurrentHP <= 0)
|
|
{
|
|
EmitSignal(SignalName.OnBossOrbExploded);
|
|
QueueFree();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnFire()
|
|
{
|
|
var attack = _attack.Instantiate<Node3D>();
|
|
attack.GlobalPosition = GlobalPosition;
|
|
GetTree().Root.AddChild(attack);
|
|
}
|
|
|
|
public void DestroySelf()
|
|
{
|
|
QueueFree();
|
|
}
|
|
}
|