diff --git a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs index e12cf6e70..26868bb35 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/BodyModuleSystem.cs @@ -68,6 +68,9 @@ namespace AibisDream.FixSystem FixSystemCenter.SystemDic.Register(this); + // 注册到维修系统管理器 + RepairSystemManager.Register(this); + // 注册Camera var virtualCam2 = transform.Find("Body Module Camera Center").GetComponent(); CameraKit.Instance.RegisterCamera(CameraEnum.BodyModuleCenter, virtualCam2); diff --git a/Assets/Scripts/FixSystemNew/BodyModule/Modules/UFModule.cs b/Assets/Scripts/FixSystemNew/BodyModule/Modules/UFModule.cs index d5732f6f8..c80038434 100644 --- a/Assets/Scripts/FixSystemNew/BodyModule/Modules/UFModule.cs +++ b/Assets/Scripts/FixSystemNew/BodyModule/Modules/UFModule.cs @@ -1,20 +1,19 @@ -using UnityEngine; +using UnityEngine; using AibisDream.Framework; using AibisDream; using System; using System.Collections; -using AibisDream.FixSystem; public class UFModule : MonoBehaviour { private GameObject _ufCover; private GameObject _ufModule; - private GameObject _ufSocket; + private GameObject _ufSocket; private GameObject _ufColor; - private UFData _ufData=new (); - + private UFData _ufData = new(); + private void Awake() { // 将数据注册到数据容器内 @@ -24,9 +23,8 @@ public class UFModule : MonoBehaviour _ufModule = transform.Find("Module Pic").gameObject; _ufSocket = transform.Find("Socket").gameObject; _ufCover = _ufModule.transform.Find("Cover").gameObject; - _ufColor=_ufModule.transform.Find("Color").gameObject; + _ufColor = _ufModule.transform.Find("Color").gameObject; } - // Start is called before the first frame update public void RemoveUFCover() { @@ -44,7 +42,7 @@ public class UFModule : MonoBehaviour { _ufModule.SetActive(false); _ufSocket.SetActive(false); - + } _ufData.isUFRemoved = true; @@ -79,7 +77,7 @@ public class UFModule : MonoBehaviour _ufData.isColorRemoved = false; } - public void RemoveUFColor() + public void RemoveUFColor() { if (_ufColor.activeInHierarchy) { diff --git a/Assets/Scripts/FixSystemNew/Cable/PhysicCable.cs b/Assets/Scripts/FixSystemNew/Cable/PhysicCable.cs index aa7fa4da1..4d4ccda5d 100644 --- a/Assets/Scripts/FixSystemNew/Cable/PhysicCable.cs +++ b/Assets/Scripts/FixSystemNew/Cable/PhysicCable.cs @@ -44,9 +44,19 @@ public class PhysicCable : MonoBehaviour private void Update() { - if (isEnabled && targetTransform != null) + if (isEnabled) { - physicLine.UpdatePlug(targetTransform); + // 更新起点位置 + if (startTransform != null) + { + physicLine.UpdateStart(startTransform.position); + } + + // 更新终点位置 + if (targetTransform != null) + { + physicLine.UpdatePlug(targetTransform); + } } } } \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/Cable/PhysicLineSegment.cs b/Assets/Scripts/FixSystemNew/Cable/PhysicLineSegment.cs index 3c11fac23..6eba7eff1 100644 --- a/Assets/Scripts/FixSystemNew/Cable/PhysicLineSegment.cs +++ b/Assets/Scripts/FixSystemNew/Cable/PhysicLineSegment.cs @@ -92,4 +92,12 @@ public class PhysicLineSegment : MonoBehaviour plug.position = plugPosition + direction.normalized * (plugLength / 2); } } + + public void UpdateStart(Vector3 newStartPosition) + { + if (particles.Count > 0) + { + particles[0].position = newStartPosition; + } + } } \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/FixStateMachine.cs b/Assets/Scripts/FixSystemNew/FixStateMachine.cs index c938d0b32..e64c890d3 100644 --- a/Assets/Scripts/FixSystemNew/FixStateMachine.cs +++ b/Assets/Scripts/FixSystemNew/FixStateMachine.cs @@ -3,6 +3,7 @@ using System.Collections; using AibisDream.Framework; using AibisDream.Kit; using AibisDream.UI; +using DG.Tweening; using UnityEngine; namespace AibisDream.FixSystem @@ -632,7 +633,7 @@ namespace AibisDream.FixSystem public IEnumerator Enter() { var bodyModuleSystem = FixSystemCenter.SystemDic.Get(); - var analysisModeManager = FixSystemCenter.SystemDic.Get(); + var analysisModeManager = FixSystemCenter.SystemDic.Get(); // 先切 BodyModule(如果需要) if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule)) @@ -658,7 +659,7 @@ namespace AibisDream.FixSystem public IEnumerator Exit() { float duration = 0.5f; - var analysisModeManager = FixSystemCenter.SystemDic.Get(); + var analysisModeManager = FixSystemCenter.SystemDic.Get(); yield return UIManager.Instance.GetPanel().FadeInAsync(duration); @@ -675,7 +676,9 @@ namespace AibisDream.FixSystem public struct BlockPuzzleState : IState { private const string puzzleName = "Game2"; + private const float blockPuzzleScale = 1.6f; private static BlockPuzzleSystem BlockPuzzleSystem => FixSystemCenter.SystemDic.Get(); + private static BodyModuleSystem BodyModuleSystem => FixSystemCenter.SystemDic.Get(); public FixState GetState => FixState.BlockPuzzle; @@ -689,10 +692,21 @@ namespace AibisDream.FixSystem yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule); var bubbleData = FixPanelSystem.Instance.BubbleSlotGroup.CollectData(); DialogUIManager.Instance.LoadBubbles(bubbleData); - // 开启遮罩 - yield return FixPanelSystem.Instance.MaskFadeIn(0.5f); - // 初始化系统并入场 + yield return TimelineCenter.Instance.PlayTimelineAsync(TimelineAssetRef.EngineModuleEnter); + // 视角移动 + var engineModule = BodyModuleSystem.FindBodyModuleByName("Heart"); + Tween tween = RepairSystemManager.Instance.ScaleCurrentSystem(blockPuzzleScale, engineModule.transform.position); + if (tween != null) + { + yield return tween.WaitForCompletion(); + } + // 初始化拼图 BlockPuzzleSystem.Initialize(puzzleName); + // 开启遮罩 + yield return FixPanelSystem.Instance.MaskFadeIn(); + RepairSystemManager.Instance.SwitchSystem(); + yield return new WaitForSeconds(0.5f); + yield return FixPanelSystem.Instance.MaskFadeOut(); // 播放进场动画 yield return TimelineCenter.Instance.PlayTimelineAsync(TimelineAssetRef.CablePanelExit); @@ -704,7 +718,6 @@ namespace AibisDream.FixSystem public IEnumerator Exit() { - BlockPuzzleYarnCommand.ClearBlockPuzzle(); yield break; } } diff --git a/Assets/Scripts/FixSystemNew/FixSystemYarnCommand.cs b/Assets/Scripts/FixSystemNew/FixSystemYarnCommand.cs index c7d0db6ee..f48c31b7c 100644 --- a/Assets/Scripts/FixSystemNew/FixSystemYarnCommand.cs +++ b/Assets/Scripts/FixSystemNew/FixSystemYarnCommand.cs @@ -8,8 +8,6 @@ namespace AibisDream.FixSystem public static class FixSystemYarnCommand { - private static ShockSystem ShockSystem => FixSystemCenter.SystemDic.Get(); - [YarnCommand("switch_fix_system_to")] public static IEnumerator SwitchFixSystemTo(string targetStateStr, string extraArg = "") { @@ -28,5 +26,37 @@ namespace AibisDream.FixSystem { yield return FixSystemCenter.PlayClinicCut(); } + + #region 维修系统管理器命令 + + /// + /// 切换到指定的维修系统(按类型名称) + /// 用法: <> + /// + [YarnCommand("repair_switch_system")] + public static IEnumerator RepairSwitchSystem(string systemTypeName) + { + Type systemType = systemTypeName switch + { + "BodyModuleSystem" => typeof(BodyModuleSystem), + "BlockPuzzleSystem" => typeof(BlockPuzzleSystem), + _ => null + }; + + if (systemType == null) + { + Debug.LogError($"[Yarn] 未知的系统类型: {systemTypeName}"); + yield break; + } + + RepairSystemManager.Instance.SwitchSystem(systemType); + + // 等待切换动画 + yield return new WaitForSeconds(RepairSystemManager.Instance.GetComponent() + ?.GetType().GetField("switchDuration", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) + ?.GetValue(RepairSystemManager.Instance) is float duration ? duration : 0.5f); + } + + #endregion } } \ No newline at end of file diff --git a/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs index 817fad76a..2d3be2621 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/Core/FixPanelSystem.cs @@ -47,12 +47,16 @@ namespace AibisDream.FixSystem #endregion - #region 光照系统 + #region 维修管理扩展 [Header("光照系统")] [SerializeField] private FixPanelLight panelLight; public FixPanelLight PanelLight => panelLight; + [Header("维修切换管理")] + [SerializeField] private RepairSystemManager repairSystemManager; + public RepairSystemManager RepairSystemManager => repairSystemManager; + #endregion #region 系统启动协调 @@ -109,33 +113,9 @@ namespace AibisDream.FixSystem [Header("默认画布")] [SerializeField] private Canvas canvas; - [Header("面板中心点")] - [SerializeField] private Transform panelCenter; - public Transform PanelCenter => panelCenter; - [Header("全景遮罩")] [SerializeField] private SpriteRenderer mask; - /// - /// 遮罩淡入(从当前透明度过渡到不透明) - /// - /// 淡入时长(秒) - public Tween MaskFadeIn(float duration = 0.5f) - { - if (mask == null) return null; - return mask.DOFade(1f, duration).SetEase(Ease.Linear); - } - - /// - /// 遮罩淡出(从当前透明度过渡到透明) - /// - /// 淡出时长(秒) - public Tween MaskFadeOut(float duration = 0.5f) - { - if (mask == null) return null; - return mask.DOFade(0f, duration).SetEase(Ease.Linear); - } - [Header("任务面板")] [SerializeField] private TaskPanel taskPanel; public TaskPanel TaskPanel => taskPanel; @@ -171,6 +151,26 @@ namespace AibisDream.FixSystem canvas.worldCamera = null; } + /// + /// 遮罩淡入(从当前透明度过渡到不透明) + /// + /// 淡入时长(秒) + public IEnumerator MaskFadeIn(float duration = 1f) + { + if (mask == null) yield break; + yield return mask.DOFade(1f, duration).WaitForCompletion(); + } + + /// + /// 遮罩淡出(从当前透明度过渡到透明) + /// + /// 淡出时长(秒) + public IEnumerator MaskFadeOut(float duration = 1f) + { + if (mask == null) yield break; + yield return mask.DOFade(0f, duration).WaitForCompletion(); + } + #endregion } } diff --git a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/BlockPuzzlePanel.cs b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/BlockPuzzlePanel.cs index f01612d6d..6b702e68f 100644 --- a/Assets/Scripts/FixSystemNew/Screen System/FixPanel/BlockPuzzlePanel.cs +++ b/Assets/Scripts/FixSystemNew/Screen System/FixPanel/BlockPuzzlePanel.cs @@ -12,6 +12,9 @@ namespace AibisDream.FixSystem public UnityEvent OnSubmit => lockButton.onClick; public UnityEvent OnPopUp => popUpButton.onClick; + [Header("面板UI部分")] + [SerializeField] private GameObject panelUIRoot; + private void Awake() { EnumEventSystem.Global.Register(ScreenEventEnum.Selected, OnSelected); @@ -59,7 +62,7 @@ namespace AibisDream.FixSystem private void OnSelected(GameObject obj) { - gameObject.SetActive(obj == blockPuzzleScreen.gameObject); + blockPuzzleScreen.gameObject.SetActive(obj == blockPuzzleScreen.gameObject); } public void ClearShapeInScreen()