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

49 lines
1.3 KiB
C#
Raw Normal View History

2024-02-07 13:17:10 +08:00
using System.Collections.Generic;
2023-08-22 19:08:45 +08:00
using Framework;
2024-02-07 13:17:10 +08:00
using Gameplay.Performance;
2023-10-19 15:00:19 +08:00
using PhxhSDK;
2024-02-07 13:17:10 +08:00
using UnityEngine;
using UnityEngine.Device;
using UnityEngine.EventSystems;
2023-08-22 19:08:45 +08:00
2023-10-19 15:00:19 +08:00
public class GameStateManager : Singlenton<GameStateManager> , IUpdatable, IInitable
2023-08-22 19:08:45 +08:00
{
2023-10-19 15:00:19 +08:00
private StateMachine _stateMachine;
2023-08-22 19:08:45 +08:00
public void Update(float deltaTime)
{
_stateMachine.Update(deltaTime);
}
public void Init()
{
2023-10-19 15:00:19 +08:00
_stateMachine = new StateMachine();
2023-08-22 19:08:45 +08:00
}
public void Release()
{
_stateMachine = null;
}
2024-06-11 13:15:54 +08:00
public async void ChangeState(IState state)
2023-08-22 19:08:45 +08:00
{
2024-06-11 13:15:54 +08:00
if (null == TableManager.Instance.Tables)
await TableManager.Instance.Load(); // 打开加载界面时要先加载配置
2024-07-12 15:21:16 +08:00
if(state is GameStateMainScene gameStateMainScene && gameStateMainScene.IsLogin)
await Gameplay.UI.Utils.ShowLoadingUI(Gameplay.E_LoadingType.Login, true);
2024-07-11 16:15:45 +08:00
else
await Gameplay.UI.Utils.ShowLoadingUI(Gameplay.E_LoadingType.CommonLoading, true);
2024-03-04 14:35:54 +08:00
// TODO: 目前看起来没什么用,先注释掉 2024-3-4 14:34 by liutao
// PerformanceManager.ClearRaycasterImage();
2024-02-22 12:46:45 +08:00
_stateMachine.ChangeState(state);
2023-08-22 19:08:45 +08:00
}
public IState GetCurState()
{
return _stateMachine.GetCurrentState();
}
2023-08-22 19:08:45 +08:00
}