石头
This commit is contained in:
@@ -1,21 +1,57 @@
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.FixSystem
|
||||
{
|
||||
public class FixSystemCenter : MonoBehaviour
|
||||
public class FixSystemCenter : Singleton<FixSystemCenter>
|
||||
{
|
||||
public static IOCContainer SystemDic = new();
|
||||
public FixState curState;
|
||||
|
||||
private void Awake()
|
||||
public override void OnSingletonInit()
|
||||
{
|
||||
SystemDic ??= new IOCContainer();
|
||||
InitTransitionDic();
|
||||
|
||||
// TODO 这个回头要改
|
||||
curState = FixState.BodyModule;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
#region 系统索引
|
||||
|
||||
// 容纳System
|
||||
public static IOCContainer SystemDic = new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region 转场管理
|
||||
|
||||
private static readonly StateDictionary<ITransitionCommand> TransitionDic = new();
|
||||
|
||||
private void InitTransitionDic()
|
||||
{
|
||||
SystemDic = null;
|
||||
TransitionDic.Add(FixState.BodyModule, FixState.Engine, new BodyModuleToEngineCommand());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行转场
|
||||
/// </summary>
|
||||
/// <param name="nextState">需要转换的状态</param>
|
||||
public void TransToNextState(FixState nextState)
|
||||
{
|
||||
// 没存过的先打个日志报错
|
||||
if (!TransitionDic.TryGetValue(curState, nextState, out var command))
|
||||
{
|
||||
Debug.Log($"源为{curState.ToString()}, 目标为{nextState.ToString()}, 转场命令不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
// 存过的执行转场命令
|
||||
StartCoroutine(command.Execute());
|
||||
curState = nextState;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user