way too many changes to list, oops. big rewrite.
This commit is contained in:
33
Towers/Gatling/tower_gatling.gd
Normal file
33
Towers/Gatling/tower_gatling.gd
Normal file
@ -0,0 +1,33 @@
|
||||
class_name GatlingTower extends Tower
|
||||
|
||||
var time_since_firing_started: float = 0.0
|
||||
var time_to_reach_max_speed: float = 0.0
|
||||
var max_speed_multiplier: float = 0.0
|
||||
var current_time_between_shots: float = 0.0
|
||||
var final_time_between_shots: float = 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
time_to_reach_max_speed = stats.get_attribute("Speed Time")
|
||||
max_speed_multiplier = stats.get_attribute("Speed Multiplier")
|
||||
final_time_between_shots = time_between_shots / max_speed_multiplier
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if time_since_firing < current_time_between_shots:
|
||||
time_since_firing += delta
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if !target_finder.targets.size() > 0:
|
||||
time_since_firing_started = 0.0
|
||||
current_time_between_shots = time_between_shots
|
||||
else:
|
||||
aim()
|
||||
time_since_firing_started += delta
|
||||
var progress: float = clamp(time_since_firing_started / time_to_reach_max_speed, 0, 1.0)
|
||||
current_time_between_shots = lerpf(time_between_shots, final_time_between_shots, progress)
|
||||
if time_since_firing >= current_time_between_shots:
|
||||
time_since_firing -= current_time_between_shots
|
||||
shoot()
|
Reference in New Issue
Block a user