From 14deb2de718feaa35195058afe709d0e01a488c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Tue, 5 May 2026 07:04:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E7=B1=BB=E5=90=8D=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复TipBox销毁时的动画冲突问题 重构游戏重启逻辑以包含库存保存 移除GameOver面板中的重复库存保存代码 优化UIState中的字段显示控制和提示清除功能 --- scripts/Contents/Panels/GameOver.gd | 2 -- scripts/Contents/Panels/Pause.gd | 1 + scripts/Statemachine/TipBox.gd | 1 + scripts/Statemachine/UIState.gd | 34 ++++++++++++++++-------- scripts/Tools/Managers/GameBusManager.gd | 3 +++ scripts/Tools/OutGameStorage.gd | 4 +++ 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/scripts/Contents/Panels/GameOver.gd b/scripts/Contents/Panels/GameOver.gd index 5c9fc9f..9a9cc14 100644 --- a/scripts/Contents/Panels/GameOver.gd +++ b/scripts/Contents/Panels/GameOver.gd @@ -9,7 +9,5 @@ func beforeOpen(args: Array = []): audio.play() var reasonTemplate = MathTool.randomChoiceFrom(GameRule.deadReasons) deadreason.text = ("[color=gray]" + reasonTemplate + "凶手是[b]%s[/b]的[b]%s[/b]。[/color]") % args - for item in OutGameStorage.inventory: - OutGameStorage.inventory[item] += UIState.player.inventory[item] func afterOpen(_args: Array = []): gameControl.enable() diff --git a/scripts/Contents/Panels/Pause.gd b/scripts/Contents/Panels/Pause.gd index 540f868..afd3663 100644 --- a/scripts/Contents/Panels/Pause.gd +++ b/scripts/Contents/Panels/Pause.gd @@ -1,5 +1,6 @@ @tool extends FullscreenPanelBase +class_name PausePanel @onready var gameControl: GameControl = $%gameControl diff --git a/scripts/Statemachine/TipBox.gd b/scripts/Statemachine/TipBox.gd index fe4e2d4..254a4fb 100644 --- a/scripts/Statemachine/TipBox.gd +++ b/scripts/Statemachine/TipBox.gd @@ -31,6 +31,7 @@ func _process(_delta): label.text = text func destroy(): + if animator.is_playing(): return animator.play("hide") await animator.animation_finished queue_free() diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index f59d56a..ef30fc9 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -15,6 +15,8 @@ static var tips: VBoxContainer static var itemsContainer: Control static var energyContainer: Control +static var showingFields: bool = false + func _ready(): bossbar = $%bossbar panels = $%panels @@ -44,17 +46,22 @@ func _physics_process(_delta): itemsContainer.visible = true energyContainer.visible = true if !fieldsAnimator.is_playing(): - if Input.is_action_just_pressed("showFields"): - for i in fields.get_children(): - fields.remove_child(i) - for i in player.fields: - if player.fields[i] == EntityBase.TITLE_FLAG: - fields.add_child(QuickUI.graySmallText(i)) - else: - fields.add_child(FieldShow.create(i, player.fields[i], false, player, true)) - fieldsAnimator.play("show") - if Input.is_action_just_released("showFields"): - fieldsAnimator.play("hide") + if showingFields: + if Input.is_action_just_released("showFields") || !(currentPanel is PausePanel): + showingFields = false + fieldsAnimator.play("hide") + else: + if Input.is_action_just_pressed("showFields") || currentPanel is PausePanel: + showingFields = true + for i in fields.get_children(): + fields.remove_child(i) + for i in player.fields: + if player.fields[i] == EntityBase.TITLE_FLAG: + fields.add_child(QuickUI.graySmallText(i)) + else: + fields.add_child(FieldShow.create(i, player.fields[i], false, player, true)) + fieldsAnimator.play("show") + if Input.is_action_just_pressed("pause"): if currentPanel: if currentPanel is MakeFeedPanel: @@ -96,5 +103,10 @@ static func closeCurrentPanel(): static func showTip(text: String, messageType: TipBox.MessageType = TipBox.MessageType.INFO): var box = TipBox.create(text, messageType) tips.add_child(box) + await box.animator.animation_finished await TickTool.millseconds(500 * len(text)) box.destroy() +static func clearTips(): + for child in tips.get_children(): + if child is TipBox: + child.destroy() diff --git a/scripts/Tools/Managers/GameBusManager.gd b/scripts/Tools/Managers/GameBusManager.gd index c7e0049..9e670bb 100644 --- a/scripts/Tools/Managers/GameBusManager.gd +++ b/scripts/Tools/Managers/GameBusManager.gd @@ -9,6 +9,9 @@ static func restart(tree: SceneTree): effect.queue_free() for item in tree.get_nodes_in_group("items"): item.queue_free() + + OutGameStorage.saveInventory() CameraManager.shakeStop() WorldManager.timeRestart() + UIState.setPanel("Starter") diff --git a/scripts/Tools/OutGameStorage.gd b/scripts/Tools/OutGameStorage.gd index f27817a..3e5c1c3 100644 --- a/scripts/Tools/OutGameStorage.gd +++ b/scripts/Tools/OutGameStorage.gd @@ -19,3 +19,7 @@ static var upgradableFieldsLevel = ArrayTool.fill(upgradableFieldsAdvance, func( static var maxInitialFeedCount: int = 3 static var maxInitialWeaponCount: int = 3 static var inventory = ArrayTool.fill(upgradableFieldsCost, func(_k): return 0) + +static func saveInventory(): + for item in OutGameStorage.inventory: + OutGameStorage.inventory[item] += UIState.player.inventory[item]