From 5dfcd152cf19d81c3fee4a1da19a699b279291d9 Mon Sep 17 00:00:00 2001 From: Bunnycxk <986826561@qq.com> Date: Sun, 28 Jan 2024 06:36:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B0=86=E7=AB=A0=E8=8A=82=E5=8F=B7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=BD=97=E9=A9=AC=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- levels/base_level/base_level.gd | 3 ++- .../level_menu/level_button/level_button.gd | 2 +- levels/chapter_menu/level_menu/level_menu.gd | 4 ++-- objects/main_menu/main_menu.gd | 13 ++++++++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/levels/base_level/base_level.gd b/levels/base_level/base_level.gd index 768c0b3..d3703c0 100644 --- a/levels/base_level/base_level.gd +++ b/levels/base_level/base_level.gd @@ -17,6 +17,7 @@ var req_pos = [] # Array[int] var chap_id : int var lvl_id : int +const I_NUMBER = ["I","II","III","VI","V"] const DATA := [ [ @@ -70,7 +71,7 @@ func init(_chap_id: int, _lvl_id: int) -> void: var choices = count(DATA[chap_id][lvl_id][2].replace(" ", "").replace("X", "*")) - $HUDs/Title.set_text("%d-%d %s" % [chap_id + 1, lvl_id + 1, lvl_name]) + $HUDs/Title.set_text("%s-%d %s" % [I_NUMBER[chap_id], lvl_id + 1, lvl_name]) diff --git a/levels/chapter_menu/level_menu/level_button/level_button.gd b/levels/chapter_menu/level_menu/level_button/level_button.gd index 6d8d0cd..f6b5023 100644 --- a/levels/chapter_menu/level_menu/level_button/level_button.gd +++ b/levels/chapter_menu/level_menu/level_button/level_button.gd @@ -27,7 +27,7 @@ func init(chapter_id: int, level_id : int, pos : Vector2, type : int) -> void : var txt if type == 0: - txt = str(chapter_id + 1) + txt = "I" + str(chapter_id + 1) else: txt = str(level_id + 1) set_word(txt) diff --git a/levels/chapter_menu/level_menu/level_menu.gd b/levels/chapter_menu/level_menu/level_menu.gd index bfedbfa..042134d 100644 --- a/levels/chapter_menu/level_menu/level_menu.gd +++ b/levels/chapter_menu/level_menu/level_menu.gd @@ -4,7 +4,7 @@ extends Node2D const CHAP_NAMES = ["=P", "Add", "Multiply", "()", "Equal?"] - +const I_NUMBER = ["I","II","III","VI","V"] const LevelButton := preload("res://levels/chapter_menu/level_menu/level_button/level_button.tscn") const BaseLevel := preload("res://levels/base_level/base_level.tscn") @@ -21,7 +21,7 @@ func init(chap_id : int, lvl_num : int) -> void: if lvl_num == -1: lvl_num = len(BaseLevel.instantiate().DATA[chap_id]) - $Title.set_text("Ch." + str(chap_id + 1) + " " + CHAP_NAMES[chap_id]) + $Title.set_text("Ch." + I_NUMBER[chap_id] + " " + CHAP_NAMES[chap_id]) chapter_id = chap_id for level_id in range(0, lvl_num): diff --git a/objects/main_menu/main_menu.gd b/objects/main_menu/main_menu.gd index a4ccd0c..e7207db 100644 --- a/objects/main_menu/main_menu.gd +++ b/objects/main_menu/main_menu.gd @@ -1,7 +1,7 @@ extends AnimatedSprite2D -var ChapterMenu = preload("res://levels/chapter_menu/chapter_menu.tscn") - +const ChapterMenu = preload("res://levels/chapter_menu/chapter_menu.tscn") +const BaseLevel := preload("res://levels/base_level/base_level.tscn") # Called when the node enters the scene tree for the first time. func _ready(): $start_button/AnimatedSprite2D.play() @@ -18,5 +18,12 @@ func _on_animation_finished(): func _on_start_button_pressed(): - get_tree().root.add_child(ChapterMenu.instantiate()) + var base_level := BaseLevel.instantiate() + + # print(chap_id, lvl_id) + + base_level.init(0, 0) + get_tree().root.add_child(base_level) queue_free() + #get_tree().root.add_child(ChapterMenu.instantiate()) + #queue_free() From ee03aa1d785c05040090ec9d34a5e9f5e6242d0d Mon Sep 17 00:00:00 2001 From: Bunnycxk <986826561@qq.com> Date: Sun, 28 Jan 2024 07:18:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=87=8D=E5=86=99replay=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E5=88=A0=E9=99=A4=E5=BD=93=E5=89=8D=E8=8A=82?= =?UTF-8?q?=E7=82=B9=EF=BC=8C=E7=84=B6=E5=90=8E=E9=87=8D=E6=96=B0=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E5=8C=96=E4=B8=80=E4=B8=AA=E8=8A=82=E7=82=B9=E5=B9=B6?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=87=B3=E8=AF=A5=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- levels/base_level/base_level.gd | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/levels/base_level/base_level.gd b/levels/base_level/base_level.gd index d3703c0..c35150d 100644 --- a/levels/base_level/base_level.gd +++ b/levels/base_level/base_level.gd @@ -209,5 +209,11 @@ func _on_next_level_button_pressed(): queue_free() func _on_replay_button_pressed(): - for card_base: CardBase in $CardBases.get_children(): - card_base.reset_all_card_position() + var new_level = BaseLevel.instantiate() + new_level.init(chap_id, lvl_id) + get_tree().root.add_child(new_level) + queue_free() + #print(get_tree().current_scene) + #get_tree().reload_current_scene() + #for card_base: CardBase in $CardBases.get_children(): + #card_base.reset_all_card_position()