Parcourir la source

Prevent shooting when game is lost

DricomDragon il y a 3 ans
Parent
commit
ff50c545ce
2 fichiers modifiés avec 16 ajouts et 1 suppressions
  1. 1 0
      godot/scenes/main.tscn
  2. 15 1
      godot/scripts/Launcher.gd

+ 1 - 0
godot/scenes/main.tscn

@@ -214,4 +214,5 @@ __meta__ = {
 [connection signal="kace_broken" from="Launcher/Grid" to="Launcher" method="_on_Grid_kace_broken"]
 [connection signal="kace_damaged" from="Launcher/Grid" to="UI/ScorePanel/ScoreCounterLabel" method="_on_Grid_kace_damaged"]
 [connection signal="timeout" from="Launcher/ShootDelay" to="Launcher" method="_on_ShootDelay_timeout"]
+[connection signal="game_lost" from="Launcher/DeadLine" to="Launcher" method="_on_DeadLine_game_lost"]
 [connection signal="game_lost" from="Launcher/DeadLine" to="UI" method="_on_DeadLine_game_lost"]

+ 15 - 1
godot/scripts/Launcher.gd

@@ -10,6 +10,7 @@ enum State {
 	FIRING,
 	WAITING,
 	INTERRUPTING,
+	DEAD
 }
 
 export var BULLET_SPEED = 500.0
@@ -68,6 +69,11 @@ func load_bullet(n:int):
 	nbStorage += n
 
 
+func end_of_round():
+	if (current_state != State.DEAD):
+		get_ready()
+
+
 func get_ready():
 	current_state = State.READY
 	target.position = source.position
@@ -75,6 +81,10 @@ func get_ready():
 	nbStorage = 0
 
 
+func die():
+	current_state = State.DEAD
+
+
 func _on_ShootDelay_timeout():
 	shoot()
 	nbAmmo -= 1
@@ -95,8 +105,12 @@ func _on_Ball_tree_exited():
 
 
 func _on_Grid_has_moved():
-	get_ready()
+	end_of_round()
 
 
 func _on_Grid_kace_broken():
 	gain_new_bullet()
+
+
+func _on_DeadLine_game_lost():
+	die()