【剧情】loading

main
Ma Yuanzheng 2024-01-09 19:20:29 +08:00
parent 68a7ea913e
commit eef18746cd
6 changed files with 85 additions and 60 deletions

View File

@ -1,6 +1,7 @@
using Code.Scripts.Gameplay.Utils;
using Cysharp.Threading.Tasks;
using Framework;
using Gameplay;
using Gameplay.Level;
using Gameplay.Story;
using Gameplay.SubSystems;
@ -27,38 +28,23 @@ namespace Code.Scripts.Gameplay.Game
_isReady = false;
EventManager.Instance.Register(EventManager.EventName.STORY_CLICK_SKIP, _OnRecvExit);
_AsyncAction();
var exe = new StoryLoadingExecutor(_storyConfig);
exe.OnEnd = delegate
{
_isReady = true;
};
LoadingExecutorManager.Instance.ExecuteLoading(exe);
}
private async void _AsyncAction()
{
await _LoadScene();
// 设置阴影距离
ShadowEx.SetShadowDistance(_storyConfig.ShadowDistance);
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);
// if (_needExit)
// {
// GameStateManager.Instance.ChangeState(new GameStateMainScene());
// }
}
private void _OnRecvExit()

View File

@ -18,8 +18,6 @@ namespace Gameplay
{
private UI_LoadingController _uiLoadingController;
private bool _needUpdate;
protected override async UniTask<LoadingResult> _DoLoading()
{
LoadingResult result;
@ -37,10 +35,6 @@ namespace Gameplay
return result;
}
if (_needUpdate)
_destProgress = 100;
else
{
_destProgress = 30f;
result = await LoadLoginUI();
if (result != LoadingResult.Success)
@ -74,10 +68,13 @@ namespace Gameplay
return result;
}
_destProgress = 95f;
await UIManager.Instance.OpenWindow(UINameConst.UI_LogIn);
_destProgress = 100f;
}
return LoadingResult.Success;
return LoadingResult.Success;
}
private async UniTask<LoadingResult> _PreloadOthers()
@ -97,23 +94,6 @@ namespace Gameplay
return LoadingResult.Success;
}
protected override async void _OnEnd()
{
if (_needUpdate)
{
var platform = GetPlatform();
if (platform != null && AppConfig.Instance.UpdateInfo.AppUrl.TryGetValue(platform, out var url))
{
UIManager.Instance.OpenWindow(UINameConst.UI_Update, url);
}
}
else
{
await UIManager.Instance.OpenWindow(UINameConst.UI_LogIn);
}
}
// 是否是安装后第一次运行
private async UniTask<LoadingResult> FirstRunAppCheck()
{
@ -126,7 +106,19 @@ namespace Gameplay
// 强更检查
private async UniTask<LoadingResult> AppVersionCheck()
{
_needUpdate = AppConfig.Instance.UpdateInfo.NeedUpdate;
var needUpdate = AppConfig.Instance.UpdateInfo.NeedUpdate;
if (needUpdate)
{
var platform = GetPlatform();
if (platform != null && AppConfig.Instance.UpdateInfo.AppUrl.TryGetValue(platform, out var url))
{
UIManager.Instance.OpenWindow(UINameConst.UI_Update, url);
}
return LoadingResult.ErrorTest;
}
return LoadingResult.Success;
}

View File

@ -6,13 +6,15 @@ namespace Gameplay
{
private UI_LoadingController _uiLoadingController;
public Action OnEnd;
public override async void OnExecute()
{
_uiLoadingController = await UIManager.Instance.OpenWindow(UINameConst.UI_Loading) as UI_LoadingController;
if (_uiLoadingController != null)
{
_uiLoadingController.StartLoading(_OnEnd);
_uiLoadingController.StartLoading(OnEnd);
}
var result = await _DoLoading();
@ -45,9 +47,5 @@ namespace Gameplay
await UniTask.NextFrame();
return LoadingResult.Success;
}
protected virtual void _OnEnd()
{
}
}
}

View File

@ -37,10 +37,5 @@ namespace Gameplay
await UIManager.Instance.OpenWindow(UINameConst.UI_MainPanel);
return LoadingResult.Success;
}
protected override void _OnEnd()
{
base._OnEnd();
}
}
}

View File

@ -0,0 +1,51 @@
using cfg.StoryCfg;
using Code.Scripts.Gameplay.Utils;
using Cysharp.Threading.Tasks;
using Gameplay.Story;
using Gameplay.SubSystems;
namespace Gameplay
{
public class StoryLoadingExecutor : LoadingExecutorWithUILoadingController
{
private readonly DataStoryMain _cfg;
public StoryLoadingExecutor(DataStoryMain cfg)
{
_cfg = cfg;
if (_cfg == null)
{
DebugUtil.LogError("StoryLoadingExecutor: DataStoryMain is null");
}
}
protected override async UniTask<LoadingResult> _DoLoading()
{
_destProgress = 0;
await _LoadScene();
_destProgress = 50;
// 设置阴影距离
ShadowEx.SetShadowDistance(_cfg.ShadowDistance);
_destProgress = 51;
StoryManager.instance.InitForGame();
_destProgress = 90
;
await UIManager.Instance.OpenWindow(UINameConst.UIStoryMain);
_destProgress = 100;
return LoadingResult.Success;
}
private async UniTask _LoadScene()
{
var scenePath = _cfg.ScenePath;
await GameSceneManager.Instance.LoadSceneAsync(scenePath);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c93da227a189446d8246297cc787cd5b
timeCreated: 1704797814