From c99ad360f99fbf919aea2772ee2886cb622ce285 Mon Sep 17 00:00:00 2001 From: Turner Bass Date: Mon, 1 May 2023 11:37:55 -0500 Subject: [PATCH] add win state detection --- Sick_Day_Delivery/Scenes/global_state.tscn | 2 ++ Sick_Day_Delivery/Scripts/global_state.gd | 12 ++++++++++++ Sick_Day_Delivery/Scripts/infection_spawner.gd | 4 ++-- Sick_Day_Delivery/project.godot | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Sick_Day_Delivery/Scenes/global_state.tscn b/Sick_Day_Delivery/Scenes/global_state.tscn index 84c9c6f..1df8a12 100644 --- a/Sick_Day_Delivery/Scenes/global_state.tscn +++ b/Sick_Day_Delivery/Scenes/global_state.tscn @@ -4,4 +4,6 @@ [node name="Global State" type="Node"] script = ExtResource("1_beo4s") +enemies_destroyed = 100 +colonies_destroyed = 100 enemies_max = 100 diff --git a/Sick_Day_Delivery/Scripts/global_state.gd b/Sick_Day_Delivery/Scripts/global_state.gd index 162b5ae..afbc2f5 100644 --- a/Sick_Day_Delivery/Scripts/global_state.gd +++ b/Sick_Day_Delivery/Scripts/global_state.gd @@ -5,6 +5,7 @@ signal on_colony_count_updated (total) signal on_enemies_destroyed (total) signal on_colonies_destroyed (total) signal on_game_over +signal on_game_won @export var enemies_destroyed := 0 @export var colonies_destroyed := 0 @@ -18,6 +19,7 @@ func report_enemy_destroyed(): total_enemies -= 1 emit_signal("on_enemies_count_updated", total_enemies) emit_signal("on_enemies_destroyed", enemies_destroyed) + try_win_game() func report_enemy_created(): total_enemies += 1 @@ -35,6 +37,16 @@ func report_colony_destroyed(): total_colonies -= 1 emit_signal("on_colonies_destroyed", colonies_destroyed) emit_signal("on_colony_count_updated", total_colonies) + try_win_game() + +func try_win_game(): + if(total_enemies == 0 && + total_colonies == 0 && + enemies_destroyed > 0 && + colonies_destroyed > 0): + print("🫡🏆🎆 YOU WON! YOU WINNINGING WINNER YOU! 🫡🏆🎆") + emit_signal("on_game_won") + func reset_state(): enemies_destroyed = 0 diff --git a/Sick_Day_Delivery/Scripts/infection_spawner.gd b/Sick_Day_Delivery/Scripts/infection_spawner.gd index 307ad73..07765ed 100644 --- a/Sick_Day_Delivery/Scripts/infection_spawner.gd +++ b/Sick_Day_Delivery/Scripts/infection_spawner.gd @@ -29,5 +29,5 @@ func createColony(): spawns.shuffle() print_debug(spawns[0].name + ": " + str(spawns[0].position)) colony.process_priority = 1 - colony.position = spawns[0].position - $Colonies.add_child(colony) + colony.position = spawns[0].position + $Colonies.add_child(colony) diff --git a/Sick_Day_Delivery/project.godot b/Sick_Day_Delivery/project.godot index 48f0515..1b2341d 100644 --- a/Sick_Day_Delivery/project.godot +++ b/Sick_Day_Delivery/project.godot @@ -16,7 +16,7 @@ config/features=PackedStringArray("4.0", "GL Compatibility") boot_splash/bg_color=Color(0.0156863, 0.164706, 0.172549, 1) boot_splash/image="res://Sprites/Pill_PlaceholderOpen.png" boot_splash/fullsize=false -config/icon="res://icon.svg" +config/icon="res://Sprites/Pill_PlaceholderOpen.png" [audio]