diff --git a/Nodes/cannon.tscn b/Nodes/cannon.tscn index 6782155..1771df1 100644 --- a/Nodes/cannon.tscn +++ b/Nodes/cannon.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=2 format=3 uid="uid://kupfq75m0v37"] +[gd_scene load_steps=2 format=3 uid="uid://byo1m0n20yl45"] [ext_resource type="Script" path="res://scripts/Modules/Cannon.gd" id="1_vdn0s"] diff --git a/Nodes/game.tscn b/Nodes/game.tscn index 8bf6463..5fdcbeb 100644 --- a/Nodes/game.tscn +++ b/Nodes/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=5 format=3 uid="uid://bl1yrgr7g06db"] +[gd_scene load_steps=5 format=3 uid="uid://n7w0ff7u25yc"] [ext_resource type="Script" path="res://scripts/Logic/Game.gd" id="1_iox18"] diff --git a/scripts/Logic/Game.gd b/scripts/Logic/Game.gd index 95d1e7d..76cdbfe 100644 --- a/scripts/Logic/Game.gd +++ b/scripts/Logic/Game.gd @@ -5,7 +5,6 @@ signal ammo_pickup signal shoot var t = 0.0 -var CAN_ENGAGE = true @onready var tween = create_tween() as Tween @@ -33,10 +32,8 @@ func _process(delta): speed_p1 = 5 start_tween() - if round(p1.position.distance_to(p2.position)) == 9 && CAN_ENGAGE: - CAN_ENGAGE = false + if round(p1.position.distance_to(p2.position)) == 9: emit_signal("shoot") - create_tween().tween_callback(func(): CAN_ENGAGE = true).set_delay(2) diff --git a/scripts/Modules/Cannon.gd b/scripts/Modules/Cannon.gd index 0cdf903..83e5b63 100644 --- a/scripts/Modules/Cannon.gd +++ b/scripts/Modules/Cannon.gd @@ -4,6 +4,8 @@ class_name Cannon enum STATE {INACTIVE, RELOADING, SHOOTING} +var CAN_ENGAGE = true + #------------Methods-------------# func _ready(): var root = get_tree().root.get_child(0) @@ -23,10 +25,14 @@ func interact(): return func _on_signal_shooting(): - print("hit") + if not CAN_ENGAGE: + return + CAN_ENGAGE = false + create_tween().tween_callback(func(): CAN_ENGAGE = true).set_delay(2) + if currentStashValue >= 1 and currentState == STATE.INACTIVE: currentState = STATE.SHOOTING currentStashValue -= 1 - #TODO: SHOOTING + print("hit") currentState = STATE.INACTIVE return