Adding win behaviour

This commit is contained in:
Zacharie Guet 2024-09-01 20:52:06 +02:00
parent d0e17011c1
commit 7b2aa34ac0
3 changed files with 14 additions and 1 deletions

View File

@ -24,3 +24,7 @@ func _on_planter_seed_list_updated() -> void:
func _on_camera_2d_mouse_motion(mouse_position):
seed_card.update_mouse_position(mouse_position)
func _on_map_win_game():
$Tuto.win()

View File

@ -4,6 +4,8 @@ extends Node2D
const OUT_OF_BOUND_DIST = 2000
signal win_game
@export var n_animals_to_liberate := 4
func _ready():
@ -36,4 +38,4 @@ func _on_gui_scanner_selected(type : Scanners.Type):
func _on_animal_liberated() -> void:
n_animals_to_liberate -= 1
if n_animals_to_liberate == 0:
print("YOU WIN")
emit_signal("win_game")

View File

@ -14,6 +14,8 @@ var texts = [
"Let's help those animals!",
]
var win_text = "Thank you ! I think all the animals are out now... But I'd be happy to continue to plant with you !"
var cursor = 0
func _ready():
@ -24,6 +26,11 @@ func _input(event):
if event.is_action_pressed("plant"):
next_text()
func win():
show()
$RobotSpeak.playing = true
$MarginContainer/Text.text = win_text
func next_text():
if cursor >= len(texts):
hide()