51 lines
992 B
C#
51 lines
992 B
C#
using Godot;
|
|
using System;
|
|
|
|
public partial class Projectile : Node3D
|
|
{
|
|
[Export]
|
|
public double Cooldown { get; protected set; }
|
|
|
|
[Export]
|
|
private AudioStream _soundEffect;
|
|
|
|
[Export]
|
|
protected float _projectileSpeed = 1f;
|
|
|
|
[Export]
|
|
public bool HasRotation = false;
|
|
|
|
private bool isDeleted = false;
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
Speed = _projectileSpeed;
|
|
}
|
|
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
var pathFollow = GetNode<PathFollow3D>("PathFollow3D");
|
|
pathFollow.Progress += Speed * (float)delta;
|
|
if (pathFollow.ProgressRatio > 0.98f)
|
|
Delete();
|
|
}
|
|
|
|
public void OnProjectileHit(Node node)
|
|
{
|
|
if (node is BasicEnemy basicEnemy)
|
|
basicEnemy.Call(BasicEnemy.MethodName.OnEnemyHit, node);
|
|
Delete();
|
|
}
|
|
|
|
public void Delete()
|
|
{
|
|
if (!isDeleted)
|
|
{
|
|
isDeleted = true;
|
|
QueueFree();
|
|
}
|
|
}
|
|
|
|
public float Speed { get; private set; }
|
|
}
|