35 lines
670 B
C#
35 lines
670 B
C#
using Godot;
|
|
|
|
public partial class PyramidAttack : Node3D
|
|
{
|
|
[Export]
|
|
private AnimationPlayer _animationPlayer;
|
|
|
|
private bool isDeleted = false;
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
_animationPlayer.AnimationFinished += Delete;
|
|
}
|
|
public void OnPlayerHit(Node node)
|
|
{
|
|
SetPhysicsProcess(false);
|
|
|
|
if (node is Character character && character.HasMethod(Character.MethodName.OnHit))
|
|
{
|
|
GD.Print("Player hit: " + character.Name);
|
|
character.Call(Character.MethodName.OnHit, this);
|
|
}
|
|
|
|
QueueFree();
|
|
isDeleted = true;
|
|
}
|
|
|
|
public void Delete(StringName name)
|
|
{
|
|
if (!isDeleted)
|
|
QueueFree();
|
|
isDeleted = true;
|
|
}
|
|
}
|