]> Untitled Git - mushroom-game.git/blobdiff - world.gd
Squashed commit of the following:
[mushroom-game.git] / world.gd
index 07e281ddcb72e8d47bcd463e90d5dfb1fa673e93..91b1bc68515c687c14b011e3357504c144c8edfb 100644 (file)
--- a/world.gd
+++ b/world.gd
@@ -1,12 +1,7 @@
 extends Node3D
 
 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.
 
 
 # Called when the node enters the scene tree for the first time.
@@ -19,6 +14,28 @@ func _process(_delta: float) -> void:
        pass
 
 
        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:
 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()