2023-08-22 19:08:45 +08:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using Framework;
|
2024-08-28 17:03:50 +08:00
|
|
|
using Gameplay.SubSystems;
|
2023-10-19 15:00:19 +08:00
|
|
|
using PhxhSDK;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
namespace Gameplay.Level
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
public partial class LevelManager : Singlenton<LevelManager>, IUpdatable, IInitable
|
2023-08-22 19:08:45 +08:00
|
|
|
{
|
|
|
|
|
public Level CurrentLevel { get; private set; }
|
|
|
|
|
|
2024-08-28 17:03:50 +08:00
|
|
|
public async UniTask<E_LoadingResult> LoadLevel(int leveId)
|
2023-08-22 19:08:45 +08:00
|
|
|
{
|
2023-12-26 18:19:05 +08:00
|
|
|
CurrentLevel = new Level(leveId, _levelParam);
|
2023-08-22 19:08:45 +08:00
|
|
|
await CurrentLevel.Load();
|
|
|
|
|
await UniTask.NextFrame();
|
2024-01-05 14:24:46 +08:00
|
|
|
|
2024-08-28 17:03:50 +08:00
|
|
|
return E_LoadingResult.Success;
|
2023-08-22 19:08:45 +08:00
|
|
|
}
|
|
|
|
|
|
2023-11-21 15:04:56 +08:00
|
|
|
public async void UnloadLevel()
|
2023-08-22 19:08:45 +08:00
|
|
|
{
|
2023-11-21 15:04:56 +08:00
|
|
|
await CurrentLevel.Unload();
|
2023-12-20 13:49:08 +08:00
|
|
|
if (CurrentLevel != null)
|
|
|
|
|
{
|
|
|
|
|
CurrentLevel.Release();
|
|
|
|
|
CurrentLevel = null;
|
|
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(float deltaTime)
|
|
|
|
|
{
|
|
|
|
|
if (CurrentLevel != null)
|
|
|
|
|
{
|
|
|
|
|
CurrentLevel.Update(deltaTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
|
{
|
|
|
|
|
InitData();
|
|
|
|
|
InitAction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Release()
|
|
|
|
|
{
|
|
|
|
|
ReleaseData();
|
|
|
|
|
ReleaseAction();
|
|
|
|
|
}
|
2023-08-22 19:08:45 +08:00
|
|
|
}
|
|
|
|
|
}
|