blank weapon fire system
This commit is contained in:
parent
8aa37bd929
commit
16b1d0f701
11 changed files with 92 additions and 51 deletions
|
@ -14,15 +14,15 @@ var cooldown : bool = false
|
|||
## Reference to cooldown scene timer
|
||||
var cooldown_timer : SceneTreeTimer = null
|
||||
|
||||
func _on_fire_begin(_tree : SceneTree) -> void:
|
||||
func _on_fire_begin() -> void:
|
||||
cooldown = false
|
||||
check_unfinished_timer(cooldown_timer,on_cooldown_timeout)
|
||||
|
||||
func _process(tree : SceneTree) -> void:
|
||||
func _process() -> void:
|
||||
if can_fire() :
|
||||
return
|
||||
if _fire():
|
||||
on_fire(tree)
|
||||
on_fire()
|
||||
|
||||
|
||||
## Invoked when cooldown has ended
|
||||
|
@ -42,7 +42,7 @@ func can_fire() -> bool:
|
|||
return cooldown
|
||||
|
||||
## Invoked when fired
|
||||
func on_fire(tree : SceneTree) -> void:
|
||||
func on_fire() -> void:
|
||||
cooldown = true
|
||||
cooldown_timer = tree.create_timer(fire_delay)
|
||||
cooldown_timer.timeout.connect(on_cooldown_timeout)
|
||||
|
|
|
@ -5,7 +5,7 @@ class_name BaseFireMode
|
|||
|
||||
## Assigned barrel to shoot out of
|
||||
var barrel : Barrel
|
||||
var tree : Tree
|
||||
var tree : SceneTree
|
||||
|
||||
func _init() -> void:
|
||||
resource_local_to_scene = true
|
||||
|
@ -14,6 +14,7 @@ func _init() -> void:
|
|||
## Returns [color=green]true[/color] if barrel can shoot,[br]
|
||||
## Returns [color=red]false[/color] if barrel cannot shoot
|
||||
func _fire() -> bool:
|
||||
barrel.fire()
|
||||
return true
|
||||
|
||||
|
||||
|
|
|
@ -20,15 +20,15 @@ var reloading : bool = false
|
|||
## Reference to reload scene timer
|
||||
var reload_timer : SceneTreeTimer = null
|
||||
|
||||
func _on_fire_begin(_tree : SceneTree) -> void:
|
||||
super._on_fire_begin(_tree)
|
||||
func _on_fire_begin() -> void:
|
||||
super._on_fire_begin()
|
||||
current_amount = 0
|
||||
reloading = false
|
||||
check_unfinished_timer(reload_timer,on_reload_timeout)
|
||||
|
||||
|
||||
func on_fire(tree : SceneTree) -> void:
|
||||
super.on_fire(tree)
|
||||
func on_fire() -> void:
|
||||
super.on_fire()
|
||||
current_amount += 1
|
||||
if current_amount >= burst_amount:
|
||||
reloading = true
|
||||
|
|
|
@ -13,7 +13,7 @@ class_name SingleFireMode
|
|||
var cooldown : bool = false
|
||||
|
||||
|
||||
func _on_fire_begin(tree) -> void:
|
||||
func _on_fire_begin() -> void:
|
||||
if cooldown:
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue