diff --git a/assets/music&sfx/sfx/achievement_unlock.wav b/assets/music&sfx/sfx/achievement_unlock.wav index a8c8781..5110446 100644 Binary files a/assets/music&sfx/sfx/achievement_unlock.wav and b/assets/music&sfx/sfx/achievement_unlock.wav differ diff --git a/assets/music&sfx/sfx/achievement_unlock.wav.import b/assets/music&sfx/sfx/achievement_unlock.wav.import index 6c22e63..b7be775 100644 --- a/assets/music&sfx/sfx/achievement_unlock.wav.import +++ b/assets/music&sfx/sfx/achievement_unlock.wav.import @@ -2,7 +2,7 @@ importer="wav" type="AudioStreamWAV" -uid="uid://c7x1rtkae66k4" +uid="uid://c2xs6x6q70sr1" path="res://.godot/imported/achievement_unlock.wav-9a9f9e013cd33e691b8d6734dd2cf61a.sample" [deps] diff --git a/scenes/stats_screen.tscn b/scenes/stats_screen.tscn index ecbc9a2..dd36bde 100644 --- a/scenes/stats_screen.tscn +++ b/scenes/stats_screen.tscn @@ -48,6 +48,38 @@ content_margin_top = 4.0 content_margin_right = 10.0 content_margin_bottom = 4.0 +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_reset_hover"] +bg_color = Color(0.5, 0.04, 0.04, 0.4) +border_width_left = 2 +border_width_top = 2 +border_width_right = 2 +border_width_bottom = 2 +border_color = Color(1.0, 0.3, 0.3, 0.75) +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 +content_margin_left = 10.0 +content_margin_top = 4.0 +content_margin_right = 10.0 +content_margin_bottom = 4.0 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_reset_pressed"] +bg_color = Color(0.35, 0.02, 0.02, 0.6) +border_width_left = 2 +border_width_top = 2 +border_width_right = 2 +border_width_bottom = 2 +border_color = Color(1.0, 0.5, 0.5, 1.0) +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 +content_margin_left = 10.0 +content_margin_top = 4.0 +content_margin_right = 10.0 +content_margin_bottom = 4.0 + [node name="StatsScreen" type="CanvasLayer"] script = ExtResource("1_stats") @@ -108,6 +140,23 @@ size_flags_horizontal = 3 layout_mode = 2 custom_minimum_size = Vector2(0, 12) +[node name="ResetButton" type="Button" parent="VBoxContainer"] +custom_minimum_size = Vector2(250, 50) +layout_mode = 2 +theme_override_colors/font_color = Color(0.85, 0.5, 0.5, 1) +theme_override_colors/font_hover_color = Color(1, 0.35, 0.35, 1) +theme_override_colors/font_pressed_color = Color(1, 0.55, 0.55, 1) +theme_override_colors/font_focus_color = Color(0.85, 0.5, 0.5, 1) +theme_override_fonts/font = ExtResource("3_stats") +theme_override_font_sizes/font_size = 24 +theme_override_styles/normal = SubResource("StyleBoxEmpty_normal") +theme_override_styles/hover = SubResource("StyleBoxFlat_reset_hover") +theme_override_styles/pressed = SubResource("StyleBoxFlat_reset_pressed") +theme_override_styles/focus = SubResource("StyleBoxEmpty_focus") +theme_override_styles/disabled = SubResource("StyleBoxEmpty_normal") +theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_reset_pressed") +text = "Reset Stats & Achievements" + [node name="BackButton" type="Button" parent="VBoxContainer"] custom_minimum_size = Vector2(250, 50) layout_mode = 2 @@ -125,4 +174,5 @@ theme_override_styles/disabled = SubResource("StyleBoxEmpty_normal") theme_override_styles/hover_pressed = SubResource("StyleBoxFlat_pressed") text = "Back" +[connection signal="pressed" from="VBoxContainer/ResetButton" to="." method="_on_reset_button_pressed"] [connection signal="pressed" from="VBoxContainer/BackButton" to="." method="_on_back_button_pressed"] diff --git a/scripts/achievement_manager.gd b/scripts/achievement_manager.gd index 2612c38..376329d 100644 --- a/scripts/achievement_manager.gd +++ b/scripts/achievement_manager.gd @@ -165,6 +165,11 @@ func _meets(ach: Dictionary) -> bool: return d["runs_played"] >= t return false +func reset() -> void: + for ach in achievements: + ach.unlocked = false + _save() + func get_unlocked_count() -> int: var n = 0 for ach in achievements: diff --git a/scripts/stats_manager.gd b/scripts/stats_manager.gd index 77c4fae..fa8fc65 100644 --- a/scripts/stats_manager.gd +++ b/scripts/stats_manager.gd @@ -57,6 +57,17 @@ func on_spell_cast(spell_type: String) -> void: data["spells_cast"][spell_type] += 1 AchievementManager.call_deferred("check_all") +func reset() -> void: + data["runs_played"] = 0 + data["total_deaths"] = 0 + data["longest_run_seconds"] = 0.0 + data["total_survive_seconds"] = 0.0 + for key in data["kills"]: + data["kills"][key] = 0 + for key in data["spells_cast"]: + data["spells_cast"][key] = 0 + _save() + func _save() -> void: var file = FileAccess.open(SAVE_PATH, FileAccess.WRITE) if file == null: diff --git a/scripts/stats_screen.gd b/scripts/stats_screen.gd index 13bd4e0..8ce7d6a 100644 --- a/scripts/stats_screen.gd +++ b/scripts/stats_screen.gd @@ -89,5 +89,10 @@ func _fmt_time(seconds: float) -> String: return "%dh %02dm %02ds" % [h, m, sec] return "%dm %02ds" % [m, sec] +func _on_reset_button_pressed() -> void: + StatsManager.reset() + AchievementManager.reset() + get_tree().change_scene_to_file("res://scenes/stats_screen.tscn") + func _on_back_button_pressed() -> void: get_tree().change_scene_to_file("res://scenes/mainmenu.tscn")