FINAL JAM COMMIT
This commit is contained in:
@@ -13,9 +13,20 @@ public partial class Turret : Node
|
||||
[Export] private ProjectilePool _projectilePool;
|
||||
[Export] private AudioStreamPlayer2D _audio;
|
||||
private float _fireTimer = 0f;
|
||||
|
||||
|
||||
public int Level { get; private set; } = 1;
|
||||
public int UpgradeCost => 31 + (int)(31 * Math.Pow(Level, 1.75f));
|
||||
|
||||
public float FireRate => _fireRate + (Level - 1) * 0.05f;
|
||||
public float Damage => 25 + (int)(10 + Math.Pow(Level, 1.5f));
|
||||
|
||||
private HashSet<Enemy> _enemiesInRange = new HashSet<Enemy>();
|
||||
|
||||
public void Upgrade()
|
||||
{
|
||||
Level++;
|
||||
}
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
_Attackrange.AreaEntered += EnemyEntered;
|
||||
@@ -42,7 +53,7 @@ public partial class Turret : Node
|
||||
{
|
||||
if (_enemiesInRange.Count == 0) return;
|
||||
_fireTimer += (float)delta;
|
||||
if (!(_fireTimer >= 1f / _fireRate)) return;
|
||||
if (!(_fireTimer >= 1f / FireRate)) return;
|
||||
_fireTimer = 0;
|
||||
_audio?.SetPitchScale(RandomHelper.Float(0.8f, 1.2f));
|
||||
_audio?.Play();
|
||||
@@ -50,6 +61,7 @@ public partial class Turret : Node
|
||||
var dir = (t.GlobalPosition - _parent.GlobalPosition).Normalized();
|
||||
var proj = _projectilePool.Get();
|
||||
proj.Direction = dir;
|
||||
proj.Damage = Damage;
|
||||
proj.GlobalPosition = _parent.GlobalPosition;
|
||||
proj.Rotation = dir.Angle();
|
||||
ProjectileParent.Instance.AddChild(proj);
|
||||
|
||||
Reference in New Issue
Block a user