|
@@ -13,6 +13,7 @@ const BULLET_SPEED = 200.0
|
|
|
var _ballScene = preload("res://scenes/Ball.tscn")
|
|
|
|
|
|
var nbAmmo = 5
|
|
|
+var nbStorage = 0
|
|
|
|
|
|
onready var target = $Target
|
|
|
onready var source = $Source
|
|
@@ -39,6 +40,11 @@ func shoot():
|
|
|
bullet.linear_velocity = (target.position - source.position).normalized()
|
|
|
bullet.linear_velocity *= BULLET_SPEED
|
|
|
add_child(bullet)
|
|
|
+ bullet.connect("tree_exited", self, "_on_Ball_tree_exited")
|
|
|
+
|
|
|
+
|
|
|
+func loadBullet(n:int):
|
|
|
+ nbStorage += 1
|
|
|
|
|
|
|
|
|
func _on_ShootDelay_timeout():
|
|
@@ -52,3 +58,13 @@ func _on_ShootDelay_timeout():
|
|
|
|
|
|
func _on_Launcher_get_firing():
|
|
|
shootDelay.start()
|
|
|
+
|
|
|
+
|
|
|
+func _on_Ball_tree_exited():
|
|
|
+ loadBullet(1)
|
|
|
+ print(get_tree().get_nodes_in_group("ball").size())
|
|
|
+ if (get_tree().get_nodes_in_group("ball").size() == 0):
|
|
|
+ current_state = State.READY
|
|
|
+ target.position = source.position
|
|
|
+ nbAmmo = nbStorage
|
|
|
+ nbStorage = 0
|