diff --git a/Tower Defence/Assets/Turrets/Choker/Choker.cs b/Tower Defence/Assets/Turrets/Choker/Choker.cs index 7f647113..41111e21 100644 --- a/Tower Defence/Assets/Turrets/Choker/Choker.cs +++ b/Tower Defence/Assets/Turrets/Choker/Choker.cs @@ -26,19 +26,14 @@ public class Choker : DynamicTurret /// Rotates towards the target if the turret have one. /// Shoots if the turret is looking towards the target /// - private void Update() + private new void Update() { - // If there's no fire rate, the turret shouldn't do anything - if (fireRate.GetStat() == 0) - { - return; - } + base.Update(); // Don't do anything if the turret doesn't have a target if (Target is null) { fireCountdown -= Time.deltaTime; - return; } // Rotates the turret each frame diff --git a/Tower Defence/Assets/Turrets/Gunner/Gunner.cs b/Tower Defence/Assets/Turrets/Gunner/Gunner.cs index 07deab61..8994b174 100644 --- a/Tower Defence/Assets/Turrets/Gunner/Gunner.cs +++ b/Tower Defence/Assets/Turrets/Gunner/Gunner.cs @@ -36,6 +36,11 @@ public class Gunner : DynamicTurret /// private void Update() { + if (fireCountdown > fireRate.GetStat()) + { + fireCountdown = 1 / fireRate.GetStat(); + } + // If there's no fire rate, the turret shouldn't do anything // However, it should rapidly cool down if (fireRate.GetStat() == 0) diff --git a/Tower Defence/Assets/Turrets/Lancer/Lancer.cs b/Tower Defence/Assets/Turrets/Lancer/Lancer.cs index 842154ac..afedddd9 100644 --- a/Tower Defence/Assets/Turrets/Lancer/Lancer.cs +++ b/Tower Defence/Assets/Turrets/Lancer/Lancer.cs @@ -88,11 +88,7 @@ private bool HasATarget() /// private void Update() { - // If there's no fire rate, the turret shouldn't do anything - if (fireRate.GetStat() == 0) - { - return; - } + base.Update(); // Don't do anything if no enemy is in range if (!HasATarget()) diff --git a/Tower Defence/Assets/Turrets/Shooter/Shooter.cs b/Tower Defence/Assets/Turrets/Shooter/Shooter.cs index 4b92fa52..d3cf420b 100644 --- a/Tower Defence/Assets/Turrets/Shooter/Shooter.cs +++ b/Tower Defence/Assets/Turrets/Shooter/Shooter.cs @@ -23,11 +23,7 @@ public class Shooter : DynamicTurret /// private void Update() { - // If there's no fire rate, the turret shouldn't do anything - if (fireRate.GetStat() == 0) - { - return; - } + base.Update(); // Don't do anything if the turret doesn't have a target if (Target is null) diff --git a/Tower Defence/Assets/Turrets/Smasher/Smasher.cs b/Tower Defence/Assets/Turrets/Smasher/Smasher.cs index a33cd308..3775a60f 100644 --- a/Tower Defence/Assets/Turrets/Smasher/Smasher.cs +++ b/Tower Defence/Assets/Turrets/Smasher/Smasher.cs @@ -19,11 +19,7 @@ public class Smasher : Turret /// private void Update() { - // If there's no fire rate, the turret shouldn't do anything - if (fireRate.GetStat() == 0) - { - return; - } + base.Update(); // Don't do anything if no enemy is in range Collider2D[] results = Physics2D.OverlapCircleAll(transform.position, range.GetStat()); diff --git a/Tower Defence/Assets/Turrets/Turret.cs b/Tower Defence/Assets/Turrets/Turret.cs index 1d377b07..6aab7990 100644 --- a/Tower Defence/Assets/Turrets/Turret.cs +++ b/Tower Defence/Assets/Turrets/Turret.cs @@ -24,6 +24,20 @@ private void Awake() { rangeDisplay.SetActive(false); } + + protected void Update() + { + // If there's no fire rate, the turret shouldn't do anything + if (fireRate.GetStat() == 0) + { + return; + } + + if (fireCountdown > fireRate.GetStat()) + { + fireCountdown = 1 / fireRate.GetStat(); + } + } /// /// Update the range shader's size