From 11a293378c2799e0740d1e65bba1421539fc54c3 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 12:24:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor(UI):=20=E4=BC=98=E5=8C=96=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=B9=B3=E6=BB=91=E7=9B=B8=E6=9C=BA=E7=A7=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将字段显示和隐藏逻辑提取为独立方法 为相机添加位置平滑效果 在游戏重启时重置初始饲料选择状态 --- components/Scenes/World.tscn | 1 + scripts/Contents/Panels/Starter.gd | 5 ++++- scripts/Statemachine/UIState.gd | 28 ++++++++++++++---------- scripts/Tools/Managers/CameraManager.gd | 1 - scripts/Tools/Managers/GameBusManager.gd | 2 ++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/components/Scenes/World.tscn b/components/Scenes/World.tscn index d4c9707..7100a24 100644 --- a/components/Scenes/World.tscn +++ b/components/Scenes/World.tscn @@ -85,6 +85,7 @@ limit_left = -2400 limit_top = -1800 limit_right = 2400 limit_bottom = 1800 +position_smoothing_enabled = true editor_draw_limits = true script = ExtResource("5_mk7bv") constantOffset = Vector2(0, -80) diff --git a/scripts/Contents/Panels/Starter.gd b/scripts/Contents/Panels/Starter.gd index baa2e3b..62676b6 100644 --- a/scripts/Contents/Panels/Starter.gd +++ b/scripts/Contents/Panels/Starter.gd @@ -89,7 +89,10 @@ func startSingleplayerGame(): ), OutGameStorage.upgradableFieldsValue) UIState.player = EntityBase.generatePlayer(playerNameInput.text, selectedCharacter, extras) WorldManager.rootNode.spawnWave(Vector2.ZERO) - UIState.setPanel("CompilingTip") + if buildingShader: + UIState.setPanel("CompilingTip") + else: + UIState.setPanel("SelectInitialFeed") func _ready(): historyStack = Composables.useHistoryStack(playerNameInput) diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index ef30fc9..e8c4aeb 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -48,19 +48,10 @@ func _physics_process(_delta): if !fieldsAnimator.is_playing(): if showingFields: if Input.is_action_just_released("showFields") || !(currentPanel is PausePanel): - showingFields = false - fieldsAnimator.play("hide") + hideFields() 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") + showFields() if Input.is_action_just_pressed("pause"): if currentPanel: @@ -100,6 +91,7 @@ static func setPanel(targetName: String = "", args: Array = []): panel.hidePanel() static func closeCurrentPanel(): setPanel() + static func showTip(text: String, messageType: TipBox.MessageType = TipBox.MessageType.INFO): var box = TipBox.create(text, messageType) tips.add_child(box) @@ -110,3 +102,17 @@ static func clearTips(): for child in tips.get_children(): if child is TipBox: child.destroy() + +static func showFields(): + 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") +static func hideFields(): + showingFields = false + fieldsAnimator.play("hide") diff --git a/scripts/Tools/Managers/CameraManager.gd b/scripts/Tools/Managers/CameraManager.gd index 8f09821..a87bff0 100644 --- a/scripts/Tools/Managers/CameraManager.gd +++ b/scripts/Tools/Managers/CameraManager.gd @@ -17,7 +17,6 @@ func _physics_process(_delta): if is_instance_valid(UIState.player): position = UIState.player.position + constantOffset position += MathTool.sampleInCircle(shakeIntensity) - offset += ((get_global_mouse_position() - UIState.player.position).clampf(-100, 100) - offset) * 0.15 static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue): if StarterPanel.buildingShader: return diff --git a/scripts/Tools/Managers/GameBusManager.gd b/scripts/Tools/Managers/GameBusManager.gd index 9e670bb..abec732 100644 --- a/scripts/Tools/Managers/GameBusManager.gd +++ b/scripts/Tools/Managers/GameBusManager.gd @@ -10,8 +10,10 @@ static func restart(tree: SceneTree): for item in tree.get_nodes_in_group("items"): item.queue_free() + UIState.hideFields() OutGameStorage.saveInventory() CameraManager.shakeStop() WorldManager.timeRestart() + StarterPanel.selectingFeed = true UIState.setPanel("Starter")