145 lines
4.4 KiB
C#
145 lines
4.4 KiB
C#
using System.Collections.Generic;
|
|
using cfg.BattlePassCfg;
|
|
using Gameplay.Net;
|
|
using System.Linq;
|
|
using Framework;
|
|
using PhxhSDK;
|
|
using NLDPB;
|
|
|
|
public class BattlePassManager : Singlenton<BattlePassManager>
|
|
{
|
|
public static readonly int ADVANCED_ID = 1;
|
|
public static readonly int PREMIUM_ADVANCED_ID = 2;
|
|
|
|
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;
|
|
BasicRewardID = basicReward[0];
|
|
BasicRewardCount = basicReward[1];
|
|
AdvancedRewardID = advancedReward[0];
|
|
AdvancedRewardCount = advancedReward[1];
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当前赛季通行证ID
|
|
/// </summary>
|
|
private int curBattlePassID;
|
|
|
|
/// <summary>
|
|
/// 当前赛季通行证数据
|
|
/// </summary>
|
|
private DataBattlePass curBattlePassData;
|
|
|
|
public DataBattlePass CurBattlePassData => curBattlePassData;
|
|
|
|
/// <summary>
|
|
/// 当前赛季的等级奖励
|
|
/// </summary>
|
|
private Dictionary<int, LevelReward> curLevelRewards;
|
|
|
|
public Dictionary<int, LevelReward> CurLevelRewards => curLevelRewards;
|
|
|
|
/// <summary>
|
|
/// 醒目等级
|
|
/// </summary>
|
|
private List<int> specialRewardLevels;
|
|
|
|
public List<int> SpecialRewardLevels => specialRewardLevels;
|
|
|
|
public bool IsDebug = false;
|
|
|
|
public void Init()
|
|
{
|
|
curBattlePassID = (int)Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassId);
|
|
|
|
// 当前赛季配置
|
|
var cfg = TableManager.Instance.Tables.BattlePassConfig.DataMap;
|
|
if (!cfg.TryGetValue(curBattlePassID, out var dataBattlePass))
|
|
{
|
|
DebugUtil.LogError("服务器下发的赛季ID[{0}] ,没有对应配置, 使用默认配置", curBattlePassID);
|
|
curBattlePassData = cfg[0];
|
|
curBattlePassID = curBattlePassData.ID;
|
|
}
|
|
|
|
curBattlePassData = dataBattlePass;
|
|
if (curBattlePassData == null) return;
|
|
|
|
// 筛选当前赛季奖励
|
|
curLevelRewards = new Dictionary<int, LevelReward>();
|
|
var rewardsList = TableManager.Instance.Tables.BattlePassRewardsConfig.DataList;
|
|
var rewardsData = rewardsList.Where(data => data.ID == curBattlePassID).ToList();
|
|
|
|
foreach (var data in rewardsData)
|
|
{
|
|
if (data.BasicReward.Length != 2 || data.AdvancedReward.Length != 2)
|
|
{
|
|
DebugUtil.LogError("赛季{0} 的 {1} 等级奖励配置错误", curBattlePassID, data.PassLevel);
|
|
continue;
|
|
}
|
|
|
|
var levelReward = new LevelReward(data);
|
|
curLevelRewards[data.PassLevel] = levelReward;
|
|
}
|
|
|
|
// 醒目奖励等级
|
|
specialRewardLevels = curBattlePassData.SpecialRewardLevel;
|
|
specialRewardLevels.Sort();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前经验点数
|
|
/// </summary>
|
|
public int GetPointItemCount()
|
|
{
|
|
return (int)Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassExp);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取通行证账号等级
|
|
/// </summary>
|
|
public int GetBattlePassLevel()
|
|
{
|
|
return (int)Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassLevel);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取账号已领奖等级
|
|
/// </summary>
|
|
public int GetNormalRewardLevel()
|
|
{
|
|
return (int)Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassRewardLevel);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取高级账号已领奖等级
|
|
/// </summary>
|
|
public int GetAdvancedRewardLevel()
|
|
{
|
|
return (int)Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassAdvancedRewardLevel);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否开通高级奖励
|
|
/// </summary>
|
|
public bool IsAdvancedAccount()
|
|
{
|
|
return Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassIsAdvanced) >= 1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取账号状态 0-无 1-高级账号 2-尊享版高级账号
|
|
/// </summary>
|
|
public int GetAdvancedAccount()
|
|
{
|
|
return (int)Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassIsAdvanced);
|
|
}
|
|
} |