NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/LevelManager.cs

52 lines
1.2 KiB
C#
Raw Normal View History

2023-08-22 19:08:45 +08:00
using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using Framework;
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; }
public async UniTask<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();
return 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
}
}