Adding win behaviour
This commit is contained in:
parent
d0e17011c1
commit
7b2aa34ac0
@ -24,3 +24,7 @@ func _on_planter_seed_list_updated() -> void:
|
|||||||
|
|
||||||
func _on_camera_2d_mouse_motion(mouse_position):
|
func _on_camera_2d_mouse_motion(mouse_position):
|
||||||
seed_card.update_mouse_position(mouse_position)
|
seed_card.update_mouse_position(mouse_position)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_map_win_game():
|
||||||
|
$Tuto.win()
|
||||||
|
|||||||
@ -4,6 +4,8 @@ extends Node2D
|
|||||||
|
|
||||||
const OUT_OF_BOUND_DIST = 2000
|
const OUT_OF_BOUND_DIST = 2000
|
||||||
|
|
||||||
|
signal win_game
|
||||||
|
|
||||||
@export var n_animals_to_liberate := 4
|
@export var n_animals_to_liberate := 4
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
@ -36,4 +38,4 @@ func _on_gui_scanner_selected(type : Scanners.Type):
|
|||||||
func _on_animal_liberated() -> void:
|
func _on_animal_liberated() -> void:
|
||||||
n_animals_to_liberate -= 1
|
n_animals_to_liberate -= 1
|
||||||
if n_animals_to_liberate == 0:
|
if n_animals_to_liberate == 0:
|
||||||
print("YOU WIN")
|
emit_signal("win_game")
|
||||||
|
|||||||
@ -14,6 +14,8 @@ var texts = [
|
|||||||
"Let's help those animals!",
|
"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
|
var cursor = 0
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
@ -24,6 +26,11 @@ func _input(event):
|
|||||||
if event.is_action_pressed("plant"):
|
if event.is_action_pressed("plant"):
|
||||||
next_text()
|
next_text()
|
||||||
|
|
||||||
|
func win():
|
||||||
|
show()
|
||||||
|
$RobotSpeak.playing = true
|
||||||
|
$MarginContainer/Text.text = win_text
|
||||||
|
|
||||||
func next_text():
|
func next_text():
|
||||||
if cursor >= len(texts):
|
if cursor >= len(texts):
|
||||||
hide()
|
hide()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user