From a85c69313b2dc0dc1be04aa7fad87c87708ee31c Mon Sep 17 00:00:00 2001 From: Moe Poi ~ Date: Sat, 21 Oct 2023 00:23:10 +0700 Subject: [PATCH] Add Save & Load Game Data --- assets/icons/locked.png | Bin 0 -> 11207 bytes assets/icons/locked.png.import | 34 ++++++++++++++++++++ scenes/ui/select_stage.tscn | 39 ++++++++++++++++++++++- scripts/data/data.gd | 31 ++++++++++++++++++ scripts/stages/1/game_manager.gd | 1 + scripts/stages/2/game_manager.gd | 1 + scripts/stages/3/game_manager.gd | 1 + scripts/stages/4/game_manager.gd | 1 + scripts/stages/5/game_manager.gd | 1 + scripts/stages/6/game_manager.gd | 1 + scripts/ui/main_menu.gd | 10 ++++++ scripts/ui/select_stage.gd | 52 +++++++++++++++++++++++++++---- scripts/ui/victory.gd | 8 +++++ 13 files changed, 173 insertions(+), 7 deletions(-) create mode 100644 assets/icons/locked.png create mode 100644 assets/icons/locked.png.import create mode 100644 scripts/data/data.gd diff --git a/assets/icons/locked.png b/assets/icons/locked.png new file mode 100644 index 0000000000000000000000000000000000000000..346690eca089b4b0bbd0e7e0de0d633652294fed GIT binary patch literal 11207 zcmeHtc|6qL|L>WxCZWZWtRIF+)=-)(gT$aL$*x4UWQ#!xUbGj@nBn*VgU!yO;H^?mip zqg7wx$3lZ_p54gv=e8d`C+!kpTe`C{d9#129=BTm^8<3@KOp3EQimAtzdqqt#7PbA7@vz!e{ z^DP&2*e)U>>J6Wr$Y%Yk@?0iMw>CkWYNa~?oBD?~?*1R_2tL=Qj z(m=M(Q=RO!GbGjn%jMYrh;gd5*#ka% z9}pzV0MO00^n;SIjFbZM!=%nq@*{G{veV)3D;ehqZBVMyP(wM2vB&7B)I%#}VKO-^ z1)NdebYmf<8-yK002R3YgJSW01FQA0#|8t3pL_^UndpaV@h;*^-T`^I;eZJzmY-#d zTiy1T;tL5$BNw7J(2&ViyaW}$2YB*V?uboOj5Vfj>kYFlprJezn30EskRe$}&|$`m z+Yq*5AHbPQ(w;8q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es/stages/stage_{stage_id}.tscn".format({"stage_id": str(stage_id)})) + pass \ No newline at end of file diff --git a/scripts/ui/victory.gd b/scripts/ui/victory.gd index 7baa39e..95ed736 100644 --- a/scripts/ui/victory.gd +++ b/scripts/ui/victory.gd @@ -1,6 +1,9 @@ extends Control +var game_data = load("res://scripts/data/data.gd").new() +var data = game_data.load_data() + var next_stage: int = 0 func set_next_stage(value: int): @@ -9,6 +12,11 @@ func set_next_stage(value: int): else: $Panel/MarginContainer/VBoxContainer/NextStage.text = "Main Menu" +func unlock_next_stage(): + if next_stage != 0: + data['unlocked_stage'] = next_stage + game_data.save_data(data) + func _on_next_stage_pressed(): get_tree().paused = false