59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using Framework;
|
|
using Gameplay.Story;
|
|
using Gameplay.SubSystems;
|
|
using PhxhSDK;
|
|
|
|
namespace Code.Scripts.Gameplay.Game
|
|
{
|
|
public class GameStateStory : IState
|
|
{
|
|
|
|
private cfg.StoryCfg.DataStoryMain _storyConfig;
|
|
|
|
private bool _isReady = false;
|
|
|
|
public GameStateStory(int storyId)
|
|
{
|
|
_storyConfig = TableManager.Instance.Tables.StoryMainConfig.Get(storyId);
|
|
}
|
|
|
|
public void OnEnter()
|
|
{
|
|
_AsyncAction();
|
|
}
|
|
|
|
private async void _AsyncAction()
|
|
{
|
|
_isReady = false;
|
|
|
|
await _LoadScene();
|
|
|
|
StoryManager.instance.InitForGame();
|
|
await UIManager.Instance.OpenWindow(UINameConst.UIStoryMain);
|
|
|
|
_isReady = true;
|
|
}
|
|
|
|
private async UniTask _LoadScene()
|
|
{
|
|
var scenePath = _storyConfig.ScenePath;
|
|
await GameSceneManager.Instance.LoadSceneAsync(scenePath);
|
|
}
|
|
|
|
public void OnUpdate(float deltaTime)
|
|
{
|
|
if (!_isReady) return;
|
|
|
|
StoryManager.instance.LogicUpdate(deltaTime);
|
|
}
|
|
|
|
public void OnExit()
|
|
{
|
|
// TODO: 卸载场景
|
|
|
|
StoryManager.instance.DisposeForGame();
|
|
}
|
|
}
|
|
}
|