795 lines
30 KiB
C#
795 lines
30 KiB
C#
using System;
|
|
using System.Collections;
|
|
using AibisDream;
|
|
using AibisDream.Framework;
|
|
using AibisDream.Kit;
|
|
using AibisDream.UI;
|
|
using DG.Tweening;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
public class FixStateMachine
|
|
{
|
|
public FixState CurState => _curState.GetState;
|
|
|
|
private IState<FixState> _curState;
|
|
|
|
private StateMachine<FixState> _stateMachine;
|
|
|
|
private FixSystemData _data;
|
|
|
|
public FixStateMachine(FixSystemData data)
|
|
{
|
|
_data = data;
|
|
_stateMachine = new StateMachine<FixState>(CreateState);
|
|
_stateMachine.OnStateSwitch += state => EnumEventSystem.Global.Send(EventEnum.FixStateSwitch, state);
|
|
}
|
|
|
|
public IEnumerator Init(FixState initState)
|
|
{
|
|
_data.curState = initState;
|
|
_data.args = "";
|
|
yield return _stateMachine.Init(initState);
|
|
}
|
|
|
|
public IEnumerator SwitchState(FixState nextState, string args = "")
|
|
{
|
|
_data.curState = nextState;
|
|
_data.args = args;
|
|
yield return _stateMachine.SwitchState(nextState, args);
|
|
}
|
|
|
|
public IEnumerator QuitState()
|
|
{
|
|
_data.curState = FixState.Default;
|
|
yield return _stateMachine.QuitState();
|
|
}
|
|
|
|
private static IState<FixState> CreateState(FixState nextState, string args)
|
|
{
|
|
IState<FixState> res = nextState switch
|
|
{
|
|
FixState.Clinic => new ClinicState(),
|
|
FixState.BodyModule => new BodyModuleState(),
|
|
FixState.Memory => new MemoryState(),
|
|
FixState.Eye => new EyeState(),
|
|
FixState.UF => new UfState(),
|
|
FixState.Expression => new ExpressionState(),
|
|
FixState.Emo => new EmoState(),
|
|
FixState.Op => new OpState(),
|
|
FixState.EmoCut => new EmoCutState(),
|
|
FixState.MemoryCut => new MemoryCutState(),
|
|
FixState.LogicCut => new LogicCutState(),
|
|
FixState.Dream => new DreamState(),
|
|
FixState.AnalysisMode => new AnalysisModeState(),
|
|
FixState.Sales => new SalesState(),
|
|
FixState.BlockPuzzle => new BlockPuzzleState(),
|
|
_ => new DefaultState()
|
|
};
|
|
|
|
res.SetArgs(args);
|
|
return res;
|
|
}
|
|
}
|
|
|
|
public enum FixState
|
|
{
|
|
Default,
|
|
Clinic,
|
|
BodyModule,
|
|
Memory,
|
|
Eye,
|
|
UF,
|
|
Expression,
|
|
Engine,
|
|
Gear,
|
|
Emo,
|
|
Op,
|
|
EmoCut,
|
|
MemoryCut,
|
|
LogicCut,
|
|
Dream,
|
|
AnalysisMode,
|
|
Sales,
|
|
BlockPuzzle
|
|
}
|
|
|
|
public struct DefaultState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.Default;
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
yield break;
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
yield break;
|
|
}
|
|
}
|
|
|
|
public struct ClinicState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.Clinic;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
// 无
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
// 先加载对话气泡,避免 Yarn 对话(如 测试 节点 me: 释放log)在相机切换完成前执行时找不到 Player 槽位
|
|
var clinicSystem = FixSystemCenter.SystemDic.Get<ClinicSystem>();
|
|
var data = clinicSystem.bubbleSlotGroup.CollectData();
|
|
DialogUIManager.Instance.LoadBubbles(data);
|
|
// 切换相机
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Clinic);
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
// 无
|
|
yield break;
|
|
}
|
|
}
|
|
|
|
public struct BodyModuleState : IState<FixState>
|
|
{
|
|
private string _args;
|
|
|
|
public FixState GetState => FixState.BodyModule;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
// 设置参数
|
|
_args = args;
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
var cablePanel = FixPanelSystem.GetRepairPanel<CablePanel>();
|
|
// 拔出插头
|
|
// 切换Body或Head
|
|
if (Enum.TryParse<ModuleState>(_args, out var moduleState))
|
|
{
|
|
bodyModuleSystem.SwitchModuleGroup(moduleState);
|
|
}
|
|
|
|
if (cablePanel != null && !cablePanel.IsSystemOn())
|
|
{
|
|
// 切换相机
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModuleCenter);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.5f);
|
|
yield return new WaitForSeconds(0.5f);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
yield return cablePanel.StartSystem();
|
|
}
|
|
else
|
|
{
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
|
|
// 加载气泡
|
|
var data = FixPanelSystem.Instance.BubbleSlotGroup.CollectData();
|
|
DialogUIManager.Instance.LoadBubbles(data);
|
|
|
|
// 开启交互
|
|
bodyModuleSystem.EnableSystem();
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
// 拔出插头
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
// 关闭交互
|
|
bodyModuleSystem.DisableSystem();
|
|
yield break;
|
|
}
|
|
}
|
|
|
|
public struct UfState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.UF;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
var ufSystem = FixSystemCenter.SystemDic.Get<UFSystem>();
|
|
var eyeSystem = FixSystemCenter.SystemDic.Get<EyeSystem>();
|
|
// 先切BodyModule
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
|
|
// 插头回到初始插孔
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
// 切换相机
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.UF);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.5f);
|
|
ufSystem.OpenUFView();
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.EyeDeep);
|
|
eyeSystem.OnEnter();
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.5f);
|
|
var data = eyeSystem.bubbleSlotGroup.CollectData();
|
|
DialogUIManager.Instance.LoadBubbles(data);
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
float duration = 0.5f;
|
|
var ufSystem = FixSystemCenter.SystemDic.Get<UFSystem>();
|
|
var eyeSystem = FixSystemCenter.SystemDic.Get<EyeSystem>();
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(duration);
|
|
eyeSystem.OnExit();
|
|
ufSystem.CloseUFView();
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.UF);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(duration);
|
|
}
|
|
}
|
|
|
|
public struct EyeState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.Eye;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
bodyModuleSystem.SwitchModuleGroup(ModuleState.Head);
|
|
var eyeSystem = FixSystemCenter.SystemDic.Get<EyeSystem>();
|
|
// 先切BodyModule
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
|
|
//打开盖子
|
|
var eyeModule = bodyModuleSystem.FindBodyModuleByType<EyeModule>();
|
|
yield return eyeModule.OpenEye();
|
|
|
|
// 插头回到初始插孔
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
// 切换相机
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Eye);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.5f);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.EyeDeep);
|
|
eyeSystem.OnEnter();
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.5f);
|
|
|
|
var data = eyeSystem.bubbleSlotGroup.CollectData();
|
|
DialogUIManager.Instance.LoadBubbles(data);
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
float duration = 0.5f;
|
|
var eyeSystem = FixSystemCenter.SystemDic.Get<EyeSystem>();
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(duration);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Eye);
|
|
eyeSystem.OnExit();
|
|
yield return new WaitForSeconds(0.1f);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(duration);
|
|
//关上
|
|
var eyeModule = bodyModuleSystem.FindBodyModuleByType<EyeModule>();
|
|
yield return eyeModule.CloseEye();
|
|
yield return new WaitForSeconds(0.5f);
|
|
}
|
|
}
|
|
|
|
public struct MemoryState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.Memory;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
float duration = 0.5f;
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
var memorySystem = FixSystemCenter.SystemDic.Get<MemoryProcess>();
|
|
// 先切BodyModule
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
|
|
yield return memorySystem.DropMemoryProjector();
|
|
// 插头回到初始插孔
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
// 相机聚焦到目标位
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Memory);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(duration);
|
|
memorySystem.OnEnter();
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(duration);
|
|
var data = memorySystem.bubbleSlotGroup.CollectData();
|
|
DialogUIManager.Instance.LoadBubbles(data);
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
float duration = 0.5f;
|
|
var memorySystem = FixSystemCenter.SystemDic.Get<MemoryProcess>();
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(duration);
|
|
memorySystem.OnExit();
|
|
memorySystem.CloseMemoryView();
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(duration);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
memorySystem.PullMemoryProjector();
|
|
}
|
|
}
|
|
|
|
public struct ExpressionState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.Expression;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
// 无
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
// 获取表达系统
|
|
var expressionManager = FixSystemCenter.SystemDic.Get<ExpressionManager>();
|
|
|
|
// 先切 BodyModule(如果需要)
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
var bodyModule = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
bodyModule.SwitchModuleGroup(ModuleState.Head);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
// 开启表达系统视图,并播放火山表达深入
|
|
// 切换到表达相机
|
|
yield return TimelineCenter.Instance.PlayTimelineAsync("透镜/透镜in");
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Expression);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.5f);
|
|
expressionManager.OpenView();
|
|
// 切换到深度表达相机
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.ExpressionDeep);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.5f);
|
|
yield return TimelineCenter.Instance.PlayTimelineAsync("火山表达模块/火山表达深入");
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
var expressionManager = FixSystemCenter.SystemDic.Get<ExpressionManager>();
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.5f);
|
|
|
|
// 重置身体模块
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
|
|
// 关闭表达系统视图
|
|
expressionManager.CloseView();
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Expression);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.5f);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
yield return TimelineCenter.Instance.PlayTimelineAsync("透镜/透镜out");
|
|
yield break;
|
|
}
|
|
}
|
|
|
|
public struct EmoState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.Emo;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
var emoManager = FixSystemCenter.SystemDic.Get<EmoManager>();
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
var bodyModule = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
bodyModule.SwitchModuleGroup(ModuleState.Head);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Emo);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.5f);
|
|
//emoManager.OpenView();
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.EmoDeep);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.5f);
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
yield break;
|
|
}
|
|
}
|
|
|
|
public struct OpState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.Op;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
// 无
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.Op))
|
|
{
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.Op);
|
|
}
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
// 无
|
|
yield break;
|
|
}
|
|
}
|
|
|
|
public struct DreamState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.Dream;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
// 无
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.DreamCamera))
|
|
{
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.DreamCamera);
|
|
|
|
var openSystem = FixSystemCenter.SystemDic.Get<OpenSystem>();
|
|
DialogUIManager.Instance.LoadBubbles(openSystem.bubbleSlotGroup.CollectData());
|
|
}
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
// 无
|
|
yield break;
|
|
}
|
|
}
|
|
|
|
public struct EmoCutState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.EmoCut;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
// 无
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
var cuttingManager = FixSystemCenter.SystemDic.Get<CuttingManager>();
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
bodyModuleSystem.SwitchModuleGroup(ModuleState.Head);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
// Cut的气泡统一放在BodyModule下
|
|
DialogUIManager.Instance.LoadBubbles(cuttingManager.bubbleSlotGroup.CollectData());
|
|
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
var bodyModule = bodyModuleSystem.FindBodyModuleByName("Emo");
|
|
if (bodyModule != null)
|
|
{
|
|
bodyModule.GetCutSpriteRenderer().sortingOrder = 100;
|
|
bodyModule.GetCutTextSpriteRenderer().sortingOrder = 101;
|
|
bodyModule.GetCutSpriteRenderer().color = new Color(1f, 1f, 1f, 1f);
|
|
bodyModule.GetCutSpriteRenderer().GetComponentInChildren<SpriteRenderer>().color =
|
|
new Color(1f, 1f, 1f, 1f);
|
|
}
|
|
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.CutEmo);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.1f);
|
|
AudioManager.Instance.SetGlobalParam("scene",14);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.CutEmoDeep);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.1f);
|
|
yield return cuttingManager.StartCutting(bodyModule);
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
// 无
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.1f);
|
|
var cuttingManager = FixSystemCenter.SystemDic.Get<CuttingManager>();
|
|
cuttingManager.ClearCutLine();
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.CutEmo);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.1f);
|
|
}
|
|
}
|
|
|
|
public struct MemoryCutState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.MemoryCut;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
// 无
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
var cuttingManager = FixSystemCenter.SystemDic.Get<CuttingManager>();
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
bodyModuleSystem.SwitchModuleGroup(ModuleState.Head);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
// Cut的气泡统一放在BodyModule下
|
|
DialogUIManager.Instance.LoadBubbles(cuttingManager.bubbleSlotGroup.CollectData());
|
|
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
var bodyModule = bodyModuleSystem.FindBodyModuleByName("Memory");
|
|
if (bodyModule != null)
|
|
{
|
|
bodyModule.GetCutSpriteRenderer().sortingOrder = 100;
|
|
bodyModule.GetCutTextSpriteRenderer().sortingOrder = 101;
|
|
bodyModule.GetCutSpriteRenderer().color = new Color(1f, 1f, 1f, 1f);
|
|
bodyModule.GetCutSpriteRenderer().GetComponentInChildren<SpriteRenderer>().color =
|
|
new Color(1f, 1f, 1f, 1f);
|
|
}
|
|
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.CutMemory);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.1f);
|
|
AudioManager.Instance.SetGlobalParam("scene",12);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.CutMemoryDeep);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.1f);
|
|
yield return cuttingManager.StartCutting(bodyModule);
|
|
}
|
|
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.1f);
|
|
var cuttingManager = FixSystemCenter.SystemDic.Get<CuttingManager>();
|
|
cuttingManager.ClearCutLine();
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.CutMemory);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.1f);
|
|
}
|
|
}
|
|
|
|
public struct LogicCutState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.LogicCut;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
// 无
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
var cuttingManager = FixSystemCenter.SystemDic.Get<CuttingManager>();
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
bodyModuleSystem.SwitchModuleGroup(ModuleState.Head);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
// Cut的气泡统一放在BodyModule下
|
|
DialogUIManager.Instance.LoadBubbles(cuttingManager.bubbleSlotGroup.CollectData());
|
|
|
|
var bodyModule = bodyModuleSystem.FindBodyModuleByName("Logic");
|
|
if (bodyModule != null)
|
|
{
|
|
bodyModule.GetCutSpriteRenderer().sortingOrder = 100;
|
|
bodyModule.GetCutTextSpriteRenderer().sortingOrder = 101;
|
|
bodyModule.GetCutSpriteRenderer().color = new Color(1f, 1f, 1f, 1f);
|
|
bodyModule.GetCutSpriteRenderer().GetComponentInChildren<SpriteRenderer>().color =
|
|
new Color(1f, 1f, 1f, 1f);
|
|
}
|
|
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.CutLogic);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.1f);
|
|
AudioManager.Instance.SetGlobalParam("scene",13);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.CutLogicDeep);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.1f);
|
|
yield return cuttingManager.StartCutting(bodyModule);
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.1f);
|
|
var cuttingManager = FixSystemCenter.SystemDic.Get<CuttingManager>();
|
|
cuttingManager.ClearCutLine();
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.CutLogic);
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.1f);
|
|
}
|
|
}
|
|
|
|
public struct AnalysisModeState : IState<FixState>
|
|
{
|
|
public FixState GetState => FixState.AnalysisMode;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
// 无
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
var analysisModeManager = FixSystemCenter.SystemDic.Get<MiniGame.Language.AnalysisModeManager>();
|
|
|
|
// 先切 BodyModule(如果需要)
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
bodyModuleSystem.SwitchModuleGroup(ModuleState.Head);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
|
|
// 插头回到初始插孔
|
|
FixPanelSystem.GetRepairPanel<CablePanel>().ResetPlug();
|
|
|
|
// 切换到分析模式相机
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.5f);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.AnalysisMode);
|
|
// 进入分析模式
|
|
if (analysisModeManager != null)
|
|
{
|
|
analysisModeManager.OnEnter();
|
|
}
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.5f);
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
float duration = 0.5f;
|
|
var analysisModeManager = FixSystemCenter.SystemDic.Get<MiniGame.Language.AnalysisModeManager>();
|
|
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(duration);
|
|
|
|
// 退出分析模式
|
|
if (analysisModeManager != null)
|
|
{
|
|
analysisModeManager.OnExit();
|
|
}
|
|
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(duration);
|
|
}
|
|
}
|
|
|
|
public struct SalesState : IState<FixState>
|
|
{
|
|
private string _systemView;
|
|
|
|
public FixState GetState => FixState.Sales;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
_systemView = args;
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
var bodyModuleSystem = FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
var screenSystem = FixSystemCenter.SystemDic.Get<ScreenSystem>();
|
|
if (!CameraKit.Instance.EqualToCameraState(CameraEnum.BodyModule))
|
|
{
|
|
bodyModuleSystem.SwitchModuleGroup(ModuleState.Head);
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
}
|
|
|
|
// 进入前先播放钳子摘盖子,完成后深入
|
|
yield return TimelineCenter.Instance.PlayTimelineAsync("钳子/摘走盖子");
|
|
|
|
// 获取销售系统管理器
|
|
var salesManager = FixSystemCenter.SystemDic.Get<AibisDream.MiniGame.Language.SalesManager>();
|
|
if (salesManager != null)
|
|
{
|
|
// FadeIn
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(0.5f);
|
|
|
|
// 打开销售系统视图,传入systemView参数
|
|
salesManager.OpenView();
|
|
|
|
// FadeOut
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(0.5f);
|
|
|
|
// 销售模块使用自身的气泡槽位;缺失时再回退到 ScreenSystem,避免读到错误的槽位配置
|
|
if (salesManager.bubbleSlotGroup != null)
|
|
{
|
|
var data = salesManager.bubbleSlotGroup.CollectData();
|
|
Debug.Log("[SalesState] Loaded bubble slots from SalesManager.");
|
|
DialogUIManager.Instance.LoadBubbles(data);
|
|
}
|
|
else if (screenSystem.BubbleSlotGroup != null)
|
|
{
|
|
Debug.LogWarning("[SalesState] SalesManager.bubbleSlotGroup is null, fallback to ScreenSystem bubble slots.");
|
|
var data = screenSystem.BubbleSlotGroup.CollectData();
|
|
DialogUIManager.Instance.LoadBubbles(data);
|
|
}
|
|
}
|
|
}
|
|
|
|
public IEnumerator Exit()
|
|
{
|
|
float duration = 0.5f;
|
|
var salesManager = FixSystemCenter.SystemDic.Get<AibisDream.MiniGame.Language.SalesManager>();
|
|
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync(duration);
|
|
|
|
// 关闭销售系统视图
|
|
if (salesManager != null)
|
|
{
|
|
salesManager.CloseView();
|
|
}
|
|
// 关闭前先播放钳子放下盖子,完成后再结
|
|
yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeOutAsync(duration);
|
|
yield return TimelineCenter.Instance.PlayTimelineAsync("钳子/放下盖子");
|
|
yield return null;
|
|
}
|
|
}
|
|
|
|
public struct BlockPuzzleState : IState<FixState>
|
|
{
|
|
private const string puzzleName = "Game2";
|
|
private const float blockPuzzleScale = 1.6f;
|
|
private static BlockPuzzleSystem BlockPuzzleSystem => FixSystemCenter.SystemDic.Get<BlockPuzzleSystem>();
|
|
private static BodyModuleSystem BodyModuleSystem => FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
|
|
|
|
public FixState GetState => FixState.BlockPuzzle;
|
|
|
|
public void SetArgs(string args)
|
|
{
|
|
}
|
|
|
|
public IEnumerator Enter()
|
|
{
|
|
// 基本操作(其实应该早就处理好了)
|
|
yield return CameraKit.Instance.SwitchCamera(CameraEnum.BodyModule);
|
|
var bubbleData = FixPanelSystem.Instance.BubbleSlotGroup.CollectData();
|
|
DialogUIManager.Instance.LoadBubbles(bubbleData);
|
|
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<BlockPuzzleSystem>();
|
|
yield return new WaitForSeconds(0.5f);
|
|
yield return FixPanelSystem.Instance.MaskFadeOut();
|
|
|
|
// 播放进场动画
|
|
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()
|
|
{
|
|
yield break;
|
|
}
|
|
}
|
|
} |