From 9fb3c8e114a67c0cdf353b32b1b50e90414fd597 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期三, 25 二月 2026 16:34:07 +0800
Subject: [PATCH] Merge branch 'master' into h5version
---
Main/System/TimingGift/TimingGiftManager.cs | 122 +++++++++++++++++++++++++++++++++++-----
1 files changed, 106 insertions(+), 16 deletions(-)
diff --git a/Main/System/TimingGift/TimingGiftManager.cs b/Main/System/TimingGift/TimingGiftManager.cs
index 220ffcc..d7b2483 100644
--- a/Main/System/TimingGift/TimingGiftManager.cs
+++ b/Main/System/TimingGift/TimingGiftManager.cs
@@ -37,6 +37,10 @@
public int[] selectCtgIds;
public int[][] selectGainItemList;
+ public int limitPopCnt;
+ public int limitShowCnt;
+ public int limitPopCd;
+
public event Action OnSelectCtgIdIndexChangeEvent;
public bool isLogShow = true;
@@ -45,6 +49,11 @@
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()
@@ -165,9 +174,55 @@
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
@@ -191,25 +246,60 @@
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}绫诲瀷鐨勭ぜ鍖匢D");
+ }
+#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;
@@ -225,7 +315,7 @@
continue;
isChange = true;
showGiftIdList.Add(id);
- lastTriggerTimeDict[id] = TimeUtility.AllSeconds;
+ lastTriggerTimeDict[config.GiftType] = TimeUtility.AllSeconds;
}
if (isChange)
@@ -480,7 +570,7 @@
lastTriggerTimeDict = loadDict;
InitCurrectTimingGiftIdList(new List<int>(loadDict.Keys));
-
+
#if UNITY_EDITOR
if (isLogShow)
{
--
Gitblit v1.8.0