NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Camp/CampManager.SceneLogic.cs

78 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System.Linq;
using Gameplay;
using Gameplay.SubSystems;
using PhxhSDK;
using UnityEngine;
using UnityEngine.SceneManagement;
public partial class CampManager
{
private const string CAMP_SCENE_PATH = "Assets/Scenes/CampScene.unity";
private enum EProcess
{
None = 0,
LoadingScene,
LoadingUI,
RefreshCamp,
Present,
}
private EProcess _currProcess = EProcess.None;
private CampSceneManager _campSceneManager;
public async void EnterCamp()
{
UIManager.Instance.HideAllUI();
_currProcess = EProcess.LoadingScene;
var loadingExecutor = new LoadingExecutorWithUILoadingController();
loadingExecutor.getProgress = GetLoadingProcess;
LoadingExecutorManager.Instance.ExecuteLoading(loadingExecutor);
var uiSceneResult = await CommonUtils.OpenUIWithScene(UINameConst.UI_Camp, CAMP_SCENE_PATH, null, false);
_currProcess = EProcess.RefreshCamp;
_campSceneManager = CommonUtils.GetSceneRootComponent<CampSceneManager>(uiSceneResult.sceneHandle.Scene);
if (_campSceneManager == null)
{
DebugUtil.LogError($"无法进入营地场景campSceneManager不存在,scene path:{CAMP_SCENE_PATH}");
_currProcess = EProcess.None;
return;
}
await _campSceneManager.Refresh();
_currProcess = EProcess.Present;
}
public async void ExitCamp()
{
await CommonUtils.CloseUIWithScene(UINameConst.UI_Camp);
_currProcess = EProcess.None;
}
private float GetLoadingProcess()
{
float progress = 0;
switch (_currProcess)
{
case EProcess.None:
break;
case EProcess.LoadingScene:
//加载场景只占50%
progress = GameSceneManager.Instance.GetSceneLoadingProgress(CAMP_SCENE_PATH) * 0.5f;
break;
case EProcess.LoadingUI:
progress = 60f;
break;
case EProcess.RefreshCamp:
//刷新场景要加载预制体和模型等
progress = 60 + _campSceneManager.GetRefreshProcess() * 40f;
break;
case EProcess.Present:
progress = 100;
break;
default:
break;
}
return progress;
}
}