Forest_Client/Forest/Assets/Scripts/Gameplay/LevelLoadingExecutor.cs

63 lines
2.1 KiB
C#
Raw Normal View History

2024-06-20 15:44:50 +08:00
using PhxhSDK;
2024-06-12 15:01:54 +08:00
using Framework.UI;
using Gameplay.Level;
using Gameplay.Manager;
2024-06-20 15:44:50 +08:00
using Framework.Manager;
2024-06-12 15:01:54 +08:00
using Framework.Constants;
using Cysharp.Threading.Tasks;
2024-08-07 18:51:02 +08:00
using Gameplay.ForestLevel;
2024-06-12 15:01:54 +08:00
using UnityEngine.SceneManagement;
using UnityEngine.AddressableAssets;
namespace Gameplay.LoadingExecutor
{
public class LevelLoadingExecutor : LoadingExecutorWithUILoadingController
{
private string _levelID;
protected override async UniTask _DoLoading()
{
await Addressables.LoadSceneAsync(PathConstants.SceneLevelPath, LoadSceneMode.Single).ToUniTask();
2024-06-12 15:01:54 +08:00
_destProgress = 10f;
await LevelManager.Instance.LoadLevel(_levelID);
_destProgress = 20f;
KongManager.Instance.Init();
_destProgress = 30f;
await KongManager.Instance.PreLoadLevelItem();
_destProgress = 40f;
await UniTask.Delay(20);
PlankManager.Instance.Init();
_destProgress = 50f;
await PlankManager.Instance.PreLoadLevelItem();
_destProgress = 70f;
await LevelManager.Instance.Init();
_destProgress = 90f;
await InitLevelUI();
_destProgress = 100f;
}
public LevelLoadingExecutor(string levelID)
{
_levelID = levelID;
}
private async UniTask InitLevelUI()
{
UIManager.Instance.CloseWindow(UIConstants.UIWinPanel);
UIManager.Instance.CloseWindow(UIConstants.UILosePanel);
await UIManager.Instance.OpenWindow(UIConstants.UILevelPanel);
var window = UIManager.Instance.GetOpenedWindowByPath<UILevelPanelController>(UIConstants.UILevelPanel);
window?.ReloadWindow();
2024-07-25 22:51:34 +08:00
2024-06-12 15:01:54 +08:00
CommonUIUtils.DestroyScreenshot();
}
2024-07-25 22:51:34 +08:00
2024-06-12 15:01:54 +08:00
protected override void _OnEnd()
{
2024-07-30 16:04:11 +08:00
LevelManager.Instance.IsInGame = true;
2024-06-12 15:01:54 +08:00
LevelManager.Instance.ReportEnterLevel();
2024-06-20 15:44:50 +08:00
AudioManager.Instance.PlayMusic(AudioType.MUSIC, AudioManager.Instance.BGMInLevel, new UnityAudio(true));
2024-06-12 15:01:54 +08:00
}
}
}