From 1f91e0aef75b6b0512014972d3e08494dba8988b Mon Sep 17 00:00:00 2001 From: Lexi Quinn Date: Tue, 10 Feb 2026 18:44:12 +1100 Subject: [PATCH] fixed shield UI not clearing on game restart --- Scripts/Resources/save_data.gd | 4 ++-- Scripts/game.gd | 2 ++ UI/ShieldUI/shield_ui.tscn | 17 +++++++++++++++++ shield_ui_test.gd | 4 ++++ shield_ui_test.tscn | 5 +++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Scripts/Resources/save_data.gd b/Scripts/Resources/save_data.gd index 1b03712..13315ca 100644 --- a/Scripts/Resources/save_data.gd +++ b/Scripts/Resources/save_data.gd @@ -28,9 +28,9 @@ var mage_unlocked: bool = 0 func check_high_score(level_title: String, wave_reached: int, endless: bool) -> void: - if endless: + if endless and endless_high_scores[level_title] < wave_reached: endless_high_scores[level_title] = wave_reached - else: + elif level_high_scores[level_title] < wave_reached: level_high_scores[level_title] = wave_reached diff --git a/Scripts/game.gd b/Scripts/game.gd index 2fefeb5..5a465f8 100644 --- a/Scripts/game.gd +++ b/Scripts/game.gd @@ -159,6 +159,8 @@ func spawn_players() -> void: base_took_damage.connect(player.hud.set_lives_count) root_scene.add_child(player) p_i += 1 + print("objective health: " + str(objective_health)) + print("player ui health: " + str(player.hud.shield_ui.health)) func ready_player(player_ready_true: bool) -> void: diff --git a/UI/ShieldUI/shield_ui.tscn b/UI/ShieldUI/shield_ui.tscn index b52e611..9dcff0f 100644 --- a/UI/ShieldUI/shield_ui.tscn +++ b/UI/ShieldUI/shield_ui.tscn @@ -6,70 +6,87 @@ [ext_resource type="Texture2D" uid="uid://bifqfvhsu4c2f" path="res://UI/ShieldUI/health_hit-Sheet.png" id="4_yanml"] [sub_resource type="AtlasTexture" id="AtlasTexture_5gv4u"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 0, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_ye2cs"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 66, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_gmtb0"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 132, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_ylmjw"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 198, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_ulao6"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 264, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_usluy"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 330, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_kgv6k"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 396, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_ymret"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 462, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_d35xv"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 528, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_yyjyl"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 594, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_p3fdm"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 660, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_2xxhe"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 726, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_8cwn3"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 792, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_q14re"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 858, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_nmmm8"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 924, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_vp71v"] +resource_local_to_scene = true atlas = ExtResource("3_uoync") region = Rect2(0, 990, 66, 66) [sub_resource type="AtlasTexture" id="AtlasTexture_slxus"] +resource_local_to_scene = true atlas = ExtResource("4_yanml") region = Rect2(0, 0, 66, 66) diff --git a/shield_ui_test.gd b/shield_ui_test.gd index b00a123..cb89242 100644 --- a/shield_ui_test.gd +++ b/shield_ui_test.gd @@ -27,3 +27,7 @@ func hit() -> void: shield.take_damage(damage) for x: int in damage: lives_bar.take_life() + + +func _on_button_2_pressed() -> void: + pass # Replace with function body. diff --git a/shield_ui_test.tscn b/shield_ui_test.tscn index 4ce8d5a..a622695 100644 --- a/shield_ui_test.tscn +++ b/shield_ui_test.tscn @@ -42,6 +42,10 @@ text = ">" layout_mode = 2 text = "hit" +[node name="Button2" type="Button" parent="Controls" unique_id=1570558672] +layout_mode = 2 +text = "reset" + [node name="ShieldUI" parent="." unique_id=591084228 instance=ExtResource("2_iketu")] layout_mode = 0 offset_left = 130.0 @@ -59,3 +63,4 @@ offset_bottom = 115.0 [connection signal="pressed" from="Controls/VBoxContainer/Button" to="." method="decrease_damage"] [connection signal="pressed" from="Controls/VBoxContainer/Button2" to="." method="increase_damage"] [connection signal="pressed" from="Controls/Button" to="." method="hit"] +[connection signal="pressed" from="Controls/Button2" to="." method="_on_button_2_pressed"]