存档功能
This commit is contained in:
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using AibisDream.Framework;
|
||||
using UnityEngine.PlayerLoop;
|
||||
|
||||
namespace AibisDream.FixSystem
|
||||
{
|
||||
public class FixStateMachine
|
||||
{
|
||||
private IState _curState;
|
||||
private string _curArgs;
|
||||
|
||||
public void SwitchState(FixState nextState, string args = "")
|
||||
{
|
||||
_curArgs = args;
|
||||
|
||||
_curState?.Exit();
|
||||
|
||||
GameLoopManager.Instance.UpdateFixState(nextState, _curArgs);
|
||||
_curState = CreateState(nextState, _curArgs);
|
||||
_curState.Enter();
|
||||
}
|
||||
|
||||
private static IState CreateState(FixState nextState, string args)
|
||||
{
|
||||
IState res = nextState switch
|
||||
{
|
||||
FixState.Clinic => new ClinicState(),
|
||||
FixState.Engine => new EngineState(),
|
||||
FixState.CoolingMachine => new CoolingMachineState(),
|
||||
FixState.BodyModule => new BodyModuleState(),
|
||||
FixState.Memory => new MemoryState(),
|
||||
FixState.Eye => new EyeState(),
|
||||
FixState.UF => new UfState(),
|
||||
FixState.Gear => new GearState(),
|
||||
_ => new ClinicState()
|
||||
};
|
||||
|
||||
res.SetArgs(args);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IState
|
||||
{
|
||||
public FixState GetState { get; }
|
||||
public void SetArgs(string args);
|
||||
public IEnumerator Enter();
|
||||
public IEnumerator Exit();
|
||||
}
|
||||
|
||||
public class ClinicState : IState
|
||||
{
|
||||
public FixState GetState => FixState.Clinic;
|
||||
|
||||
public void SetArgs(string args)
|
||||
{
|
||||
// 无
|
||||
}
|
||||
|
||||
public IEnumerator Enter()
|
||||
{
|
||||
// 切换相机
|
||||
yield break;
|
||||
}
|
||||
|
||||
public IEnumerator Exit()
|
||||
{
|
||||
// 似乎没有?
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
public class BodyModuleState : IState
|
||||
{
|
||||
public FixState GetState => FixState.BodyModule;
|
||||
|
||||
public void SetArgs(string args)
|
||||
{
|
||||
// 无
|
||||
}
|
||||
|
||||
public IEnumerator Enter()
|
||||
{
|
||||
// 切换相机
|
||||
yield break;
|
||||
}
|
||||
|
||||
public IEnumerator Exit()
|
||||
{
|
||||
// 似乎没有?
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
public class GearState : IState
|
||||
{
|
||||
public FixState GetState => FixState.Gear;
|
||||
|
||||
private string _configKey;
|
||||
|
||||
public void SetArgs(string args)
|
||||
{
|
||||
_configKey = args;
|
||||
}
|
||||
|
||||
public IEnumerator Enter()
|
||||
{
|
||||
// 切换相机
|
||||
yield break;
|
||||
}
|
||||
|
||||
public IEnumerator Exit()
|
||||
{
|
||||
// 切换相机
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
public class EngineState : IState
|
||||
{
|
||||
public FixState GetState => FixState.Engine;
|
||||
|
||||
public void SetArgs(string args)
|
||||
{
|
||||
// 无
|
||||
}
|
||||
|
||||
public IEnumerator Enter()
|
||||
{
|
||||
// 切换相机
|
||||
yield break;
|
||||
// 加载Level
|
||||
|
||||
// 解锁
|
||||
|
||||
}
|
||||
|
||||
public IEnumerator Exit()
|
||||
{
|
||||
// 上锁
|
||||
|
||||
// 切换相机
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
public class CoolingMachineState : IState
|
||||
{
|
||||
public FixState GetState => FixState.CoolingMachine;
|
||||
|
||||
public void SetArgs(string args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator Enter()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator Exit()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class UfState : IState
|
||||
{
|
||||
public FixState GetState => FixState.UF;
|
||||
|
||||
public void SetArgs(string args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator Enter()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator Exit()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class EyeState : IState
|
||||
{
|
||||
public FixState GetState => FixState.Eye;
|
||||
|
||||
public void SetArgs(string args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator Enter()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator Exit()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class MemoryState : IState
|
||||
{
|
||||
public FixState GetState => FixState.Memory;
|
||||
|
||||
public void SetArgs(string args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator Enter()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerator Exit()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user