Update stuff
This commit is contained in:
@@ -1,31 +1,25 @@
|
||||
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 AudioStream _soundEffect;
|
||||
|
||||
[Export]
|
||||
public AudioStream _onHitSfx;
|
||||
|
||||
[Export]
|
||||
public RigidBody3D _hitBox;
|
||||
|
||||
[Export]
|
||||
public bool HasRotation = false;
|
||||
|
||||
public override void _Ready()
|
||||
private bool isDeleted = false;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Speed = _projectileSpeed;
|
||||
var sfxPlayer = GetTree().Root.GetNode<AudioStreamPlayer>("Main/SFXPlayer");
|
||||
sfxPlayer.Stream = _soundEffect;
|
||||
sfxPlayer.Play();
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
@@ -33,25 +27,23 @@ public partial class Projectile : Node3D
|
||||
var pathFollow = GetNode<PathFollow3D>("PathFollow3D");
|
||||
pathFollow.Progress += Speed * (float)delta;
|
||||
if (pathFollow.ProgressRatio > 0.98f)
|
||||
QueueFree();
|
||||
Delete();
|
||||
}
|
||||
|
||||
public void OnProjectileHit(Node node)
|
||||
{
|
||||
SetProcess(false);
|
||||
if (node is BasicEnemy basicEnemy && basicEnemy.HasMethod(BasicEnemy.MethodName.OnEnemyHit))
|
||||
{
|
||||
if (node is BasicEnemy basicEnemy)
|
||||
basicEnemy.Call(BasicEnemy.MethodName.OnEnemyHit, node);
|
||||
GD.Print("Hit enemy at " + basicEnemy.Position);
|
||||
Delete();
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
if (!isDeleted)
|
||||
{
|
||||
isDeleted = true;
|
||||
QueueFree();
|
||||
}
|
||||
else
|
||||
GD.Print("Hit something other than enemy: " + node.Name);
|
||||
|
||||
_hitBox.QueueFree();
|
||||
|
||||
var sfxPlayer = GetTree().Root.GetNode<AudioStreamPlayer>("Main/SFXPlayer");
|
||||
if (!sfxPlayer.Playing)
|
||||
sfxPlayer.Play();
|
||||
}
|
||||
|
||||
public float Speed { get; private set; }
|
||||
|
||||
Reference in New Issue
Block a user