| | |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | RechargeManager.Instance.rechargeCountEvent += OnRechargeCountEvent; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent; |
| | | |
| | | InitClickTabDict(); |
| | | InitRedPoint(); |
| | | } |
| | | |
| | | public override void Release() |
| | |
| | | { |
| | | firstChargeInfoDict.Clear(); |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | | { |
| | | InitClickTabDict(); |
| | | InitRedPoint(); |
| | | if (FuncOpen.Instance.IsFuncOpen(FuncID)&& TryGetUnBuyFirstId(out int firstId)) |
| | | if (FuncOpen.Instance.IsFuncOpen(FuncID) && TryGetUnBuyFirstId(out int firstId)) |
| | | { |
| | | PopupWindowsProcessor.Instance.Add("FirstChargeWin"); |
| | | } |
| | | } |
| | | |
| | | public bool TryGetFirstChargeDataByFirstId(int firstId, out FirstChargeData firstChargeData) |
| | | { |
| | | return firstChargeInfoDict.TryGetValue(firstId, out firstChargeData); |
| | |
| | | UpdateRedPoint(); |
| | | OnUpdateFirstChargeInfo?.Invoke(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 检查是否所有首充奖励都已领取,如果是,则将当前服务器时间保存到本地 |
| | | /// </summary> |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 检查是否所有首充奖励都已经领取 |
| | | public bool IsAllFirstChargeRewardsClaimed() |
| | | { |
| | |
| | | var firstChargeIds = FirstChargeConfig.GetKeys(); |
| | | if (firstChargeIds == null || firstChargeIds.Count == 0) |
| | | return false; |
| | | |
| | | |
| | | foreach (var firstId in firstChargeIds) |
| | | { |
| | | // 尝试获取首充数据 |
| | | if (!TryGetFirstChargeDataByFirstId(firstId, out var firstChargeData)) |
| | | return false; |
| | | |
| | | |
| | | // 检查是否购买 |
| | | if (!firstChargeData.IsBuy()) |
| | | return false; |
| | | |
| | | |
| | | // 检查是否所有奖励都已领取 |
| | | if (!firstChargeData.IsAllHave()) |
| | | return false; |
| | |
| | | // 检查是否已经过了第二天0点 |
| | | return true; |
| | | } |
| | | |
| | | |
| | | // 检查是否已经过了所有奖励领取完毕后的第二天0点 |
| | | public bool IsNextDayAfterAllClaimed() |
| | | { |
| | | // 生成一个唯一的键来获取时间 |
| | | string key = $"FirstCharge_AllRewardsClaimed_Time_{PlayerDatas.Instance.baseData.PlayerID}"; |
| | | |
| | | |
| | | // 检查是否存在记录的时间戳 |
| | | if (!LocalSave.HasKey(key)) |
| | | return false; |
| | | |
| | | |
| | | // 获取记录的时间戳 |
| | | string timeString = LocalSave.GetString(key); |
| | | if (string.IsNullOrEmpty(timeString)) |
| | | return false; |
| | | |
| | | |
| | | // 解析时间戳 |
| | | if (!long.TryParse(timeString, out long ticks)) |
| | | return false; |
| | | |
| | | |
| | | // 将时间戳转换为DateTime |
| | | DateTime allRewardsClaimedTime = new DateTime(ticks); |
| | | |
| | | |
| | | // 计算第二天0点的时间 |
| | | DateTime nextDayStart = allRewardsClaimedTime.Date.AddDays(1); |
| | | |
| | | |
| | | // 判断当前服务器时间是否已经过了第二天0点 |
| | | DateTime serverNow = TimeUtility.ServerNow; |
| | | return serverNow >= nextDayStart; |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | // ... existing code ... |
| | | |
| | | // ... existing code ... |
| | | /// <summary> |
| | | /// 获取当前时间是购买这档充值礼包的第几天 |
| | | /// 购买的当天算作第一天,第二天0点后算第二天,以此类推 |
| | |
| | | { |
| | | DateTime serverNow = TimeUtility.ServerNow; |
| | | DateTime chargeTime = TimeUtility.GetTime(ChargeTime); |
| | | |
| | | |
| | | DateTime chargeDate = chargeTime.Date; |
| | | DateTime serverDate = serverNow.Date; |
| | | |
| | | |
| | | // 计算从充值日期到当前日期的完整天数 |
| | | // 购买的当天算第一天,第二天0点后算第二天 |
| | | TimeSpan timeSpan = serverDate - chargeDate; |
| | | int days = (int)timeSpan.TotalDays + 1; // +1 因为当天算第一天 |
| | | |
| | | |
| | | int maxDay = FirstChargeManager.Instance.maxDay; |
| | | |
| | | return Mathf.Min(maxDay, Mathf.Max(1, days)); |