2024-06-12 15:01:54 +08:00
|
|
|
using System;
|
|
|
|
using PhxhSDK;
|
|
|
|
using UnityEngine;
|
|
|
|
using Framework.BI;
|
|
|
|
using PhxhSDK.Phxh;
|
|
|
|
using Framework.Event;
|
|
|
|
using Framework.Manager;
|
|
|
|
using Framework.Constants;
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Constants = Framework.Constants.Constants;
|
|
|
|
|
|
|
|
namespace Gameplay.Manager
|
|
|
|
{
|
|
|
|
public class LevelSelectManager : Singlenton<LevelSelectManager>, IInitable
|
|
|
|
{
|
|
|
|
private List<AllLevelData> _allLevels;
|
|
|
|
public GameObject CurBtnObj;
|
|
|
|
public GameObject GfxSelectLevel;
|
|
|
|
|
|
|
|
private string CurPassLevel
|
|
|
|
{
|
|
|
|
get { return AppInfoManager.Instance.AppUserInfo.PassLevel; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
AppInfoManager.Instance.AppUserInfo.PassLevel = value;
|
|
|
|
|
|
|
|
AppInfoManager.Instance.SetRemoteData(0, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<AllLevelData> CurAllLevelDatas => _allLevels;
|
|
|
|
public int CurPassLevelIndex;
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
{
|
|
|
|
EventManager.Instance.Register(EventManager.EventName.RefreshGameData, UpdateLevelInfo);
|
|
|
|
_allLevels = new List<AllLevelData>() { new AllLevelData("level0") };
|
|
|
|
UpdateLevelInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
public async UniTask InitAsync()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var configFilePath = string.Format(Constants.LevelListPath);
|
|
|
|
_allLevels = await JsonHelper.LoadFromAddressable<List<AllLevelData>>(configFilePath);
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
DebugUtil.LogError("LevelSelectMgr.Init Error: {0}", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void UpdateLevelInfo()
|
|
|
|
{
|
|
|
|
CurPassLevelIndex = int.Parse(CurPassLevel.Substring("level".Length));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SaveNewPassLevel(string levelID)
|
|
|
|
{
|
|
|
|
var id = int.Parse(levelID.Substring("level".Length));
|
|
|
|
if (CurPassLevelIndex < id)
|
|
|
|
{
|
|
|
|
ShopManager.Instance.CurCoin += LevelConstants.RewardCoin;
|
|
|
|
CurPassLevelIndex = id;
|
|
|
|
CurPassLevel = levelID;
|
|
|
|
CurPassLevelIndex = int.Parse(CurPassLevel.Substring("level".Length));
|
|
|
|
StorageManager.Instance.SyncForce = true;
|
|
|
|
StorageManager.Instance.SyncRemoteForce = true;
|
|
|
|
BIManager.Instance.TrackEvent(cfg.BI.Event.main_unlock_level, (id + 1).ToString());
|
|
|
|
LevelManager.Instance.CanGfxCoin = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ClearFile()
|
|
|
|
{
|
|
|
|
PlayerPrefs.DeleteAll();
|
|
|
|
PlayerPrefs.Save();
|
|
|
|
UpdateLevelInfo();
|
|
|
|
}
|
|
|
|
|
2024-06-27 15:40:40 +08:00
|
|
|
public void PassAllLevel(int levelId = 0)
|
2024-06-12 15:01:54 +08:00
|
|
|
{
|
2024-06-27 15:40:40 +08:00
|
|
|
var id = levelId == 0 ? _allLevels.Count : levelId;
|
|
|
|
var level = $"level{id}";
|
2024-06-12 15:01:54 +08:00
|
|
|
SaveNewPassLevel(level);
|
|
|
|
UpdateLevelInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Release()
|
|
|
|
{
|
|
|
|
EventManager.Instance.Unregister(EventManager.EventName.RefreshGameData, UpdateLevelInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Update(float deltaTime)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|