From 07850fcf1c6f1bb63a3f7d84be0b567b04f2c91e Mon Sep 17 00:00:00 2001 From: Ding Yuntian <1491671119@qq.com> Date: Mon, 22 Jun 2026 19:02:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20BubbleSlotKit=20?= =?UTF-8?q?=E4=B8=8E=20VirtualCamRegistry=20=E9=9B=86=E4=B8=AD=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=B0=94=E6=B3=A1=E6=A7=BD=E4=BD=8D=E5=92=8C=E8=99=9A?= =?UTF-8?q?=E6=8B=9F=E7=9B=B8=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/FixSystem/Memory/MemoryProcess.cs | 10 +- .../BodyModule/BodyModuleSystem.cs | 10 +- .../FixSystemNew/BodyModule/CuttingManager.cs | 25 ----- .../FixSystemNew/Clinic/ClinicSystem.cs | 14 +-- .../Scripts/FixSystemNew/Open/OpenSystem.cs | 11 --- .../Screen System/Core/FixPanelSystem.cs | 13 --- .../Framework/OtherKit/BubbleSlotKit.cs | 94 +++++++++++++++++++ .../Framework/OtherKit/BubbleSlotKit.cs.meta | 11 +++ .../Scripts/Framework/OtherKit/CameraKit.cs | 12 +++ .../Framework/OtherKit/VirtualCamRegistry.cs | 38 ++++++++ .../OtherKit/VirtualCamRegistry.cs.meta | 11 +++ .../AnalysisModeManager.cs | 18 ---- .../MiniGame/HuoShan/Emo/EmoManager.cs | 7 -- .../HuoShan/Language/ExpressionManager.cs | 21 ----- .../HuoShan/SalesSystem/SalesManager.cs | 83 ---------------- .../Scripts/MiniGame/Peipei/Eye/EyeSystem.cs | 8 +- Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs | 4 - Assets/Scripts/MiniGame/Tarot/TarotManager.cs | 19 ++-- .../SceneCenter/OutsideCenter.cs | 8 +- .../SceneCenter/SubwayCenter.cs | 19 +--- .../UI/DialogUI/Bubbles/BubbleSlotGroup.cs | 22 +++++ 21 files changed, 209 insertions(+), 249 deletions(-) create mode 100644 Assets/Scripts/Framework/OtherKit/BubbleSlotKit.cs create mode 100644 Assets/Scripts/Framework/OtherKit/BubbleSlotKit.cs.meta create mode 100644 Assets/Scripts/Framework/OtherKit/VirtualCamRegistry.cs create mode 100644 Assets/Scripts/Framework/OtherKit/VirtualCamRegistry.cs.meta diff --git a/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs b/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs index b4653824a..86e8a24e4 100644 --- a/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs +++ b/Assets/Scripts/FixSystem/Memory/MemoryProcess.cs @@ -3,9 +3,8 @@ using UnityEngine; using DG.Tweening; using Yarn.Unity; using AibisDream.Framework; -using Cinemachine; -using UnityEngine.Rendering; using AibisDream.Kit; +using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; namespace AibisDream.FixSystem @@ -18,8 +17,6 @@ namespace AibisDream.FixSystem private const float SearchStartDelay = 1f; private const float ProjectorMoveDuration = 2f; - [SerializeField] private BubbleSlotGroup bubbleSlotGroup; - public BubbleSlotGroup BubbleSlotGroup => bubbleSlotGroup; [SerializeField] private GameObject memoryView; [SerializeField] private GameObject projector; [SerializeField] private SpriteRenderer memoryFinishedSpriteRenderer; // 用于显示记忆处理结束的表现 @@ -35,7 +32,6 @@ namespace AibisDream.FixSystem [SerializeField] private CanvasGroup playBackground; [SerializeField] private GameObject memoryGroup; - [SerializeField] private CinemachineVirtualCamera memoryCamera; private bool isProcessing = false; // 新增变量来追踪是否正在处理记忆 private bool isPlayingFaderSound = false; // 追踪音效是否正在播放 @@ -140,8 +136,6 @@ namespace AibisDream.FixSystem FixSystemCenter.SystemDic.Register(this); if (memoryGroup != null) memoryGroup.SetActive(false); - if (memoryCamera != null) - CameraKit.Instance.RegisterCamera(CameraEnum.Memory, memoryCamera); } @@ -215,7 +209,7 @@ namespace AibisDream.FixSystem /// /// 单条记忆播放结束后的复位:不调用 (避免再次锁条并触发打开 Timeline), - /// 仅禁用拖动;完整 仅在退出 执行。 + /// 仅禁用拖动;完整 仅在退出 执行。 /// private void ResetAfterMemoryFinished() { diff --git a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs index 8e752b7a9..21aa22189 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs @@ -1,11 +1,10 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Linq; -using AibisDream.Framework; -using Cinemachine; using JetBrains.Annotations; using UnityEngine; +using AibisDream.Framework; using AibisDream.Kit; using AibisDream.SaveSystem; @@ -74,16 +73,11 @@ namespace AibisDream.FixSystem // 注册到维修系统管理器 RepairSystemManager.Register(this); - - // 注册Camera - var virtualCam2 = transform.Find("Body Module Camera Center").GetComponent(); - CameraKit.Instance.RegisterCamera(CameraEnum.BodyModuleCenter, virtualCam2); } private void OnDestroy() { DeepRepairDataRegistry.UnregisterData(); - CameraKit.Instance.UnRegisterCamera(CameraEnum.BodyModuleCenter); } /// diff --git a/Assets/Scripts/FixSystemNew/BodyModule/CuttingManager.cs b/Assets/Scripts/FixSystemNew/BodyModule/CuttingManager.cs index 18df3d287..2e4cdcee2 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/CuttingManager.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/CuttingManager.cs @@ -1,7 +1,6 @@ using UnityEngine; using AibisDream.FixSystem; using Cinemachine; -using AibisDream.Framework; using DG.Tweening; using System.Collections; using AibisDream.Kit; @@ -10,7 +9,6 @@ namespace AibisDream { public class CuttingManager : MonoBehaviour { - public BubbleSlotGroup bubbleSlotGroup; [Header("切割组件")] public GameObject gearFollowerPrefab; public GameObject entrancePanelPrefab; // 入场面板预制体 @@ -30,21 +28,7 @@ namespace AibisDream private void Awake() { - // 注册 FixSystemCenter.SystemDic.Register(this); - var virtualCam1 = transform.Find("Cut Emo Camera").GetComponent(); - var virtualCam2 = transform.Find("Cut Memory Camera").GetComponent(); - var virtualCam3 = transform.Find("Cut Logic Camera").GetComponent(); - var virtualCam4 = transform.Find("Cut Emo Deep Camera").GetComponent(); - var virtualCam5 = transform.Find("Cut Memory Deep Camera").GetComponent(); - var virtualCam6 = transform.Find("Cut Logic Deep Camera").GetComponent(); - CameraKit.Instance.RegisterCamera(CameraEnum.CutEmo, virtualCam1); - CameraKit.Instance.RegisterCamera(CameraEnum.CutMemory, virtualCam2); - CameraKit.Instance.RegisterCamera(CameraEnum.CutLogic, virtualCam3); - CameraKit.Instance.RegisterCamera(CameraEnum.CutEmoDeep, virtualCam4); - CameraKit.Instance.RegisterCamera(CameraEnum.CutMemoryDeep, virtualCam5); - CameraKit.Instance.RegisterCamera(CameraEnum.CutLogicDeep, virtualCam6); - _mainCamera = Camera.main; } @@ -311,17 +295,8 @@ namespace AibisDream private void OnDestroy() { - // 从系统字典中注销 FixSystemCenter.SystemDic.Unregister(); - // 清理相机注册 - CameraKit.Instance.UnRegisterCamera(CameraEnum.CutEmo); - CameraKit.Instance.UnRegisterCamera(CameraEnum.CutMemory); - CameraKit.Instance.UnRegisterCamera(CameraEnum.CutLogic); - CameraKit.Instance.UnRegisterCamera(CameraEnum.CutEmoDeep); - CameraKit.Instance.UnRegisterCamera(CameraEnum.CutMemoryDeep); - CameraKit.Instance.UnRegisterCamera(CameraEnum.CutLogicDeep); - // 强制清理所有相关对象 if (gearFollower != null) { diff --git a/Assets/Scripts/FixSystemNew/Clinic/ClinicSystem.cs b/Assets/Scripts/FixSystemNew/Clinic/ClinicSystem.cs index af497a270..e8b462b96 100644 --- a/Assets/Scripts/FixSystemNew/Clinic/ClinicSystem.cs +++ b/Assets/Scripts/FixSystemNew/Clinic/ClinicSystem.cs @@ -1,28 +1,18 @@ using AibisDream.FixSystem; -using AibisDream.Framework; -using Cinemachine; using UnityEngine; namespace AibisDream { public class ClinicSystem : MonoBehaviour - { - [HideInInspector] public BubbleSlotGroup bubbleSlotGroup; - + { private void Awake() { FixSystemCenter.SystemDic.Register(this); - bubbleSlotGroup = transform.Find("Bubble Slot Group").GetComponent(); - - // 注册Camera - var clinicCam = transform.Find("Clinic Camera").GetComponent(); - CameraKit.Instance.RegisterCamera(CameraEnum.Clinic, clinicCam); } private void OnDestroy() { FixSystemCenter.SystemDic.Unregister(); - CameraKit.Instance.UnRegisterCamera(CameraEnum.Clinic); } } -} \ No newline at end of file +} diff --git a/Assets/Scripts/FixSystemNew/Open/OpenSystem.cs b/Assets/Scripts/FixSystemNew/Open/OpenSystem.cs index 842e7472d..1d8c9b449 100644 --- a/Assets/Scripts/FixSystemNew/Open/OpenSystem.cs +++ b/Assets/Scripts/FixSystemNew/Open/OpenSystem.cs @@ -1,6 +1,4 @@ using AibisDream.FixSystem; -using AibisDream.Framework; -using Cinemachine; using UnityEngine; using UnityEngine.Playables; using Yarn.Unity; @@ -18,18 +16,9 @@ namespace AibisDream public SpriteRenderer dreamSprite; - public BubbleSlotGroup bubbleSlotGroup; - private void Awake() { - // 注册 FixSystemCenter.SystemDic.Register(this); - var virtualCam = transform.Find("Op Camera").GetComponent(); - CameraKit.Instance.RegisterCamera(CameraEnum.Op, virtualCam); - var breakCam = transform.Find("Break Camera").GetComponent(); - CameraKit.Instance.RegisterCamera(CameraEnum.BreakCamera, breakCam); - var dreamCam = transform.Find("Dream Camera").GetComponent(); - CameraKit.Instance.RegisterCamera(CameraEnum.DreamCamera, dreamCam); } private void Start() diff --git a/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs index 4138dcd81..84c838a88 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs @@ -1,7 +1,6 @@ using AibisDream.Framework; using AibisDream.Kit; using UnityEngine; -using Cinemachine; using System.Collections; using DG.Tweening; @@ -127,13 +126,6 @@ namespace AibisDream.FixSystem #endregion #region 屏幕相关操作 - [Header("默认相机")] - [SerializeField] private CinemachineVirtualCamera fixPanelCamera; - - [Header("默认气泡")] - [SerializeField] private BubbleSlotGroup bubbleSlotGroup; - public BubbleSlotGroup BubbleSlotGroup => bubbleSlotGroup; - [Header("默认画布")] [SerializeField] private Canvas canvas; @@ -150,17 +142,12 @@ namespace AibisDream.FixSystem private void RegisterScreenView() { - // 注册相机 - CameraKit.Instance.RegisterCamera(CameraEnum.BodyModule, fixPanelCamera); - DialogUIManager.Instance.RegisterScreenView(DialogViewType.Screen, screenPanel); DialogUIManager.Instance.RegisterScreenView(DialogViewType.Task, taskPanel); } private void UnRegisterScreenView() { - CameraKit.Instance.UnRegisterCamera(CameraEnum.BodyModule); - DialogUIManager.Instance.UnRegisterScreenView(DialogViewType.Screen); DialogUIManager.Instance.UnRegisterScreenView(DialogViewType.Task); } diff --git a/Assets/Scripts/Framework/OtherKit/BubbleSlotKit.cs b/Assets/Scripts/Framework/OtherKit/BubbleSlotKit.cs new file mode 100644 index 000000000..b2ec388e5 --- /dev/null +++ b/Assets/Scripts/Framework/OtherKit/BubbleSlotKit.cs @@ -0,0 +1,94 @@ +using System.Collections.Generic; +using AibisDream.Kit; +using UnityEngine; + +namespace AibisDream.Framework +{ + public class BubbleSlotKit : Singleton + { + private readonly Dictionary _slotDict = new(); + + private BubbleSlotKit() + { + } + + public void Register(BubbleSlotEnum slotType, BubbleSlotGroup group) + { + if (slotType == BubbleSlotEnum.Default) + { + Debug.LogWarning("[BubbleSlotKit] 不能注册 Default 类型的气泡槽组。"); + return; + } + + if (_slotDict.TryGetValue(slotType, out var existing) && existing != null && existing != group) + { + Debug.LogWarning( + $"[BubbleSlotKit] {slotType} 已被 \"{existing.name}\" 注册,将被 \"{group.name}\" 覆盖"); + } + + _slotDict[slotType] = group; + } + + public void Unregister(BubbleSlotEnum slotType) + { + _slotDict.Remove(slotType); + } + + public void RemoveAll() + { + _slotDict.Clear(); + } + + public bool TryGet(BubbleSlotEnum slotType, out BubbleSlotGroup group) + { + if (_slotDict.TryGetValue(slotType, out group) && group != null) + { + return true; + } + + group = null; + return false; + } + + public BubbleSlotGroupData CollectData(BubbleSlotEnum slotType) + { + if (!TryGet(slotType, out var group)) + { + Debug.LogWarning($"[BubbleSlotKit] CollectData: {slotType} 气泡槽组未注册"); + return default; + } + + return group.CollectData(); + } + + public void LoadBubbles(BubbleSlotEnum slotType) + { + if (!TryGet(slotType, out var group)) + { + Debug.LogWarning($"[BubbleSlotKit] LoadBubbles: {slotType} 气泡槽组未注册"); + return; + } + + DialogUIManager.Instance.LoadBubbles(group.CollectData()); + } + } + + public enum BubbleSlotEnum + { + Default, + Clinic, + BodyModule, + Memory, + Eye, + Cut, + Open, + Sales, + Subway, + SubwayTV, + Outside, + Tarot, + Emo, + Expression, + Analysis + } +} diff --git a/Assets/Scripts/Framework/OtherKit/BubbleSlotKit.cs.meta b/Assets/Scripts/Framework/OtherKit/BubbleSlotKit.cs.meta new file mode 100644 index 000000000..47b9f9869 --- /dev/null +++ b/Assets/Scripts/Framework/OtherKit/BubbleSlotKit.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a8f3c2e1b94d4f6a9e7d5c3b2a10876f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Framework/OtherKit/CameraKit.cs b/Assets/Scripts/Framework/OtherKit/CameraKit.cs index e9fca1621..3cb1fd0a5 100644 --- a/Assets/Scripts/Framework/OtherKit/CameraKit.cs +++ b/Assets/Scripts/Framework/OtherKit/CameraKit.cs @@ -93,6 +93,18 @@ namespace AibisDream.Framework public void RegisterCamera(CameraEnum camType, ICinemachineCamera virtualCamera) { + if (_virtualCameraDict.TryGetValue(camType, out var existing) && existing != virtualCamera) + { + var existingName = existing?.VirtualCameraGameObject != null + ? existing.VirtualCameraGameObject.name + : "unknown"; + var newName = virtualCamera?.VirtualCameraGameObject != null + ? virtualCamera.VirtualCameraGameObject.name + : "unknown"; + Debug.LogWarning( + $"RegisterCamera: {camType} 已被 \"{existingName}\" 注册,将被 \"{newName}\" 覆盖"); + } + _virtualCameraDict[camType] = virtualCamera; var vcam = virtualCamera.VirtualCameraGameObject.GetComponent(); diff --git a/Assets/Scripts/Framework/OtherKit/VirtualCamRegistry.cs b/Assets/Scripts/Framework/OtherKit/VirtualCamRegistry.cs new file mode 100644 index 000000000..57c361b49 --- /dev/null +++ b/Assets/Scripts/Framework/OtherKit/VirtualCamRegistry.cs @@ -0,0 +1,38 @@ +using Cinemachine; +using UnityEngine; + +namespace AibisDream.Framework +{ + [RequireComponent(typeof(CinemachineVirtualCamera))] + public class VirtualCamRegistry : MonoBehaviour + { + [SerializeField] private CameraEnum cameraType; + + private void Awake() + { + if (cameraType == CameraEnum.Default) + { + Debug.LogWarning($"[{nameof(VirtualCamRegistry)}] cameraType 不能为 Default,请在 Inspector 配置。", this); + return; + } + + if (!TryGetComponent(out var virtualCam)) + { + Debug.LogWarning($"[{nameof(VirtualCamRegistry)}] 未找到 ICinemachineCamera 组件。", this); + return; + } + + CameraKit.Instance.RegisterCamera(cameraType, virtualCam); + } + + private void OnDestroy() + { + if (cameraType == CameraEnum.Default) + { + return; + } + + CameraKit.Instance?.UnRegisterCamera(cameraType); + } + } +} diff --git a/Assets/Scripts/Framework/OtherKit/VirtualCamRegistry.cs.meta b/Assets/Scripts/Framework/OtherKit/VirtualCamRegistry.cs.meta new file mode 100644 index 000000000..e02f592d8 --- /dev/null +++ b/Assets/Scripts/Framework/OtherKit/VirtualCamRegistry.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7432789ba6bd1a340b824676e1e56184 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/MiniGame/HuoShan/AnalysisSystem_Archived/AnalysisModeManager.cs b/Assets/Scripts/MiniGame/HuoShan/AnalysisSystem_Archived/AnalysisModeManager.cs index a784a6753..0955eff59 100644 --- a/Assets/Scripts/MiniGame/HuoShan/AnalysisSystem_Archived/AnalysisModeManager.cs +++ b/Assets/Scripts/MiniGame/HuoShan/AnalysisSystem_Archived/AnalysisModeManager.cs @@ -6,8 +6,6 @@ using System.Linq; using DG.Tweening; using Shapes; using AibisDream.FixSystem; -using AibisDream.Framework; -using Cinemachine; namespace AibisDream.MiniGame.Language { @@ -137,7 +135,6 @@ namespace AibisDream.MiniGame.Language /// public class AnalysisModeManager : MonoBehaviour { - public BubbleSlotGroup bubbleSlotGroup; [Header("Canvas 引用(共享)")] [SerializeField] private Canvas sharedCanvas; // 共享 LanguageParticleManager 的 canvas @@ -225,25 +222,10 @@ namespace AibisDream.MiniGame.Language private void Start() { - // 注册到系统字典 FixSystemCenter.SystemDic.Register(this); - - // 注册相机 - var virtualCam = transform.Find("Analysis Camera")?.GetComponent(); - if (virtualCam != null) - { - CameraKit.Instance.RegisterCamera(CameraEnum.AnalysisMode, virtualCam); - } - SetupUI(); } - private void OnDestroy() - { - CameraKit.Instance?.UnRegisterCamera(CameraEnum.AnalysisMode); - CameraKit.Instance?.UnRegisterCamera(CameraEnum.AnalysisModeDeep); - } - /// /// 进入分析模式(由状态机调用) /// diff --git a/Assets/Scripts/MiniGame/HuoShan/Emo/EmoManager.cs b/Assets/Scripts/MiniGame/HuoShan/Emo/EmoManager.cs index d423d45cd..3fe1d09af 100644 --- a/Assets/Scripts/MiniGame/HuoShan/Emo/EmoManager.cs +++ b/Assets/Scripts/MiniGame/HuoShan/Emo/EmoManager.cs @@ -1,13 +1,10 @@ using UnityEngine; using AibisDream.FixSystem; -using Cinemachine; -using AibisDream.Framework; namespace AibisDream { public class EmoManager : MonoBehaviour { - public BubbleSlotGroup bubbleSlotGroup; private GameObject emoView; void Start() @@ -15,10 +12,6 @@ namespace AibisDream FixSystemCenter.SystemDic.Register(this); emoView = transform.Find("Emo View").gameObject; emoView.SetActive(false); - var virtualCam = transform.Find("Emo Camera").GetComponent(); - var virtualCam2 = transform.Find("Emo Deep Camera").GetComponent(); - CameraKit.Instance.RegisterCamera(CameraEnum.Emo, virtualCam); - CameraKit.Instance.RegisterCamera(CameraEnum.EmoDeep, virtualCam2); } public void OpenView() diff --git a/Assets/Scripts/MiniGame/HuoShan/Language/ExpressionManager.cs b/Assets/Scripts/MiniGame/HuoShan/Language/ExpressionManager.cs index 811ad7b33..ee27d806d 100644 --- a/Assets/Scripts/MiniGame/HuoShan/Language/ExpressionManager.cs +++ b/Assets/Scripts/MiniGame/HuoShan/Language/ExpressionManager.cs @@ -2,8 +2,6 @@ using System.Collections; using DG.Tweening; using UnityEngine; using AibisDream.FixSystem; -using Cinemachine; -using AibisDream.Framework; using AibisDream.MiniGame.Language; using System.Collections.Generic; @@ -14,7 +12,6 @@ namespace AibisDream /// public class ExpressionManager : MonoBehaviour { - public BubbleSlotGroup bubbleSlotGroup; [Header("系统组件")] [SerializeField] private LanguageParticleManager particleManager; [SerializeField] private GameObject expressionView; @@ -61,19 +58,6 @@ namespace AibisDream { glitchController = GetComponentInChildren(true); } - - // 注册相机 - var virtualCam = transform.Find("Expression Camera")?.GetComponent(); - if (virtualCam != null) - { - CameraKit.Instance.RegisterCamera(CameraEnum.Expression, virtualCam); - } - - var virtualCam2 = transform.Find("Expression Deep Camera")?.GetComponent(); - if (virtualCam2 != null) - { - CameraKit.Instance.RegisterCamera(CameraEnum.ExpressionDeep, virtualCam2); - } } /// @@ -251,10 +235,5 @@ namespace AibisDream yield return glitchController.StartCoroutine(glitchController.TransitionToAndWait(to, duration)); } - private void OnDestroy() - { - CameraKit.Instance?.UnRegisterCamera(CameraEnum.Expression); - CameraKit.Instance?.UnRegisterCamera(CameraEnum.ExpressionDeep); - } } } \ No newline at end of file diff --git a/Assets/Scripts/MiniGame/HuoShan/SalesSystem/SalesManager.cs b/Assets/Scripts/MiniGame/HuoShan/SalesSystem/SalesManager.cs index 423f85f11..16d2e3682 100644 --- a/Assets/Scripts/MiniGame/HuoShan/SalesSystem/SalesManager.cs +++ b/Assets/Scripts/MiniGame/HuoShan/SalesSystem/SalesManager.cs @@ -1,9 +1,7 @@ using UnityEngine; using UnityEngine.Events; -using Cinemachine; using AibisDream; using AibisDream.FixSystem; -using AibisDream.Framework; using System.Collections; using System.Collections.Generic; using DG.Tweening; @@ -26,15 +24,6 @@ namespace AibisDream.MiniGame.Language [Tooltip("销售系统主视图对象(会自动查找名为'SaleView'或'SellView'的子对象)")] [SerializeField] private GameObject saleView; - [HideInInspector] public BubbleSlotGroup bubbleSlotGroup; - - [Header("相机配置")] - [Tooltip("主销售相机")] - [SerializeField] private CameraEnum mainCamera = CameraEnum.SaleCamera; - - [Tooltip("深度销售相机(可选)")] - [SerializeField] private CameraEnum deepCamera = CameraEnum.SaleDeepCamera; - [Header("销售模块深入 - Crank 与 Slider 协调")] [Tooltip("发条控制器(不填则从 saleView 下查找)")] [SerializeField] private CrankController crankController; @@ -90,7 +79,6 @@ namespace AibisDream.MiniGame.Language [Tooltip("盖子淡出时长")] [SerializeField] private float coverFadeDuration = 0.5f; - private readonly List registeredCameras = new(); private bool _isProcessorDeepMode; private Vector3 _saleViewOriginalPos; private Vector3 _saleViewOriginalScale; @@ -139,26 +127,9 @@ namespace AibisDream.MiniGame.Language sliderController?.SetControlActive(true); } - private void Awake() - { - // 对话气泡槽组(SaleSystem 下名为 "Bubble Slots" 的 GameObject) - var bubbleSlots = transform.Find("Bubble Slots"); - if (bubbleSlots != null) - { - bubbleSlotGroup = bubbleSlots.GetComponent(); - if (bubbleSlotGroup == null) - Debug.LogWarning("[SalesManager] 找到 'Bubble Slots' 但无 BubbleSlotGroup 组件", this); - } - else - { - Debug.LogWarning("[SalesManager] 未找到名为 'Bubble Slots' 的子对象,对话气泡将无法显示", this); - } - } - private void Start() { RegisterToSystem(); - RegisterCameras(); FindSaleView(); FindSaleViewEnterAnimation(); FindCrankController(); @@ -171,7 +142,6 @@ namespace AibisDream.MiniGame.Language private void OnDestroy() { _deepModeSequence?.Kill(); - UnregisterCameras(); UnsubscribeFromCrankSlider(); } @@ -347,59 +317,6 @@ namespace AibisDream.MiniGame.Language FixSystemCenter.SystemDic.Register(this); } - /// - /// 注册所有相机到CameraKit - /// - private void RegisterCameras() - { - if (CameraKit.Instance == null) - { - Debug.LogError("[SalesManager] CameraKit.Instance 为 null,无法注册相机!"); - return; - } - - // 获取所有相机 - var virtualCams = GetComponentsInChildren(); - - if (virtualCams.Length == 0) - { - Debug.LogWarning("[SalesManager] 未找到任何 ICinemachineCamera 组件!"); - return; - } - - // 注册主相机 - if (virtualCams.Length > 0) - { - CameraKit.Instance.RegisterCamera(mainCamera, virtualCams[0]); - registeredCameras.Add(mainCamera); - Debug.Log($"[SalesManager] 成功注册主相机: {mainCamera}"); - } - - // 注册深度相机(如果有) - if (virtualCams.Length > 1) - { - CameraKit.Instance.RegisterCamera(deepCamera, virtualCams[1]); - registeredCameras.Add(deepCamera); - Debug.Log($"[SalesManager] 成功注册深度相机: {deepCamera}"); - } - } - - /// - /// 从CameraKit注销所有相机 - /// - private void UnregisterCameras() - { - if (CameraKit.Instance == null) return; - - foreach (var cameraType in registeredCameras) - { - CameraKit.Instance.UnRegisterCamera(cameraType); - Debug.Log($"[SalesManager] 已注销相机: {cameraType}"); - } - - registeredCameras.Clear(); - } - /// /// 打开销售系统界面 /// diff --git a/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs b/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs index 38d24228e..a0a93d46e 100644 --- a/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs +++ b/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs @@ -7,9 +7,8 @@ using Yarn.Unity; using System.Linq; using UnityEngine.UI; using AibisDream.FixSystem; -using AibisDream.SaveSystem; -using Cinemachine; using AibisDream.Framework; +using AibisDream.SaveSystem; using AibisDream.Kit; using UnityEngine.ResourceManagement.AsyncOperations; using Sequence = DG.Tweening.Sequence; @@ -20,7 +19,6 @@ namespace AibisDream { private const string MemorySpritePath = "Sprite/Memory/{0}.png"; - public BubbleSlotGroup bubbleSlotGroup; [SerializeField] private List targets = new(); // 保存目标列表 public List Targets => targets; // 提供目标列表的公共访问 private EyeTarget currentTarget; // 当前选中的目标 @@ -73,10 +71,6 @@ namespace AibisDream public void Init() { FixSystemCenter.SystemDic.Register(this); - var virtualCam = transform.Find("Eye Camera").GetComponent(); - var virtualCamDeep = transform.Find("Eye DeepCamera").GetComponent(); - CameraKit.Instance.RegisterCamera(CameraEnum.Eye, virtualCam); - CameraKit.Instance.RegisterCamera(CameraEnum.EyeDeep, virtualCamDeep); DeepRepairDataRegistry.RegisterData(_eyeData); // 添加加载逻辑 _eyeData.LoadEvent += LoadData; diff --git a/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs b/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs index 8f7f8d356..75cf17eee 100644 --- a/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs +++ b/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using UnityEngine; using AibisDream; using AibisDream.FixSystem; -using AibisDream.Framework; -using Cinemachine; using UnityEngine.Rendering; using Yarn.Unity; using DG.Tweening; @@ -46,8 +44,6 @@ public class UFSystem : MonoBehaviour private void Awake() { FixSystemCenter.SystemDic.Register(this); - var virtualCam = transform.Find("UF Camera").GetComponent(); - CameraKit.Instance.RegisterCamera(CameraEnum.UF, virtualCam); eyeSystem = FindObjectOfType(); } diff --git a/Assets/Scripts/MiniGame/Tarot/TarotManager.cs b/Assets/Scripts/MiniGame/Tarot/TarotManager.cs index f15cdd0df..bc274373b 100644 --- a/Assets/Scripts/MiniGame/Tarot/TarotManager.cs +++ b/Assets/Scripts/MiniGame/Tarot/TarotManager.cs @@ -1,6 +1,7 @@ using System.Collections; using AibisDream; using AibisDream.FixSystem; +using AibisDream.Framework; using UnityEngine; namespace AibisDream.MiniGame.Tarot @@ -16,9 +17,7 @@ namespace AibisDream.MiniGame.Tarot [SerializeField] private Sprite backSprite; [Header("Dialogue Bubbles")] - [Tooltip("塔罗流程中使用的气泡槽位;不指定则进入塔罗时不切换气泡。")] - [SerializeField] private BubbleSlotGroup tarotBubbleSlotGroup; - [Tooltip("本场景普通对话的气泡槽位,用于退出塔罗时恢复;不填则尝试 OutsideCenter / FixPanelSystem。")] + [Tooltip("退出塔罗时恢复的气泡槽位;不填则尝试 Outside / BodyModule。")] [SerializeField] private BubbleSlotGroup restoreBubbleSlotGroup; private TarotDeck _deck; @@ -176,21 +175,21 @@ namespace AibisDream.MiniGame.Tarot private void TryEnterTarotBubbleMode() { - if (tarotBubbleSlotGroup == null) + if (!BubbleSlotKit.Instance.TryGet(BubbleSlotEnum.Tarot, out _)) return; var snapshot = CollectRestoreSnapshot(); if (snapshot.bubbleSlots == null || snapshot.bubbleSlots.Length == 0) { Debug.LogWarning( - "[TarotManager] 已配置塔罗气泡但无法取得有效的恢复快照(请指定 restoreBubbleSlotGroup 或保证 OutsideCenter/FixPanelSystem 气泡可用),跳过气泡切换。", + "[TarotManager] 已配置 Tarot 气泡但无法取得有效的恢复快照(请指定 restoreBubbleSlotGroup 或保证 Outside/BodyModule 气泡已注册),跳过气泡切换。", this); return; } _savedBubbleData = snapshot; _bubbleSwapActive = true; - DialogUIManager.Instance.LoadBubbles(tarotBubbleSlotGroup.CollectData()); + BubbleSlotKit.Instance.LoadBubbles(BubbleSlotEnum.Tarot); } private void RestoreTarotBubbleMode() @@ -206,11 +205,11 @@ namespace AibisDream.MiniGame.Tarot if (restoreBubbleSlotGroup != null) return restoreBubbleSlotGroup.CollectData(); - if (OutsideCenter.Instance != null && OutsideCenter.Instance.bubbleSlotGroup != null) - return OutsideCenter.Instance.bubbleSlotGroup.CollectData(); + if (BubbleSlotKit.Instance.TryGet(BubbleSlotEnum.Outside, out _)) + return BubbleSlotKit.Instance.CollectData(BubbleSlotEnum.Outside); - if (FixPanelSystem.Instance != null && FixPanelSystem.Instance.BubbleSlotGroup != null) - return FixPanelSystem.Instance.BubbleSlotGroup.CollectData(); + if (BubbleSlotKit.Instance.TryGet(BubbleSlotEnum.BodyModule, out _)) + return BubbleSlotKit.Instance.CollectData(BubbleSlotEnum.BodyModule); return default; } diff --git a/Assets/Scripts/SceneManagement/SceneCenter/OutsideCenter.cs b/Assets/Scripts/SceneManagement/SceneCenter/OutsideCenter.cs index 289989196..46ebaa393 100644 --- a/Assets/Scripts/SceneManagement/SceneCenter/OutsideCenter.cs +++ b/Assets/Scripts/SceneManagement/SceneCenter/OutsideCenter.cs @@ -1,15 +1,13 @@ -using AibisDream.Kit; +using AibisDream.Framework; +using AibisDream.Kit; namespace AibisDream { public class OutsideCenter : Singleton { - public BubbleSlotGroup bubbleSlotGroup; - public override void OnSingletonInit() { - // 加载气泡 - DialogUIManager.Instance.LoadBubbles(bubbleSlotGroup.CollectData()); + BubbleSlotKit.Instance.LoadBubbles(BubbleSlotEnum.Outside); } } } diff --git a/Assets/Scripts/SceneManagement/SceneCenter/SubwayCenter.cs b/Assets/Scripts/SceneManagement/SceneCenter/SubwayCenter.cs index 319242159..ba84e7424 100644 --- a/Assets/Scripts/SceneManagement/SceneCenter/SubwayCenter.cs +++ b/Assets/Scripts/SceneManagement/SceneCenter/SubwayCenter.cs @@ -2,7 +2,6 @@ using System.Collections; using AibisDream.Framework; using AibisDream.Kit; -using Cinemachine; using UnityEngine; using UnityEngine.Playables; using UnityEngine.ResourceManagement.AsyncOperations; @@ -14,11 +13,6 @@ namespace AibisDream { #region 部分索引 - public BubbleSlotGroup subwaySlots; - public BubbleSlotGroup tvSlots; - - public CinemachineVirtualCamera subwayCam; - public CinemachineVirtualCamera tvCam; public SpriteRenderer newsSpriteRenderer; public PlayableDirector arriveStation; @@ -29,19 +23,10 @@ namespace AibisDream public override void OnSingletonInit() { - CameraKit.Instance.RegisterCamera(CameraEnum.Subway, subwayCam); - CameraKit.Instance.RegisterCamera(CameraEnum.SubwayTV, tvCam); - StateMachine = new StateMachine(CreateState); StartCoroutine(StateMachine.Init(OutSideState.Subway)); } - public override void OnSingletonDestroy() - { - CameraKit.Instance.UnRegisterCamera(CameraEnum.SubwayTV); - CameraKit.Instance.UnRegisterCamera(CameraEnum.Subway); - } - private static IState CreateState(OutSideState nextState, string arg = "") { IState res = nextState switch @@ -96,7 +81,7 @@ namespace AibisDream public IEnumerator Enter() { yield return CameraKit.Instance.SwitchCamera(CameraEnum.Subway); - DialogUIManager.Instance.LoadBubbles(SubwayCenter.Instance.subwaySlots.CollectData()); + DialogUIManager.Instance.LoadBubbles(BubbleSlotKit.Instance.CollectData(BubbleSlotEnum.Subway)); } } @@ -108,7 +93,7 @@ namespace AibisDream { yield return CameraKit.Instance.SwitchCamera(CameraEnum.SubwayTV); // 要加载气泡吗? - DialogUIManager.Instance.LoadBubbles(SubwayCenter.Instance.tvSlots.CollectData()); + DialogUIManager.Instance.LoadBubbles(BubbleSlotKit.Instance.CollectData(BubbleSlotEnum.SubwayTV)); } } diff --git a/Assets/Scripts/UI/DialogUI/Bubbles/BubbleSlotGroup.cs b/Assets/Scripts/UI/DialogUI/Bubbles/BubbleSlotGroup.cs index d6f2f053b..8830848c5 100644 --- a/Assets/Scripts/UI/DialogUI/Bubbles/BubbleSlotGroup.cs +++ b/Assets/Scripts/UI/DialogUI/Bubbles/BubbleSlotGroup.cs @@ -1,13 +1,35 @@ using System; using System.Linq; +using AibisDream.Framework; using UnityEngine; namespace AibisDream { public class BubbleSlotGroup : MonoBehaviour { + [SerializeField] private BubbleSlotEnum slotKey; [SerializeField] private BubbleSlotGroupData data; + private void Awake() + { + if (slotKey == BubbleSlotEnum.Default) + { + return; + } + + BubbleSlotKit.Instance.Register(slotKey, this); + } + + private void OnDestroy() + { + if (slotKey == BubbleSlotEnum.Default) + { + return; + } + + BubbleSlotKit.Instance?.Unregister(slotKey); + } + public BubbleSlotGroupData CollectData() { // 获取子类