90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
using System.Linq;
|
|
using cfg.ShowCfg;
|
|
using Gameplay;
|
|
using Gameplay.SubSystems;
|
|
using PhxhSDK;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using static Gameplay.CommonUtils;
|
|
|
|
public partial class CampManager
|
|
{
|
|
/// <summary>
|
|
/// 进度
|
|
/// </summary>
|
|
private enum EProcess
|
|
{
|
|
None = 0,
|
|
/// <summary>
|
|
/// 加载场景
|
|
/// </summary>
|
|
LoadingScene,
|
|
/// <summary>
|
|
/// 加载UI
|
|
/// </summary>
|
|
LoadingUI,
|
|
/// <summary>
|
|
/// 刷新营地
|
|
/// </summary>
|
|
RefreshCamp,
|
|
/// <summary>
|
|
/// 当前
|
|
/// </summary>
|
|
Present,
|
|
}
|
|
|
|
private EProcess curProcess = EProcess.None;
|
|
|
|
public async void EnterCamp()
|
|
{
|
|
UIManager.Instance.HideAllUI();
|
|
curProcess = EProcess.LoadingScene;
|
|
|
|
LoadingExecutorWithUILoadingController loadingExecutor = new()
|
|
{
|
|
getProgress = GetLoadingProcess
|
|
};
|
|
LoadingExecutorManager.Instance.ExecuteLoading(loadingExecutor);
|
|
UISceneResult uiSceneResult = await OpenUIWithScene(UINameConst.UI_Camp, Framework.Constants.CAMP_SCENE_PATH, null, false);
|
|
curProcess = EProcess.RefreshCamp;
|
|
|
|
ShowComponent showComponent = GetSceneRootComponent<ShowComponent>(uiSceneResult.sceneHandle.Scene);
|
|
if (showComponent == null)
|
|
{
|
|
DebugUtil.LogError($"无法进入营地场景,{typeof(ShowComponent).Name}不存在,scene path:{Framework.Constants.CAMP_SCENE_PATH}");
|
|
curProcess = EProcess.None;
|
|
|
|
return;
|
|
}
|
|
|
|
await ShowManager.Instance.RefreshShow(E_ShowSceneType.Camp);
|
|
|
|
curProcess = EProcess.Present;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 退出营地
|
|
/// </summary>
|
|
public async void ExitCamp()
|
|
{
|
|
await CloseUIWithScene(UINameConst.UI_Camp);
|
|
curProcess = EProcess.None;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取加载进度
|
|
/// </summary>
|
|
/// <returns>0f-100f</returns>
|
|
private float GetLoadingProcess()
|
|
{
|
|
return curProcess switch
|
|
{
|
|
EProcess.None => 0f,
|
|
EProcess.LoadingScene => GameSceneManager.Instance.GetSceneLoadingProgress(Framework.Constants.CAMP_SCENE_PATH) * 0.5f,
|
|
EProcess.LoadingUI => 60f,
|
|
EProcess.RefreshCamp => 60f + ShowManager.Instance.GetRefreshProcess(E_ShowSceneType.Camp) * 40f,
|
|
EProcess.Present => 100f,
|
|
_ => 0f,
|
|
};
|
|
}
|
|
} |