121 lines
3.5 KiB
C#
121 lines
3.5 KiB
C#
using System.Collections.Generic;
|
|
using cfg.BattlePassCfg;
|
|
using System.Linq;
|
|
using Framework;
|
|
using PhxhSDK;
|
|
|
|
public class BattlePassManager : Singlenton<BattlePassManager>
|
|
{
|
|
public struct LevelReward
|
|
{
|
|
public int BasicRewardID;
|
|
public int BasicRewardCount;
|
|
public int AdvancedRewardID;
|
|
public int AdvancedRewardCount;
|
|
|
|
public LevelReward(DataBattlePassRewards rewardsData)
|
|
{
|
|
var basicReward = rewardsData.BasicReward;
|
|
var advancedReward = rewardsData.AdvancedReward;
|
|
if (basicReward.Length != 2 || advancedReward.Length != 2)
|
|
{
|
|
DebugUtil.LogError("赛季{0} 的 {1} 等级奖励配置错误", Instance.curBattlePassID,
|
|
rewardsData.PassLevel);
|
|
}
|
|
|
|
BasicRewardID = basicReward[0];
|
|
BasicRewardCount = basicReward[1];
|
|
AdvancedRewardID = advancedReward[0];
|
|
AdvancedRewardCount = advancedReward[1];
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通行证等级结构
|
|
/// </summary>
|
|
public struct BattlePassLevel
|
|
{
|
|
/// <summary>
|
|
/// 普通等级
|
|
/// </summary>
|
|
public int NormalLevel;
|
|
|
|
/// <summary>
|
|
/// 高级等级
|
|
/// </summary>
|
|
public int AdvancedLevel;
|
|
|
|
public BattlePassLevel(int normalLevel, int advancedLevel)
|
|
{
|
|
NormalLevel = normalLevel;
|
|
AdvancedLevel = advancedLevel;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当前赛季通行证数据
|
|
/// </summary>
|
|
private DataBattlePass curBattlePassData;
|
|
|
|
public DataBattlePass CurBattlePassData => curBattlePassData;
|
|
|
|
/// <summary>
|
|
/// 当前赛季通行证ID
|
|
/// </summary>
|
|
private int curBattlePassID;
|
|
|
|
private DataBattlePassRewards curBattlePassRewards;
|
|
|
|
/// <summary>
|
|
/// 当前赛季的等级奖励
|
|
/// </summary>
|
|
private Dictionary<int, LevelReward> curLevelRewards;
|
|
|
|
/// <summary>
|
|
/// 当前解锁等级
|
|
/// </summary>
|
|
private BattlePassLevel unLockLevel;
|
|
|
|
/// <summary>
|
|
/// 当前已经领取奖励的等级
|
|
/// </summary>
|
|
private BattlePassLevel getRewardLevel;
|
|
|
|
public BattlePassLevel UnLockLevel => unLockLevel;
|
|
|
|
public BattlePassLevel GetRewardLevel => getRewardLevel;
|
|
|
|
public Dictionary<int, LevelReward> CurLevelRewards => curLevelRewards;
|
|
|
|
public void Init()
|
|
{
|
|
curLevelRewards = new Dictionary<int, LevelReward>();
|
|
|
|
// TODO 从服务器获取数据
|
|
var cfg = TableManager.Instance.Tables.BattlePassConfig.DataList;
|
|
if (cfg.Count <= 0) return;
|
|
curBattlePassData = cfg[0];
|
|
curBattlePassID = curBattlePassData.ID;
|
|
|
|
// TODO 从服务器获取等级相关数据
|
|
unLockLevel = new BattlePassLevel(10, 10);
|
|
getRewardLevel = new BattlePassLevel(8, 7);
|
|
|
|
// 筛选当前赛季奖励
|
|
var rewardsList = TableManager.Instance.Tables.BattlePassRewardsConfig.DataList;
|
|
var rewardsData = rewardsList.Where(data => data.ID == curBattlePassID).ToList();
|
|
|
|
if (rewardsData.Count != curBattlePassData.MaxPurchaseLevel + 1)
|
|
DebugUtil.LogError("赛季 {0} 没有配置足够对应的等级奖励", curBattlePassID);
|
|
|
|
foreach (var data in rewardsData)
|
|
{
|
|
var levelReward = new LevelReward(data);
|
|
curLevelRewards[data.PassLevel] = levelReward;
|
|
}
|
|
}
|
|
|
|
public void Release()
|
|
{
|
|
}
|
|
} |