154 lines
5.0 KiB
C#
154 lines
5.0 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 AdvancedID = 1;
|
||
public static readonly int PremiumAdvancedID = 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;
|
||
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>
|
||
/// 当前赛季通行证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 void Init()
|
||
{
|
||
//EventManager.Instance.Register(EventManager.EventName.BattlePassGetAllReward, RefreshGetRewardLevel);
|
||
|
||
curBattlePassID = (int)Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassId);
|
||
/*DebugUtil.LogError("赛季ID:{0},是否购买VIP标识:{1},当前等级:{2},普通领取等级:{3},VIP领取等级:{4}",
|
||
Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassId),
|
||
Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassIsAdvanced),
|
||
Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassLevel),
|
||
Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassRewardLevel),
|
||
Actor.Instance.Logic.GetCount((uint)LogicID.BattlePassAdvancedRewardLevel));*/
|
||
|
||
// 当前赛季配置
|
||
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;
|
||
|
||
// 筛选当前赛季奖励
|
||
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)
|
||
{
|
||
var levelReward = new LevelReward(data);
|
||
curLevelRewards[data.PassLevel] = levelReward;
|
||
}
|
||
|
||
// 醒目奖励等级
|
||
specialRewardLevels = curBattlePassData.SpecialRewardLevel;
|
||
specialRewardLevels.Sort();
|
||
}
|
||
|
||
public void Release()
|
||
{
|
||
}
|
||
|
||
/// <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);
|
||
}
|
||
} |