| | |
| | | |
| | | public int[] selectCtgIds; |
| | | public int[][] selectGainItemList; |
| | | public int limitPopCnt; |
| | | public int limitShowCnt; |
| | | 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); |
| | | limitShowCnt = int.Parse(config.Numerical2); |
| | | limitPopCd = int.Parse(config.Numerical3); |
| | | } |
| | | |
| | | public override void Release() |
| | |
| | | return showGiftIdList; |
| | | } |
| | | |
| | | HashSet<int> typeHashSet; |
| | | int GetShowCnt() |
| | | { |
| | | 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; |
| | | } |
| | | |
| | | int GetPopCnt() |
| | | { |
| | | if (lastTriggerTimeDict.IsNullOrEmpty()) |
| | | return 0; |
| | | int cnt = 0; |
| | | foreach (var item in lastTriggerTimeDict) |
| | | { |
| | | int type = item.Key; |
| | | int time = item.Value; |
| | | var timeData = TimeUtility.GetTime((uint)time); |
| | | DateTime nowTime = TimeUtility.ServerNow; |
| | | if (timeData.Day == nowTime.Day && timeData.Month == nowTime.Month && timeData.Year == nowTime.Year) |
| | | { |
| | | cnt += 1; |
| | | } |
| | | } |
| | | return cnt; |
| | | } |
| | | |
| | | 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 |
| | | if (isLogShow) |
| | | { |
| | | Debug.Log($"[TimingGift] TryPop:触发Return,表格中没有找到{type}类型的礼包ID"); |
| | | } |
| | | #endif |
| | | return; |
| | | } |
| | | int showCnt = GetShowCnt(); |
| | | |
| | | if (limitShowCnt <= showCnt) |
| | | { |
| | | #if UNITY_EDITOR |
| | | if (isLogShow) |
| | | { |
| | | Debug.Log($"[TimingGift] TryPop:触发Return,当前已达到同时展示的礼包类型数量总上限"); |
| | | } |
| | | #endif |
| | | return; |
| | | } |
| | | int popCnt = GetPopCnt(); |
| | | |
| | | if (limitPopCnt <= popCnt) |
| | | { |
| | | #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; |
| | |
| | | continue; |
| | | isChange = true; |
| | | showGiftIdList.Add(id); |
| | | lastTriggerTimeDict[id] = TimeUtility.AllSeconds; |
| | | lastTriggerTimeDict[config.GiftType] = TimeUtility.AllSeconds; |
| | | } |
| | | |
| | | if (isChange) |
| | |
| | | |
| | | lastTriggerTimeDict = loadDict; |
| | | InitCurrectTimingGiftIdList(new List<int>(loadDict.Keys)); |
| | | |
| | | |
| | | #if UNITY_EDITOR |
| | | if (isLogShow) |
| | | { |