| | |
| | | |
| | | public int[] selectCtgIds; |
| | | public int[][] selectGainItemList; |
| | | public int limitPopCnt; |
| | | public int limitPopCd; |
| | | public event Action OnSelectCtgIdIndexChangeEvent; |
| | | |
| | | public bool isLogShow = true; |
| | |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitializeEventOnRelogin; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | GlobalTimeEvent.Instance.secondEvent += OnSecondEvent; |
| | | |
| | | var config = FuncConfigConfig.Get("TimingGift"); |
| | | limitPopCnt = int.Parse(config.Numerical1); |
| | | limitPopCd = int.Parse(config.Numerical2); |
| | | } |
| | | |
| | | public override void Release() |
| | |
| | | return showGiftIdList; |
| | | } |
| | | |
| | | HashSet<int> typeHashSet; |
| | | int GetPopCnt() |
| | | { |
| | | if (typeHashSet == null) |
| | | typeHashSet = new HashSet<int>(); |
| | | |
| | | typeHashSet.Clear(); |
| | | if (showGiftIdList.IsNullOrEmpty()) |
| | | return 0; |
| | | |
| | | for (int i = 0; i < showGiftIdList.Count; i++) |
| | | { |
| | | int id = showGiftIdList[i]; |
| | | if (!TimingGiftConfig.TryGetTimingGiftConfig(id, out var config)) |
| | | continue; |
| | | typeHashSet.Add(config.GiftType); |
| | | } |
| | | return typeHashSet.Count; |
| | | } |
| | | |
| | | bool IsInLimitCd() |
| | | { |
| | | if (lastTriggerTimeDict.IsNullOrEmpty()) |
| | | return false; |
| | | int lastTime = lastTriggerTimeDict.Values.Max(); |
| | | return TimeUtility.AllSeconds - lastTime <= limitPopCd; |
| | | } |
| | | |
| | | public void TryAdd(int type) |
| | | { |
| | | |
| | | if (NewBieCenter.Instance.inGuiding) |
| | | { |
| | | #if UNITY_EDITOR |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!IsTodayUnlimited(type)) |
| | | { |
| | | #if UNITY_EDITOR |
| | | if (isLogShow) |
| | | { |
| | | int lastTriggerTime = lastTriggerTimeDict[type]; |
| | | DateTime lastTime = TimeUtility.GetTime((uint)lastTriggerTime); |
| | | Debug.Log($"[TimingGift] TryPop:触发Return,今天已弹出过{type}类型的礼包,该类型上次弹出时间为{lastTime:yyyy-MM-dd HH:mm:ss}"); |
| | | } |
| | | #endif |
| | | return; |
| | | } |
| | | |
| | | if (!TimingGiftConfig.TryGetTypeToGiftIdList(type, out List<int> giftIdList)) |
| | | { |
| | | #if UNITY_EDITOR |
| | |
| | | #endif |
| | | return; |
| | | } |
| | | |
| | | int popCount = GetPopCnt(); |
| | | if (limitPopCnt <= popCount) |
| | | { |
| | | #if UNITY_EDITOR |
| | | if (isLogShow) |
| | | { |
| | | Debug.Log($"[TimingGift] TryPop:触发Return,今日已达到限制次数"); |
| | | } |
| | | #endif |
| | | return; |
| | | } |
| | | |
| | | bool isInLimitCd = IsInLimitCd(); |
| | | if (isInLimitCd) |
| | | { |
| | | #if UNITY_EDITOR |
| | | if (isLogShow) |
| | | { |
| | | Debug.Log($"[TimingGift] TryPop:触发Return,礼包触发冷却时间中"); |
| | | } |
| | | #endif |
| | | return; |
| | | } |
| | | |
| | | if (!IsTodayUnlimited(type)) |
| | | { |
| | | #if UNITY_EDITOR |
| | | if (isLogShow) |
| | | { |
| | | int lastTriggerTime = lastTriggerTimeDict[type]; |
| | | Debug.Log($"[TimingGift] TryPop:触发Return,今天已弹出过{type}类型的礼包,该类型上次弹出时间为{TimeUtility.GetTime((uint)lastTriggerTime):yyyy-MM-dd HH:mm:ss}"); |
| | | } |
| | | #endif |
| | | return; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | bool isChange = false; |
| | | for (int i = 0; i < giftIdList.Count; i++) |
| | |
| | | |
| | | lastTriggerTimeDict = loadDict; |
| | | InitCurrectTimingGiftIdList(new List<int>(loadDict.Keys)); |
| | | |
| | | |
| | | #if UNITY_EDITOR |
| | | if (isLogShow) |
| | | { |