| | |
| | | |
| | | public class HeroReturnManager : GameSystemManager<HeroReturnManager>, IOpenServerActivity |
| | | { |
| | | // 缓存的ZhanLingType列表(从ActHeroAppearConfig获取,后续不变) |
| | | private static List<int> zhanLingTypeList = null; |
| | | public int[] xbGridArr; |
| | | public Dictionary<int, int[][]> heroQaulityColor; |
| | | public int[][] seeArr; |
| | | public int subVulue; |
| | | public override void Init() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitializeEventOnRelogin; |
| | |
| | | GeneralActInfoManager.Instance.OnUpdateActSignInfosEvent += OnUpdateActSignInfosEvent; |
| | | HeroManager.Instance.onHeroChangeEvent += OnHeroChangeEvent; |
| | | TimeMgr.Instance.OnDayEvent += OnDayEvent; |
| | | BattlePassManager.Instance.BattlePassDataUpdateEvent += OnBattlePassDataUpdate; |
| | | |
| | | var config = FuncConfigConfig.Get("HeroAppear"); |
| | | xbGridArr = JsonMapper.ToObject<int[]>(config.Numerical1); |
| | | subVulue = int.Parse(config.Numerical4); |
| | | |
| | | config = FuncConfigConfig.Get("HeroReturn"); |
| | | heroQaulityColor = ConfigParse.ParseIntArray2Dict(config.Numerical1); |
| | | seeArr = JsonMapper.ToObject<int[][]>(config.Numerical2); |
| | | |
| | | |
| | | InitRedPointId(); |
| | | |
| | | |
| | | } |
| | | |
| | | public void SetheroQaulityColor(GradientText text, int qaulity) |
| | |
| | | GeneralActInfoManager.Instance.OnUpdateActSignInfosEvent -= OnUpdateActSignInfosEvent; |
| | | HeroManager.Instance.onHeroChangeEvent -= OnHeroChangeEvent; |
| | | TimeMgr.Instance.OnDayEvent -= OnDayEvent; |
| | | BattlePassManager.Instance.BattlePassDataUpdateEvent -= OnBattlePassDataUpdate; |
| | | } |
| | | |
| | | private void OnDayEvent() |
| | |
| | | UIManager.Instance.CloseWindow<HeroReturnPopWin>(); |
| | | if (UIManager.Instance.IsOpened<HeroReturnWin>()) |
| | | UIManager.Instance.CloseWindow<HeroReturnWin>(); |
| | | gameRecDict.Clear(); |
| | | UpdateRedpoint(); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (type == operaType && state == 0) |
| | | { |
| | | gameRecDict.Clear(); |
| | | isSendFirst = true; |
| | | onStateUpdate?.Invoke(activityID); |
| | | TryPopWin(); |
| | | UpdateRedpoint(); |
| | |
| | | public Redpoint starUpRedpoint; |
| | | public Redpoint shopRedpoint; |
| | | public Redpoint giftRedpoint; |
| | | public Redpoint zhanLingRedpoint; |
| | | public void InitRedPointId() |
| | | { |
| | | checkInRedpoint ??= new Redpoint(MainRedDot.HeroReturnRepoint, GetRedPointId(HeroReturnRedPointType.CheckIn)); |
| | | starUpRedpoint ??= new Redpoint(MainRedDot.HeroReturnRepoint, GetRedPointId(HeroReturnRedPointType.StarUp)); |
| | | shopRedpoint ??= new Redpoint(MainRedDot.HeroReturnRepoint, GetRedPointId(HeroReturnRedPointType.Shop)); |
| | | giftRedpoint ??= new Redpoint(MainRedDot.HeroReturnRepoint, GetRedPointId(HeroReturnRedPointType.Gift)); |
| | | zhanLingRedpoint ??= new Redpoint(MainRedDot.HeroReturnRepoint, GetRedPointId(HeroReturnRedPointType.ZhanLing)); |
| | | } |
| | | |
| | | public void UpdateRedpoint() |
| | |
| | | starUpRedpoint.state = RedPointState.None; |
| | | shopRedpoint.state = RedPointState.None; |
| | | giftRedpoint.state = RedPointState.None; |
| | | zhanLingRedpoint.state = RedPointState.None; |
| | | |
| | | if (!IsHeroReturnOpen()) return; |
| | | |
| | |
| | | if (HasGiftCanHave())//皇权礼包 |
| | | { |
| | | giftRedpoint.state = RedPointState.Simple; |
| | | } |
| | | if (HasZhanLingCanHave())//战令 |
| | | { |
| | | zhanLingRedpoint.state = RedPointState.Simple; |
| | | } |
| | | } |
| | | #endregion |
| | |
| | | LocalSave.SetBool(GetCallSkipKey(cfgID, startDate, endDate), value); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 当前招募选中的武将ID |
| | | /// </summary> |
| | |
| | | if (config == null || config.ActHeroIDList?.Length <= callHeroIndex) return 0; |
| | | |
| | | return config.ActHeroIDList[callHeroIndex]; |
| | | } |
| | | public int GetLuckValueAward(int type) |
| | | { |
| | | XBTypeInfo typeInfo = HappyXBModel.Instance.GetXBInfoByType(type); |
| | | if (typeInfo == null) return 0; |
| | | |
| | | var xbConfig = HappyXBModel.Instance.GetXBItemConfigByType(type); |
| | | var luckList = xbConfig.LuckyItemRateInfo.Keys.ToList(); |
| | | luckList.Sort(); |
| | | for (int i = 0; i < luckList.Count; i++) |
| | | { |
| | | var luckyValue = typeInfo.luckValue; |
| | | if (luckyValue < luckList[i]) |
| | | { |
| | | return luckList[i]; |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public int GetNextXBCountForBigAward(int type) |
| | | { |
| | | XBTypeInfo typeInfo = HappyXBModel.Instance.GetXBInfoByType(type); |
| | | if (typeInfo == null) return 0; |
| | | |
| | | var xbConfig = HappyXBModel.Instance.GetXBItemConfigByType(type); |
| | | var luckList = xbConfig.LuckyItemRateInfo.Keys.ToList(); |
| | | luckList.Sort(); |
| | | for (int i = 0; i < luckList.Count; i++) |
| | | { |
| | | var luckyValue = typeInfo.luckValue; |
| | | if (luckyValue < luckList[i]) |
| | | { |
| | | return luckList[i] - luckyValue; |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | public int GetFirstHeroId() |
| | |
| | | } |
| | | |
| | | #endregion |
| | | #region 战令 |
| | | /// <summary> |
| | | /// 武将登场战令类型(从配置实时获取) |
| | | /// </summary> |
| | | public int ZhanLingType => GetCurrentZhanLingType(); |
| | | |
| | | /// <summary> |
| | | /// 获取当前战令类型 |
| | | /// </summary> |
| | | private int GetCurrentZhanLingType() |
| | | { |
| | | var act = GetOperationHeroAppearInfo(); |
| | | if (act == null) |
| | | return 0; |
| | | |
| | | var config = ActHeroAppearConfig.Get(act.CfgID); |
| | | return config?.ActZhanlingType ?? 0; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 武将登场战令功能ID |
| | | /// </summary> |
| | | public const int ZhanLingFuncId = 63; |
| | | |
| | | /// <summary> |
| | | /// 战令数据更新事件 |
| | | /// </summary> |
| | | public event Action OnZhanLingUpdateEvent; |
| | | |
| | | private void OnBattlePassDataUpdate(int type) |
| | | { |
| | | if (type == ZhanLingType) |
| | | { |
| | | OnZhanLingUpdateEvent?.Invoke(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取武将登场战令的当前进度值 |
| | | /// </summary> |
| | | public int GetZhanLingValue() |
| | | { |
| | | var data = BattlePassManager.Instance.GetBattlePassData(ZhanLingType); |
| | | return data != null ? (int)data.value1 : 0; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断指定类型是否为ZhanLing类型(缓存查询) |
| | | /// </summary> |
| | | public static bool IsZhanLingType(int type) |
| | | { |
| | | if (zhanLingTypeList == null) |
| | | { |
| | | zhanLingTypeList = ActHeroAppearConfig.GetValues() |
| | | .Select(x => x.ActZhanlingType) |
| | | .Where(x => x > 0) |
| | | .Distinct() |
| | | .ToList(); |
| | | } |
| | | return zhanLingTypeList.Contains(type); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取指定ZhanLing类型的进度值 |
| | | /// </summary> |
| | | public static int GetZhanLingValueByType(int zhanLingType) |
| | | { |
| | | var data = BattlePassManager.Instance.GetBattlePassData(zhanLingType); |
| | | return data != null ? (int)data.value1 : 0; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断武将登场战令的指定等级是否达成 |
| | | /// </summary> |
| | | public bool IsZhanLingNeedValueOk(int needValue) |
| | | { |
| | | return GetZhanLingValue() >= needValue; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取武将登场战令的购买状态 |
| | | /// 0 没购买进阶和玄级 1 购买了进阶没买玄级 2 购买了玄级没买进阶 3 购买了进阶和玄级 |
| | | /// </summary> |
| | | public int GetZhanLingBuyState() |
| | | { |
| | | var data = BattlePassManager.Instance.GetBattlePassData(ZhanLingType); |
| | | if (data == null) |
| | | return 0; |
| | | |
| | | bool isBuyPaid = data.isActivite > 0; |
| | | bool isBuyPaidH = data.isActiviteH > 0; |
| | | if (isBuyPaid && isBuyPaidH) |
| | | return 3; |
| | | if (isBuyPaid) |
| | | return 1; |
| | | if (isBuyPaidH) |
| | | return 2; |
| | | return 0; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 是否有可领取的战令奖励 |
| | | /// </summary> |
| | | public bool HasZhanLingCanHave() |
| | | { |
| | | var data = BattlePassManager.Instance.GetBattlePassData(ZhanLingType); |
| | | if (data == null) |
| | | return false; |
| | | |
| | | var dict = ZhanlingConfig.GetTypeToIDDict(ZhanLingType); |
| | | if (dict.IsNullOrEmpty()) |
| | | return false; |
| | | |
| | | int buyState = GetZhanLingBuyState(); |
| | | bool isBuyPaid = buyState == 1 || buyState == 3; |
| | | bool isBuyPaidH = buyState == 2 || buyState == 3; |
| | | |
| | | foreach (var kvp in dict) |
| | | { |
| | | int needValue = kvp.Key; |
| | | // 检查免费奖励 |
| | | int freeState = GetZhanLingFreeGiftState(needValue); |
| | | if (freeState == 1) |
| | | return true; |
| | | |
| | | // 检查普通奖励(需要已购买进阶) |
| | | if (isBuyPaid) |
| | | { |
| | | int paidState = GetZhanLingPaidGiftState(needValue); |
| | | if (paidState == 1) |
| | | return true; |
| | | } |
| | | |
| | | // 检查高级奖励(需要已购买玄级) |
| | | if (isBuyPaidH) |
| | | { |
| | | int paidHState = GetZhanLingPaidGiftHState(needValue); |
| | | if (paidHState == 1) |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取武将登场战令免费奖励状态 |
| | | /// 0 不能领 1 未领取 2 已领取 |
| | | /// </summary> |
| | | public int GetZhanLingFreeGiftState(int needValue) |
| | | { |
| | | var data = BattlePassManager.Instance.GetBattlePassData(ZhanLingType); |
| | | if (data == null) |
| | | return 0; |
| | | var totalValue = BattlePassManager.Instance.GetTotalValue(ZhanLingType); |
| | | return BattlePassManager.Instance.GetBPCellAwardState(data, totalValue, needValue, 0); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取武将登场战令普通奖励状态 |
| | | /// 0 不能领 1 未领取 2 已领取 |
| | | /// </summary> |
| | | public int GetZhanLingPaidGiftState(int needValue) |
| | | { |
| | | var data = BattlePassManager.Instance.GetBattlePassData(ZhanLingType); |
| | | if (data == null) |
| | | return 0; |
| | | var totalValue = BattlePassManager.Instance.GetTotalValue(ZhanLingType); |
| | | return BattlePassManager.Instance.GetBPCellAwardState(data, totalValue, needValue, 1); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取武将登场战令高级奖励状态 |
| | | /// 0 不能领 1 未领取 2 已领取 |
| | | /// </summary> |
| | | public int GetZhanLingPaidGiftHState(int needValue) |
| | | { |
| | | var data = BattlePassManager.Instance.GetBattlePassData(ZhanLingType); |
| | | if (data == null) |
| | | return 0; |
| | | var totalValue = BattlePassManager.Instance.GetTotalValue(ZhanLingType); |
| | | return BattlePassManager.Instance.GetBPCellAwardState(data, totalValue, needValue, 2); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 一键领取武将登场战令所有可领取奖励 |
| | | /// </summary> |
| | | public void HaveAllZhanLingGift() |
| | | { |
| | | var data = BattlePassManager.Instance.GetBattlePassData(ZhanLingType); |
| | | if (data == null) |
| | | return; |
| | | |
| | | if (PackManager.Instance.GetEmptyGridCount(PackType.Item) < 1) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("GeRen_lhs_202580"); |
| | | return; |
| | | } |
| | | |
| | | var totalValue = BattlePassManager.Instance.GetTotalValue(ZhanLingType); |
| | | BattlePassManager.Instance.GetAllAward(data, ZhanLingType, totalValue); |
| | | } |
| | | #endregion |
| | | |
| | | #region 战令预览购买 |
| | | /// <summary> |
| | | /// 当前预览的战令类型 |
| | | /// </summary> |
| | | public int previewZhanLingType { get; private set; } |
| | | |
| | | /// <summary> |
| | | /// 当前预览的礼包类型 1 普通战令礼包 2 高级战令礼包 |
| | | /// </summary> |
| | | public int previewGiftType { get; private set; } |
| | | |
| | | /// <summary> |
| | | /// 显示战令购买预览界面 |
| | | /// </summary> |
| | | public void ShowZhanLingHBuy(int zhanLingType, int showGiftType) |
| | | { |
| | | previewZhanLingType = zhanLingType; |
| | | previewGiftType = showGiftType; |
| | | |
| | | if (showGiftType == 1) |
| | | { |
| | | UIManager.Instance.OpenWindow<HeroReturnZhanLingPreviewWin>(); |
| | | } |
| | | else if (showGiftType == 2) |
| | | { |
| | | UIManager.Instance.OpenWindow<HeroReturnZhanLingPreviewHWin>(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取当前预览类型的充值ID |
| | | /// </summary> |
| | | public int GetPreviewCtgID() |
| | | { |
| | | int ctgid = 0; |
| | | if (previewGiftType == 1) |
| | | { |
| | | ctgid = BattlePassManager.Instance.GetCTGIDByType(previewZhanLingType); |
| | | } |
| | | else if (previewGiftType == 2) |
| | | { |
| | | // 高级战令使用 Numerical3 |
| | | var config = FuncConfigConfig.Get("Zhanling"); |
| | | if (config != null) |
| | | { |
| | | var dict = ConfigParse.ParseIntArrayDict(config.Numerical3); |
| | | if (dict.TryGetValue(previewZhanLingType, out var arr) && arr.Length > 0) |
| | | { |
| | | ctgid = arr[0]; |
| | | } |
| | | } |
| | | } |
| | | return ctgid; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取购买后所有等级的奖励 |
| | | /// </summary> |
| | | /// <param name="maxCountPerSlot">每个相同的itemid每个格子最大同时显示的数量</param> |
| | | public List<Item> GetPreviewGiftAllItem(int maxCountPerSlot = 20) |
| | | { |
| | | List<int> collectList = new List<int>(); |
| | | var dict = ZhanlingConfig.GetTypeToIDDict(previewZhanLingType); |
| | | if (dict.IsNullOrEmpty()) |
| | | return new List<Item>(); |
| | | |
| | | var arr = dict.Keys.ToArray(); |
| | | for (int i = 0; i < arr.Length; i++) |
| | | { |
| | | int needValue = arr[i]; |
| | | int zhanLingId = dict[needValue]; |
| | | collectList.Add(zhanLingId); |
| | | } |
| | | return CollectPreviewItems(collectList, maxCountPerSlot); |
| | | } |
| | | |
| | | private List<Item> CollectPreviewItems(List<int> collectList, int maxCountPerSlot) |
| | | { |
| | | Dictionary<int, int> resultDict = new Dictionary<int, int>(); |
| | | for (int i = 0; i < collectList.Count; i++) |
| | | { |
| | | int zhanLingId = collectList[i]; |
| | | int[][] itemArr = GetPreviewItemArr(zhanLingId, previewGiftType); |
| | | if (itemArr.IsNullOrEmpty()) |
| | | continue; |
| | | |
| | | for (int j = 0; j < itemArr.Length; j++) |
| | | { |
| | | int itemID = itemArr[j][0]; |
| | | int count = itemArr[j][1]; |
| | | if (resultDict.ContainsKey(itemID)) |
| | | resultDict[itemID] += count; |
| | | else |
| | | resultDict[itemID] = count; |
| | | } |
| | | } |
| | | List<Item> result = GetItemListByDict(resultDict, maxCountPerSlot); |
| | | result.Sort(CmpPreviewItem); |
| | | return result; |
| | | } |
| | | |
| | | private int[][] GetPreviewItemArr(int zhanLingId, int showGiftType) |
| | | { |
| | | var config = ZhanlingConfig.Get(zhanLingId); |
| | | if (config == null) |
| | | return new int[][] { }; |
| | | |
| | | if (showGiftType == 1) |
| | | return config.ZLRewardItemList; |
| | | if (showGiftType == 2) |
| | | return config.ZLRewardItemListH; |
| | | return new int[][] { }; |
| | | } |
| | | |
| | | private List<Item> GetItemListByDict(Dictionary<int, int> dict, int maxCountPerSlot) |
| | | { |
| | | List<Item> result = new List<Item>(); |
| | | var arr = dict.Keys.ToArray(); |
| | | for (int i = 0; i < arr.Length; i++) |
| | | { |
| | | int itemID = arr[i]; |
| | | int count = dict[itemID]; |
| | | |
| | | // 根据maxCountPerSlot拆分数量,每个Item最多显示maxCountPerSlot个 |
| | | int slotCount = Mathf.CeilToInt((float)count / maxCountPerSlot); |
| | | for (int s = 0; s < slotCount; s++) |
| | | { |
| | | int itemCount = Mathf.Min(maxCountPerSlot, count - s * maxCountPerSlot); |
| | | result.Add(new Item(itemID, itemCount)); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private int CmpPreviewItem(Item a, Item b) |
| | | { |
| | | int quality1 = ItemConfig.Get(a.id).ItemColor; |
| | | int quality2 = ItemConfig.Get(b.id).ItemColor; |
| | | if (quality1 != quality2) |
| | | return quality2.CompareTo(quality1); |
| | | return a.countEx.CompareTo(b.countEx); |
| | | } |
| | | #endregion |
| | | #region 获奖记录 |
| | | public static readonly int RecordType = 311; |
| | | |
| | |
| | | StarUp = 2, |
| | | Shop = 3, |
| | | Gift = 4, |
| | | ZhanLing = 5, |
| | | } |
| | | |
| | | public class HeroReturnGameRec |