2024-01-10 18:30:01 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Gameplay;
|
|
|
|
|
|
using Gameplay.SubSystems;
|
2024-01-12 15:35:41 +08:00
|
|
|
|
using PhxhSDK;
|
|
|
|
|
|
using UnityEngine;
|
2024-01-10 18:30:01 +08:00
|
|
|
|
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()
|
|
|
|
|
|
{
|
2024-01-11 18:32:08 +08:00
|
|
|
|
UIManager.Instance.HideAllUI();
|
2024-01-10 18:30:01 +08:00
|
|
|
|
_currProcess = EProcess.LoadingScene;
|
|
|
|
|
|
var loadingExecutor = new LoadingExecutorWithUILoadingController();
|
|
|
|
|
|
loadingExecutor.getProgress = GetLoadingProcess;
|
|
|
|
|
|
LoadingExecutorManager.Instance.ExecuteLoading(loadingExecutor);
|
2024-01-15 15:38:20 +08:00
|
|
|
|
var sceneHandle = await GameSceneHelper.Instance.LoadSceneForUIView(CAMP_SCENE_PATH, LoadSceneMode.Additive);
|
2024-01-10 18:30:01 +08:00
|
|
|
|
if (sceneHandle == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"无法进入营地场景,场景不存在,scene path:{CAMP_SCENE_PATH}");
|
|
|
|
|
|
_currProcess = EProcess.None;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-01-12 15:35:41 +08:00
|
|
|
|
|
2024-01-10 18:30:01 +08:00
|
|
|
|
_currProcess = EProcess.LoadingUI;
|
2024-01-12 14:59:34 +08:00
|
|
|
|
await UIManager.Instance.OpenWindow(UINameConst.UI_Camp);
|
2024-01-10 18:30:01 +08:00
|
|
|
|
_currProcess = EProcess.RefreshCamp;
|
2024-01-11 18:32:08 +08:00
|
|
|
|
_campSceneManager = CommonUtils.GetSceneRootComponent<CampSceneManager>(sceneHandle.Scene);
|
2024-01-10 18:30:01 +08:00
|
|
|
|
if (_campSceneManager == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError($"无法进入营地场景,campSceneManager不存在,scene path:{CAMP_SCENE_PATH}");
|
|
|
|
|
|
_currProcess = EProcess.None;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-11 18:32:08 +08:00
|
|
|
|
await _campSceneManager.Refresh();
|
2024-01-10 18:30:01 +08:00
|
|
|
|
_currProcess = EProcess.Present;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async void ExitCamp()
|
|
|
|
|
|
{
|
2024-01-15 15:38:20 +08:00
|
|
|
|
await GameSceneHelper.Instance.UnLoadSceneForUIView(CAMP_SCENE_PATH);
|
2024-01-12 15:35:41 +08:00
|
|
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_Camp, UIWindowCloseType.HideAndDestroy);
|
2024-01-10 18:30:01 +08:00
|
|
|
|
_currProcess = EProcess.None;
|
2024-01-11 18:32:08 +08:00
|
|
|
|
UIManager.Instance.ShowAllUI();
|
2024-01-10 18:30:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private float GetLoadingProcess()
|
|
|
|
|
|
{
|
2024-01-12 15:35:41 +08:00
|
|
|
|
float progress = 0;
|
2024-01-10 18:30:01 +08:00
|
|
|
|
switch (_currProcess)
|
|
|
|
|
|
{
|
|
|
|
|
|
case EProcess.None:
|
2024-01-12 15:35:41 +08:00
|
|
|
|
break;
|
2024-01-10 18:30:01 +08:00
|
|
|
|
case EProcess.LoadingScene:
|
|
|
|
|
|
//加载场景只占50%
|
2024-01-12 15:35:41 +08:00
|
|
|
|
progress = GameSceneManager.Instance.GetSceneLoadingProgress(CAMP_SCENE_PATH) * 50f;
|
|
|
|
|
|
break;
|
2024-01-10 18:30:01 +08:00
|
|
|
|
case EProcess.LoadingUI:
|
2024-01-12 15:35:41 +08:00
|
|
|
|
progress = 60f;
|
|
|
|
|
|
break;
|
2024-01-10 18:30:01 +08:00
|
|
|
|
case EProcess.RefreshCamp:
|
|
|
|
|
|
//刷新场景要加载预制体和模型等
|
2024-01-12 15:35:41 +08:00
|
|
|
|
progress = 60 + _campSceneManager.GetRefreshProcess() * 40f;
|
|
|
|
|
|
break;
|
2024-01-10 18:30:01 +08:00
|
|
|
|
case EProcess.Present:
|
2024-01-12 15:35:41 +08:00
|
|
|
|
progress = 100;
|
|
|
|
|
|
break;
|
2024-01-10 18:30:01 +08:00
|
|
|
|
default:
|
2024-01-12 15:35:41 +08:00
|
|
|
|
break;
|
2024-01-10 18:30:01 +08:00
|
|
|
|
}
|
2024-01-12 15:35:41 +08:00
|
|
|
|
|
|
|
|
|
|
//DebugUtil.Log($"progress:{progress}");
|
|
|
|
|
|
return progress;
|
2024-01-10 18:30:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|