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

74 lines
1.7 KiB
C#

using PhxhSDK;
using PhxhSDK.Phxh;
using Framework.BI;
using Gameplay.Manager;
using LC.Newtonsoft.Json;
using Framework.Constants;
using Cysharp.Threading.Tasks;
using Constants = Framework.Constants.Constants;
namespace Gameplay.Level
{
public class Level : IUpdatable
{
private readonly string _id;
private LevelData _levelData;
public string ID => _id;
public LevelData LevelData => _levelData;
public Level(string leveId)
{
_id = leveId;
}
public string GetLevelID()
{
return _id.Substring("level".Length);
}
public int GetLevelIndex()
{
return int.Parse(_id["level".Length..]);
}
private async UniTask LoadLevelConfig(string levelID)
{
var configFilePath = string.Format(Constants.LevelConfigPath, levelID);
_levelData = await JsonHelper.LoadFromAddressable<LevelData>(configFilePath);
}
public async UniTask Load(string levelId)
{
BIManager.Instance.TrackEventLevel(cfg.BI.Event.level_enter);
await LoadLevelConfig(levelId);
CheckFirstEnterLevel();
}
public void Update(float deltaTime)
{
PlankManager.Instance.Update(deltaTime);
}
private void CheckFirstEnterLevel()
{
var passLevel = AppInfoManager.Instance.AppUserInfo.PassLevel;
LevelManager.Instance.IsNewbieGuide = passLevel.Equals("level0");
}
}
}
public class AllLevelData
{
public string LevelID;
[JsonConstructor]
public AllLevelData()
{
}
public AllLevelData(string LevelID)
{
this.LevelID = LevelID;
}
}