From 7b2aa34ac03055c5d84cce7942da051252adfd44 Mon Sep 17 00:00:00 2001 From: Zacharie Guet Date: Sun, 1 Sep 2024 20:52:06 +0200 Subject: [PATCH] Adding win behaviour --- scripts/gui.gd | 4 ++++ scripts/map.gd | 4 +++- scripts/tuto.gd | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/gui.gd b/scripts/gui.gd index dcd3669..222971f 100644 --- a/scripts/gui.gd +++ b/scripts/gui.gd @@ -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() diff --git a/scripts/map.gd b/scripts/map.gd index cb5329c..fd4de67 100644 --- a/scripts/map.gd +++ b/scripts/map.gd @@ -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") diff --git a/scripts/tuto.gd b/scripts/tuto.gd index 409fadd..2f9a74f 100644 --- a/scripts/tuto.gd +++ b/scripts/tuto.gd @@ -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()