From b05e59f5645a3ec31e3271f8a287210648d5cafc Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Fri, 6 Mar 2026 18:31:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(fix-system):=20=E9=87=8D=E6=9E=84BlockPuzz?= =?UTF-8?q?le=E7=B3=BB=E7=BB=9F=EF=BC=8C=E5=AE=8C=E5=96=84=E7=9F=B3?= =?UTF-8?q?=E5=A4=B4=E7=BB=B4=E4=BF=AE=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/FixSystemNew/FixStateMachine.cs | 21 ++++++++++++++----- .../Scripts/Framework/OtherKit/CameraKit.cs | 5 +---- .../BlockPuzzle/Class/BlockPuzzleKit.cs | 16 +++++++------- .../BlockPuzzle/Class/BlockPuzzleSystem.cs | 20 ++++++++++++------ .../BlockPuzzle/Class/ShapeDragger.cs | 1 - 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/Assets/Scripts/FixSystemNew/FixStateMachine.cs b/Assets/Scripts/FixSystemNew/FixStateMachine.cs index 630b9937d..c938d0b32 100644 --- a/Assets/Scripts/FixSystemNew/FixStateMachine.cs +++ b/Assets/Scripts/FixSystemNew/FixStateMachine.cs @@ -675,6 +675,7 @@ namespace AibisDream.FixSystem public struct BlockPuzzleState : IState { private const string puzzleName = "Game2"; + private static BlockPuzzleSystem BlockPuzzleSystem => FixSystemCenter.SystemDic.Get(); public FixState GetState => FixState.BlockPuzzle; @@ -684,11 +685,21 @@ namespace AibisDream.FixSystem public IEnumerator Enter() { - yield return CameraKit.Instance.SwitchCamera(CameraEnum.BlockPuzzle); - if (!string.IsNullOrEmpty(puzzleName)) - { - BlockPuzzleYarnCommand.InitBlockPuzzle(puzzleName); - } + // 基本操作(其实应该早就处理好了) + yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule); + var bubbleData = FixPanelSystem.Instance.BubbleSlotGroup.CollectData(); + DialogUIManager.Instance.LoadBubbles(bubbleData); + // 开启遮罩 + yield return FixPanelSystem.Instance.MaskFadeIn(0.5f); + // 初始化系统并入场 + BlockPuzzleSystem.Initialize(puzzleName); + + // 播放进场动画 + yield return TimelineCenter.Instance.PlayTimelineAsync(TimelineAssetRef.CablePanelExit); + yield return new WaitForSeconds(0.5f); + yield return TimelineCenter.Instance.PlayTimelineAsync(TimelineAssetRef.BlockPuzzleEnter); + // 解锁 + BlockPuzzleSystem.SetLocked(false); } public IEnumerator Exit() diff --git a/Assets/Scripts/Framework/OtherKit/CameraKit.cs b/Assets/Scripts/Framework/OtherKit/CameraKit.cs index a12882f95..530e864e4 100644 --- a/Assets/Scripts/Framework/OtherKit/CameraKit.cs +++ b/Assets/Scripts/Framework/OtherKit/CameraKit.cs @@ -403,8 +403,6 @@ namespace AibisDream.Framework Eye, UF, Expression, - Engine, - Gear, EyeDeep, ExpressionDeep, Emo, @@ -423,7 +421,6 @@ namespace AibisDream.Framework Language, LanguageDeep, AnalysisMode, - AnalysisModeDeep, - BlockPuzzle, + AnalysisModeDeep } } \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleKit.cs b/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleKit.cs index 72bcb426d..c1fa37fea 100644 --- a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleKit.cs +++ b/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleKit.cs @@ -4,6 +4,7 @@ using System.IO; using Newtonsoft.Json; using AibisDream.Utility; using AibisDream.Framework; +using AibisDream.FixSystem; using UnityEngine; using Yarn.Unity; @@ -584,13 +585,14 @@ namespace AibisDream public static class BlockPuzzleYarnCommand { + private static BlockPuzzleSystem BlockPuzzleSystem => FixSystemCenter.SystemDic.Get(); + [YarnCommand("init_block_puzzle")] public static void InitBlockPuzzle(string puzzleName) { if (BlockPuzzleKit.TryLoadBlockPuzzleData(puzzleName, out var blockPuzzleData)) { - BlockPuzzleSystem.Instance.Initialize(blockPuzzleData); - // BlockPuzzleSystem.Instance.SetLocked(true); + BlockPuzzleSystem.Initialize(blockPuzzleData); } else { @@ -601,31 +603,31 @@ namespace AibisDream [YarnCommand("load_shape_rack")] public static void LoadShapeRack() { - BlockPuzzleSystem.Instance.LoadShapeRack(); + BlockPuzzleSystem.LoadShapeRack(); } [YarnCommand("switch_block_puzzle_state")] public static void PlayShapeAnimation(string triggerName) { - BlockPuzzleSystem.Instance.PlayShapeAnimation(triggerName); + BlockPuzzleSystem.PlayShapeAnimation(triggerName); } [YarnCommand("unlock_block_puzzle_system")] public static void UnlockSystem() { - BlockPuzzleSystem.Instance.SetLocked(false); + BlockPuzzleSystem.SetLocked(false); } [YarnCommand("enable_drag")] public static void EnableDrag() { - BlockPuzzleSystem.Instance.EnableDrag(); + BlockPuzzleSystem.EnableDrag(); } [YarnCommand("clear_block_puzzle")] public static void ClearBlockPuzzle() { - BlockPuzzleSystem.Instance.ClearGame(); + BlockPuzzleSystem.ClearGame(); } } diff --git a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleSystem.cs b/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleSystem.cs index 5281478dc..65d1d1e82 100644 --- a/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleSystem.cs +++ b/Assets/Scripts/MiniGame/BlockPuzzle/Class/BlockPuzzleSystem.cs @@ -1,5 +1,4 @@ using UnityEngine; -using Cinemachine; using AibisDream.Kit; using AibisDream.Utility; using System.Linq; @@ -9,7 +8,7 @@ using UnityEngine.EventSystems; namespace AibisDream { - public class BlockPuzzleSystem : Singleton + public class BlockPuzzleSystem : MonoBehaviour { [Header("物体索引")] // 物体索引 @@ -41,14 +40,23 @@ namespace AibisDream { Initialize(); } - - CameraKit.Instance?.RegisterCamera(CameraEnum.BlockPuzzle, GetComponentInChildren()); } - public override void OnSingletonDestroy() + private void OnDestroy() { FixSystemCenter.SystemDic.Unregister(); - CameraKit.Instance?.UnRegisterCamera(CameraEnum.BlockPuzzle); + } + + public void Initialize(string puzzleName) + { + if (BlockPuzzleKit.TryLoadBlockPuzzleData(puzzleName, out var blockPuzzleData)) + { + Initialize(blockPuzzleData); + } + else + { + Debug.LogError($"加载 BlockPuzzleData 失败: {puzzleName}"); + } } public void Initialize(BlockPuzzleData puzzleData) diff --git a/Assets/Scripts/MiniGame/BlockPuzzle/Class/ShapeDragger.cs b/Assets/Scripts/MiniGame/BlockPuzzle/Class/ShapeDragger.cs index 37bc047a1..bb04f1fc5 100644 --- a/Assets/Scripts/MiniGame/BlockPuzzle/Class/ShapeDragger.cs +++ b/Assets/Scripts/MiniGame/BlockPuzzle/Class/ShapeDragger.cs @@ -60,7 +60,6 @@ namespace AibisDream public bool IsInteractable { get => isInteractable; set => isInteractable = value; } public InteractionMode InteractionMode { get => interactionMode; set => interactionMode = value; } - public IBlockPuzzleGrid TargetGrid => BlockPuzzleSystem.Instance.grid; public IBlockShape BlockShape => _blockShape; #region 事件定义