From 5794c49a3985f11953b971769cae77c9d2a3350b Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Mon, 2 Mar 2026 20:00:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor(fix-system):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E7=BB=B4=E4=BF=AE=E4=BE=A7=E8=BE=B9=E6=A0=8F=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E6=9E=B6=E6=9E=84=E5=B9=B6=E6=95=B4=E5=90=88=E6=96=B9=E5=9D=97?= =?UTF-8?q?=E6=8B=BC=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- .../FixSystemPrefabs/Block Puzzle Game.prefab | 2 +- .../BodyModule/BodyModuleSystem.cs | 4 +- .../FixSystemNew/BodyModule/CableSystem.cs | 9 +- .../FixSystemNew/Screen System/Core.meta | 8 ++ .../Screen System/Core/FixPanelSystem.cs | 70 ++++++++++++++ .../{FixPanel => Core}/FixPanelSystem.cs.meta | 2 +- .../IPanelPart.cs => Core/IOperatorPanel.cs} | 0 .../IOperatorPanel.cs.meta} | 0 .../Screen System/FixPanel/BlockPuzzlePart.cs | 58 +++++++++++- .../Screen System/FixPanel/FixPanelSystem.cs | 46 ---------- .../Screen System/FixPanel/ScreenPanel.cs | 43 +++++++++ .../FixPanel/ScreenPanel.cs.meta} | 2 +- .../Screen System/FixPanel/TaskPanel.cs | 68 ++++++++++++++ .../Screen System/FixPanel/TaskPanel.cs.meta | 11 +++ .../Screen System/ScreenYarnCommand.cs | 15 +-- .../FixSystemNew/Screen System/TaskScreen.cs | 2 +- .../Screen System/UniversalScreen.cs | 32 +------ .../BlockPuzzle/Class/BlockPuzzlePanel.cs | 92 ------------------- .../BlockPuzzle/Class/BlockPuzzleSystem.cs | 46 +++++----- 19 files changed, 290 insertions(+), 220 deletions(-) create mode 100644 Assets/Scripts/FixSystemNew/Screen System/Core.meta create mode 100644 Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs rename Assets/Scripts/FixSystemNew/Screen System/{FixPanel => Core}/FixPanelSystem.cs.meta (83%) rename Assets/Scripts/FixSystemNew/Screen System/{FixPanel/IPanelPart.cs => Core/IOperatorPanel.cs} (100%) rename Assets/Scripts/FixSystemNew/Screen System/{FixPanel/IPanelPart.cs.meta => Core/IOperatorPanel.cs.meta} (100%) delete mode 100644 Assets/Scripts/FixSystemNew/Screen System/FixPanel/FixPanelSystem.cs create mode 100644 Assets/Scripts/FixSystemNew/Screen System/FixPanel/ScreenPanel.cs rename Assets/Scripts/{MiniGame/BlockPuzzle/Class/BlockPuzzlePanel.cs.meta => FixSystemNew/Screen System/FixPanel/ScreenPanel.cs.meta} (83%) create mode 100644 Assets/Scripts/FixSystemNew/Screen System/FixPanel/TaskPanel.cs create mode 100644 Assets/Scripts/FixSystemNew/Screen System/FixPanel/TaskPanel.cs.meta delete mode 100644 Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzlePanel.cs diff --git a/Assets/Prefabs/FixSystemPrefabs/Block Puzzle Game.prefab b/Assets/Prefabs/FixSystemPrefabs/Block Puzzle Game.prefab index 784333d66..00ddbc754 100644 --- a/Assets/Prefabs/FixSystemPrefabs/Block Puzzle Game.prefab +++ b/Assets/Prefabs/FixSystemPrefabs/Block Puzzle Game.prefab @@ -1169,7 +1169,7 @@ MonoBehaviour: m_EditorClassIdentifier: grid: {fileID: 2843654655404132764} shapeRoot: {fileID: 1499443718145266889} - blockPuzzlePanel: {fileID: 0} + blockPuzzlePart: {fileID: 0} shapeRecycleSlot: {fileID: 5821461881795384241} puzzleData: puzzleName: Game2 diff --git a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs index 14c4a4337..b45003ca2 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -62,7 +62,7 @@ namespace AibisDream.FixSystem // 处理内部索引 _bodyModuleGroup = transform.Find("Body Module Group")?.gameObject; _headModuleGroup = transform.Find("Head Module Group")?.gameObject; - CableSystem = transform.Find("Cable System").GetComponent(); + // CableSystem = FixPanelSystem.CableSystem; if (transform.Find("HeatMapController")) { heatMapController = transform.Find("HeatMapController").GetComponent(); diff --git a/Assets/Scripts/FixSystemNew/BodyModule/CableSystem.cs b/Assets/Scripts/FixSystemNew/BodyModule/CableSystem.cs index 95b333ce4..b1a0d45e3 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/CableSystem.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/CableSystem.cs @@ -38,13 +38,10 @@ namespace AibisDream.FixSystem #endregion - private void Awake() - { - InitComponentRefs(); - } - private void Start() { + InitComponentRefs(); + InitSystem(); LoadCableState(); } @@ -69,7 +66,7 @@ namespace AibisDream.FixSystem CableRootPos = CableReelRef.transform.Find("Cable Root Pos").transform; PhysicCableRef = transform.Find("PhysicCable").GetComponent(); - BodyModuleSystem = transform.parent.GetComponent(); + BodyModuleSystem = FixSystemCenter.SystemDic.Get(); } private void InitSystem() diff --git a/Assets/Scripts/FixSystemNew/Screen System/Core.meta b/Assets/Scripts/FixSystemNew/Screen System/Core.meta new file mode 100644 index 000000000..77c9e50b9 --- /dev/null +++ b/Assets/Scripts/FixSystemNew/Screen System/Core.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cdf20405a2a52d64ea96a65557431b27 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs new file mode 100644 index 000000000..9e1244d58 --- /dev/null +++ b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs @@ -0,0 +1,70 @@ +using System.Collections; +using System.Collections.Generic; +using AibisDream.Framework; +using AibisDream.Kit; +using UnityEngine; + +namespace AibisDream.FixSystem +{ + /// + /// 维修面板系统 - 统一管理所有侧边栏面板 + /// 包括常驻面板(对话、任务)和随状态切换的游戏面板 + /// + public class FixPanelSystem : Singleton + { + private void OnEnable() + { + RegisterScreenView(); + } + + private void OnDisable() + { + UnRegisterScreenView(); + } + + #region 维修面板 + + private static IOCContainer _repairPanelContainer = new(); + + public static void RegisterRepairPanel(T panel) + { + _repairPanelContainer.Register(panel); + } + + public static T GetRepairPanel() where T : class + { + return _repairPanelContainer.Get(); + } + + public static void UnregisterRepairPanel() where T : class + { + _repairPanelContainer.Unregister(); + } + + #endregion + + #region 常驻面板 + + [Header("任务面板")] + [SerializeField] private TaskPanel taskPanel; + public TaskPanel TaskPanel => taskPanel; + + [Header("屏幕面板")] + [SerializeField] private ScreenPanel screenPanel; + public ScreenPanel ScreenPanel => screenPanel; + + private void RegisterScreenView() + { + // DialogUIManager.Instance.RegisterScreenView(DialogViewType.Screen, screenPanel); + // DialogUIManager.Instance.RegisterScreenView(DialogViewType.Task, taskPanel); + } + + private void UnRegisterScreenView() + { + // DialogUIManager.Instance.UnRegisterScreenView(DialogViewType.Screen); + // DialogUIManager.Instance.UnRegisterScreenView(DialogViewType.Task); + } + + #endregion + } +} diff --git a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/FixPanelSystem.cs.meta b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs.meta similarity index 83% rename from Assets/Scripts/FixSystemNew/Screen System/FixPanel/FixPanelSystem.cs.meta rename to Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs.meta index 8d3a23f22..49476561a 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/FixPanelSystem.cs.meta +++ b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 22aebfdc0d2f6f74f99cb84e1b24bc04 +guid: a1952e7bc2cf88742a189a44fd0765f1 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/IPanelPart.cs b/Assets/Scripts/FixSystemNew/Screen System/Core/IOperatorPanel.cs similarity index 100% rename from Assets/Scripts/FixSystemNew/Screen System/FixPanel/IPanelPart.cs rename to Assets/Scripts/FixSystemNew/Screen System/Core/IOperatorPanel.cs diff --git a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/IPanelPart.cs.meta b/Assets/Scripts/FixSystemNew/Screen System/Core/IOperatorPanel.cs.meta similarity index 100% rename from Assets/Scripts/FixSystemNew/Screen System/FixPanel/IPanelPart.cs.meta rename to Assets/Scripts/FixSystemNew/Screen System/Core/IOperatorPanel.cs.meta diff --git a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/BlockPuzzlePart.cs b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/BlockPuzzlePart.cs index e0fe4fdd4..61300e52c 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/BlockPuzzlePart.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/BlockPuzzlePart.cs @@ -11,7 +11,57 @@ namespace AibisDream.FixSystem public UnityEvent OnSubmit => lockButton.onClick; public UnityEvent OnPopUp => popUpButton.onClick; - private Animator _animator; + // ------------------------ 屏幕显示 ------------------------- + [Header("屏幕")] + [SerializeField] private UniversalScreen blockPuzzleScreen; + + public void SwitchToLogScreen() + { + blockPuzzleScreen.gameObject.SetActive(false); + } + + public void ShowShapeInScreen(BlockShapeInfo shape) + { + blockPuzzleScreen.gameObject.SetActive(true); + + blockPuzzleScreen.SetImage("设备缩略图", shape.GetDetailImage()); + + blockPuzzleScreen.SetText("设备名称", shape.shapeName); + blockPuzzleScreen.SetText("设备描述", shape.shapeDescription); + + blockPuzzleScreen.SetText("PWR", $"PWR\n{shape.paramValue.power.ToString("+0;-0;+0")}"); + blockPuzzleScreen.SetText("NOISE", $"NOISE\n{shape.paramValue.noise.ToString("+0;-0;+0")}"); + blockPuzzleScreen.SetText("HEAT", $"HEAT\n{shape.paramValue.heat.ToString("+0;-0;+0")}"); + + for (int i = 1; i <= 3; i++) + { + if (i <= shape.states.Length) + { + blockPuzzleScreen.SetText($"设备状态{i}", shape.states[i - 1]); + } + else + { + blockPuzzleScreen.SetText($"设备状态{i}", ""); + } + } + } + + public void ClearShapeInScreen() + { + blockPuzzleScreen.SetImage("设备缩略图", null); + + blockPuzzleScreen.SetText("设备名称", "待选择"); + blockPuzzleScreen.SetText("设备描述", null); + + blockPuzzleScreen.SetText("PWR", "0"); + blockPuzzleScreen.SetText("NOISE", "0"); + blockPuzzleScreen.SetText("HEAT", "0"); + + for (int i = 1; i <= 3; i++) + { + blockPuzzleScreen.SetText($"设备状态{i}", ""); + } + } // ------------------------ 进度条 ------------------------- @@ -109,12 +159,14 @@ namespace AibisDream.FixSystem public void Open() { - _animator?.Play("Open", 0, 0); + TimelineCenter.Instance.PlayTimeline("维修面板/石头维修开启"); } public void Close() { - _animator?.Play("Close", 0, 0); + TimelineCenter.Instance.PlayTimeline("维修面板/石头维修关闭"); } + + public FixState TargetState => FixState.BlockPuzzle; } } \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/FixPanelSystem.cs b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/FixPanelSystem.cs deleted file mode 100644 index 24644ea6e..000000000 --- a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/FixPanelSystem.cs +++ /dev/null @@ -1,46 +0,0 @@ -using UnityEngine; -using AibisDream.Kit; -using AibisDream.Framework; - -namespace AibisDream.FixSystem -{ - public class FixPanelSystem : Singleton - { - // 组件索引及注册 - [SerializeField] private UniversalScreen logScreen; - private IOCContainer _screenContainer; - private IOCContainer _panelContainer; - - public override void OnSingletonInit() - { - _screenContainer = new IOCContainer(); - _panelContainer = new IOCContainer(); - } - - public override void OnSingletonDestroy() - { - _screenContainer.Clear(); - _panelContainer.Clear(); - } - - private void RegisterScreen(T screen) where T : class - { - _screenContainer.Register(screen); - } - - private void RegisterPanel(T panel) where T : class - { - _panelContainer.Register(panel); - } - - private void UnregisterScreen() where T : class - { - _screenContainer.Unregister(); - } - - private void UnregisterPanel() where T : class - { - _panelContainer.Unregister(); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/ScreenPanel.cs b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/ScreenPanel.cs new file mode 100644 index 000000000..ac3a25c77 --- /dev/null +++ b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/ScreenPanel.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using AibisDream.UI; +using System.Globalization; +using TMPro; + +namespace AibisDream.FixSystem +{ + public class ScreenPanel : MonoBehaviour, ILineView + { + [SerializeField] private TMP_Text title; + [SerializeField] private TerminalText logText; + + // ---------------------- 对话框功能 ---------------------- + public void RunLine(LineSyncToken token) + { + if (logText != null) + { + logText.OnTextShown += () => token.TextShown(); + + title.text = token.lineInfo.character.GetActorName(); + logText.SetTypewriterSpeed(GetTextSpeedValue()); + logText.AddText(token.lineInfo.lineText); + token.TextStart(); + } + else + { + Debug.LogError("UniversalScreen: logText 为空"); + } + } + + private float GetTextSpeedValue() + { + var textSpeedStr = SettingLoader.Instance.TryRead("TextSpeed", out string textSpeed) ? textSpeed : "1"; + return float.TryParse(textSpeedStr, NumberStyles.Float, CultureInfo.InvariantCulture, out float result) ? result : 1f; + } + + public void ClearScreen() + { + logText.Clear(); + title.text = string.Empty; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzlePanel.cs.meta b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/ScreenPanel.cs.meta similarity index 83% rename from Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzlePanel.cs.meta rename to Assets/Scripts/FixSystemNew/Screen System/FixPanel/ScreenPanel.cs.meta index 4fb223619..1e61f25a3 100644 --- a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzlePanel.cs.meta +++ b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/ScreenPanel.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d791efeea60851f44b14603ee02c71ff +guid: f1dfc0da3459bd44d9165739f0acd7c5 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/TaskPanel.cs b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/TaskPanel.cs new file mode 100644 index 000000000..0b6d0602e --- /dev/null +++ b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/TaskPanel.cs @@ -0,0 +1,68 @@ +using System.Collections.Generic; +using AibisDream.Framework; +using AibisDream.Utility; +using TMPro; +using UnityEngine; +using UnityEngine.UI; +using DG.Tweening; + +namespace AibisDream.FixSystem +{ + public class TaskPanel : MonoBehaviour, ILineView + { + #region 索引 + + [SerializeField] private Transform taskRoot; + [SerializeField] private Transform taskListParent; + private GameObject _taskItemPrefab; + private readonly Dictionary _taskDict = new(); + + #endregion + + private void Awake() + { + _taskItemPrefab = ResourceKit.LoadAssetSync(ConstRef.TaskItemName); + } + + public void ShowPanel() + { + taskRoot.DOLocalMoveX(-7.12f, 1f); + } + public void CompleteTask(string lineId) + { + if (_taskDict.Remove(lineId, out var taskItem)) + { + Destroy(taskItem); + } + } + + public void ClearTasks() + { + foreach (var task in _taskDict) + { + Destroy(task.Value); + } + _taskDict.Clear(); + } + + public void RunLine(LineSyncToken token) + { + if (_taskDict.ContainsKey(token.lineInfo.lineId)) + { + EnumEventSystem.Global.Send(DialogEventEnum.LineShown); + token.ForceAdvance(); + return; + } + + var taskItem = Instantiate(_taskItemPrefab, taskListParent); + var task = taskItem.GetComponent(); + task.text = $"\u25cf {token.lineInfo.lineText}"; + token.TextStart(); + + _taskDict[token.lineInfo.lineId] = taskItem; + token.TextShown(); + token.ForceAdvance(); + LayoutRebuilder.ForceRebuildLayoutImmediate(taskListParent.GetComponent()); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/TaskPanel.cs.meta b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/TaskPanel.cs.meta new file mode 100644 index 000000000..2ff95c2e0 --- /dev/null +++ b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/TaskPanel.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 15ff2c83edd36a44cbbbbde6a0cbe079 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/FixSystemNew/Screen System/ScreenYarnCommand.cs b/Assets/Scripts/FixSystemNew/Screen System/ScreenYarnCommand.cs index a3b750cc0..376fda78a 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/ScreenYarnCommand.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/ScreenYarnCommand.cs @@ -1,5 +1,4 @@ -using AibisDream.FixSystem; -using UnityEngine; +using AibisDream.FixSystem; using Yarn.Unity; using System.Collections; @@ -29,18 +28,6 @@ namespace AibisDream { ScreenSystem.TaskScreen.ClearTasks(); } - - [YarnCommand("task_moveIn")] - public static void ShowTask() - { - Debug.LogWarning("task_moveIn 已废弃,请尽快删除"); - } - - [YarnCommand("task_moveOut")] - public static void HideTask() - { - Debug.LogWarning("task_moveOut 已废弃,请尽快删除"); - } [YarnCommand("show_task_panel")] public static void ShowTaskPanel() diff --git a/Assets/Scripts/FixSystemNew/Screen System/TaskScreen.cs b/Assets/Scripts/FixSystemNew/Screen System/TaskScreen.cs index f01476be1..57a90615b 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/TaskScreen.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/TaskScreen.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using AibisDream.Framework; using AibisDream.Utility; using TMPro; diff --git a/Assets/Scripts/FixSystemNew/Screen System/UniversalScreen.cs b/Assets/Scripts/FixSystemNew/Screen System/UniversalScreen.cs index c00e80821..6607243a8 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/UniversalScreen.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/UniversalScreen.cs @@ -1,17 +1,12 @@ -using System.Globalization; -using System.Linq; -using AibisDream.UI; +using System.Linq; using TMPro; using UnityEngine; using UnityEngine.UI; namespace AibisDream.FixSystem { - public class UniversalScreen : MonoBehaviour, ILineView + public class UniversalScreen : MonoBehaviour { - [Header("是否为对话容器")] - [SerializeField] private TerminalText logText; - [Header("其他字段")] [SerializeField] private TMP_Text[] textFields; [SerializeField] private Image[] imageFields; @@ -41,28 +36,5 @@ namespace AibisDream.FixSystem Debug.LogError($"UniversalScreen: 未找到字段{fieldName}"); } } - - // ---------------------- 对话框功能 ---------------------- - public void RunLine(LineSyncToken token) - { - if (logText != null) - { - logText.OnTextShown += () => token.TextShown(); - - logText.SetTypewriterSpeed(GetTextSpeedValue()); - logText.AddText(token.lineInfo.lineText); - token.TextStart(); - } - else - { - Debug.LogError("UniversalScreen: logText 为空"); - } - } - - private float GetTextSpeedValue() - { - var textSpeedStr = SettingLoader.Instance.TryRead("TextSpeed", out string textSpeed) ? textSpeed : "1"; - return float.TryParse(textSpeedStr, NumberStyles.Float, CultureInfo.InvariantCulture, out float result) ? result : 1f; - } } } \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzlePanel.cs b/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzlePanel.cs deleted file mode 100644 index f6cec72fb..000000000 --- a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzlePanel.cs +++ /dev/null @@ -1,92 +0,0 @@ -using UnityEngine; -using AibisDream.FixSystem; - -namespace AibisDream -{ - public class BlockPuzzlePanel : MonoBehaviour, ILineView - { - [Header("组件索引")] - [SerializeField] private UniversalScreen logScreen; - [SerializeField] private UniversalScreen blockPuzzleScreen; - [SerializeField] private BlockPuzzlePart blockPuzzlePart; - - // ---------------------- 基本功能 ---------------------- - - public void SwitchToLogScreen() - { - logScreen.gameObject.SetActive(true); - blockPuzzleScreen.gameObject.SetActive(false); - } - - // ---------------------- 维修部分 ---------------------- - public BlockPuzzlePart Panel => blockPuzzlePart; - - public void ShowShapeInScreen(BlockShapeInfo shape) - { - logScreen.gameObject.SetActive(false); - blockPuzzleScreen.gameObject.SetActive(true); - - // 在屏幕上显示对应信息 - blockPuzzleScreen.SetImage("设备缩略图", shape.GetDetailImage()); - - blockPuzzleScreen.SetText("设备名称", shape.shapeName); - blockPuzzleScreen.SetText("设备描述", shape.shapeDescription); - - blockPuzzleScreen.SetText("PWR", $"PWR\n{shape.paramValue.power.ToString("+0;-0;+0")}"); - blockPuzzleScreen.SetText("NOISE", $"NOISE\n{shape.paramValue.noise.ToString("+0;-0;+0")}"); - blockPuzzleScreen.SetText("HEAT", $"HEAT\n{shape.paramValue.heat.ToString("+0;-0;+0")}"); - - for (int i = 1; i <= 3; i++) - { - if (i <= shape.states.Length) - { - blockPuzzleScreen.SetText($"设备状态{i}", shape.states[i-1]); - } - else - { - blockPuzzleScreen.SetText($"设备状态{i}", ""); - } - } - } - - public void ClearShapeInScreen() - { - blockPuzzleScreen.SetImage("设备缩略图", null); - - blockPuzzleScreen.SetText("设备名称", "待选择"); - blockPuzzleScreen.SetText("设备描述", null); - - blockPuzzleScreen.SetText("PWR", "0"); - blockPuzzleScreen.SetText("NOISE", "0"); - blockPuzzleScreen.SetText("HEAT", "0"); - - for (int i = 1; i <= 3; i++) - { - blockPuzzleScreen.SetText($"设备状态{i}", ""); - } - } - - // ---------------------- 对话功能 ---------------------- - - public void RunLine(LineSyncToken syncToken) - { - // 对话时显示Log面板,隐藏BlockPuzzle面板 - logScreen.gameObject.SetActive(true); - blockPuzzleScreen.gameObject.SetActive(false); - - logScreen.RunLine(syncToken); - } - - // -------------------------- 生命周期 -------------------------- - - private void OnEnable() - { - DialogUIManager.Instance?.RegisterScreenView(DialogViewType.Log, this); - } - - private void OnDisable() - { - DialogUIManager.Instance?.UnRegisterScreenView(DialogViewType.Log); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleSystem.cs b/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleSystem.cs index 3a5097648..8b08a1b8c 100644 --- a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleSystem.cs +++ b/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleSystem.cs @@ -1,9 +1,10 @@ -using UnityEngine; +using UnityEngine; using Cinemachine; using AibisDream.Kit; using AibisDream.Utility; using System.Linq; using AibisDream.Framework; +using AibisDream.FixSystem; using UnityEngine.EventSystems; namespace AibisDream @@ -14,7 +15,7 @@ namespace AibisDream // 物体索引 [SerializeField] public BlockPuzzleGrid grid; [SerializeField] private Transform shapeRoot; - [SerializeField] public BlockPuzzlePanel blockPuzzlePanel; + [SerializeField] public BlockPuzzlePart blockPuzzlePart; [SerializeField] private ShapeRecycleSlot shapeRecycleSlot; [Header("数据")] @@ -80,11 +81,11 @@ namespace AibisDream // 加载验证器 validator = ResourceKit.LoadAssetSync(puzzleData.validatorName); - blockPuzzlePanel.Panel.SetProgressMaxValue(validator.CollectThresholds()); + blockPuzzlePart.SetProgressMaxValue(validator.CollectThresholds()); // 初始化侧边栏 var deviceDatas = BlockPuzzleKit.LoadBlockShapeDataBatch(puzzleData.shapeInRack); - blockPuzzlePanel.Panel.DeviceButtonDatas = deviceDatas.Values.ToArray(); + blockPuzzlePart.DeviceButtonDatas = deviceDatas.Values.ToArray(); // 组装事件逻辑 @@ -149,16 +150,15 @@ namespace AibisDream } // 更新按钮的交互状态 - if (blockPuzzlePanel != null && blockPuzzlePanel.Panel != null) + if (blockPuzzlePart != null) { - var panel = blockPuzzlePanel.Panel; - if (panel.LockButton != null) + if (blockPuzzlePart.LockButton != null) { - panel.LockButton.GetComponent().SetLockedState(IsLocked); + blockPuzzlePart.LockButton.GetComponent().SetLockedState(IsLocked); } - if (panel.PopUpButton != null) + if (blockPuzzlePart.PopUpButton != null) { - panel.PopUpButton.interactable = !IsLocked; + blockPuzzlePart.PopUpButton.interactable = !IsLocked; } } } @@ -176,7 +176,7 @@ namespace AibisDream public void LoadShapeRack() { - blockPuzzlePanel.Panel.LoadBackupDevices(); + blockPuzzlePart.LoadBackupDevices(); } // --------------------- 维修面板同步 ------------------- @@ -189,9 +189,9 @@ namespace AibisDream private void AssembleEventLogic() { // 由面板触发 - blockPuzzlePanel.Panel.OnDeviceSelected += OnPanelShapeSelected; - blockPuzzlePanel.Panel.OnSubmit.AddListener(SubmitGameResult); - blockPuzzlePanel.Panel.OnPopUp.AddListener(PopUpShape); + blockPuzzlePart.OnDeviceSelected += OnPanelShapeSelected; + blockPuzzlePart.OnSubmit.AddListener(SubmitGameResult); + blockPuzzlePart.OnPopUp.AddListener(PopUpShape); // 由Shape触发 - 使用新的事件系统 shapeFactory.OnDragStartDetailed += OnShapeDragStartDetailed; @@ -200,15 +200,15 @@ namespace AibisDream shapeFactory.OnClick += OnShapeClick; // 由系统触发 - validator.OnValidate.AddListener(blockPuzzlePanel.Panel.SetVaildState); - validator.OnValidate.AddListener(blockPuzzlePanel.Panel.OnProgressChanged); + validator.OnValidate.AddListener(blockPuzzlePart.SetVaildState); + validator.OnValidate.AddListener(blockPuzzlePart.OnProgressChanged); } private void OnPanelShapeSelected(BlockShapeInfo shapeData) { // 在屏幕上更新选中的图形 selectedShapeName = shapeData.shapeName; - blockPuzzlePanel.ShowShapeInScreen(shapeData); + blockPuzzlePart.ShowShapeInScreen(shapeData); } // 旧的事件处理方法已迁移到新的详细事件处理器 @@ -219,7 +219,7 @@ namespace AibisDream public void OnShapeClick(BlockShape blockShape) { // 点击形状 - blockPuzzlePanel.ShowShapeInScreen(blockShape.BlockShapeData.blockShapeInfo); + blockPuzzlePart.ShowShapeInScreen(blockShape.BlockShapeData.blockShapeInfo); } #region 新的事件驱动处理器 @@ -238,7 +238,7 @@ namespace AibisDream // 显示Info if (blockShape?.BlockShapeData.blockShapeInfo.shapeName != null) { - blockPuzzlePanel.ShowShapeInScreen(blockShape.BlockShapeData.blockShapeInfo); + blockPuzzlePart.ShowShapeInScreen(blockShape.BlockShapeData.blockShapeInfo); EventSystem.current.SetSelectedGameObject(null); selectedShapeName = null; } @@ -308,11 +308,11 @@ namespace AibisDream shapeRecycleSlot.RecycleShape(args.Shape); // 清空屏幕并切换回LogScreen - blockPuzzlePanel.ClearShapeInScreen(); - blockPuzzlePanel.SwitchToLogScreen(); + blockPuzzlePart.ClearShapeInScreen(); + blockPuzzlePart.SwitchToLogScreen(); // 向面板添加回收的形状 - blockPuzzlePanel.Panel.OnDeviceRecycle(args.Shape); + blockPuzzlePart.OnDeviceRecycle(args.Shape); // 更新事件参数 args.IsHandled = true; @@ -390,7 +390,7 @@ namespace AibisDream blockShape.GetComponent().CurrentState = DragState.Idle; // 删除按钮 - blockPuzzlePanel.Panel.RemoveDeviceButton(selectedShapeName); + blockPuzzlePart.RemoveDeviceButton(selectedShapeName); selectedShapeName = null; }