NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Game/GameStateManager.cs

40 lines
961 B
C#

using Framework;
using PhxhSDK;
public class GameStateManager : Singlenton<GameStateManager> , IUpdatable, IInitable
{
private StateMachine _stateMachine;
public void Update(float deltaTime)
{
_stateMachine.Update(deltaTime);
}
public void Init()
{
_stateMachine = new StateMachine();
}
public void Release()
{
_stateMachine = null;
}
public async void ChangeState(IState state)
{
var ui = await UIManager.Instance.OpenWindow(UINameConst.UI_Loading) as UI_LoadingController;
if (ui != null)
{
UIManager.Instance.ForeachUI(delegate(UIWindow window)
{
if (window != null && window != ui)
{
window.CloseWindow(UIWindowCloseType.HideAndDestroy);
}
});
_stateMachine.ChangeState(state);
}
}
}