extends Node3D
-func quit_game() -> void:
- get_tree().quit()
-
-# Quit the game
-func _unhandled_input(event: InputEvent) -> void:
- if event.is_action_pressed("quit-game"):
- quit_game()
+signal victory
+signal quit
# Called when the node enters the scene tree for the first time.
pass
+# Quit the game on user action
+func _unhandled_input(event: InputEvent) -> void:
+ if event.is_action_pressed("quit-game"):
+ quit.emit()
+
+
+# if all mushrooms have been picked,
+# then game is over
func _on_mushroom_picked() -> void:
- print("Player picked all mushrooms!")
- #quit_game()
+ print("Player picked a mushroom!")
+
+ for mushroom in $mushrooms.get_children():
+ if mushroom.is_picked == false:
+ return
+
+ print("Player picked all mushrooms, game over")
+ victory.emit()
+
+
+func _on_victory() -> void:
+ get_tree().change_scene_to_file("res://victory-screen.tscn")
+
+
+func _on_quit() -> void:
+ get_tree().quit()