Files
MinFt/Client/Assets/Scripts/UI/Shop/BlackFridayCouponData.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

88 lines
3.2 KiB
C#

using System;
using System.Linq;
using asap.core;
using cfg;
public class BlackFridayCouponData
{
private readonly Tables _tables = GContext.container.Resolve<Tables>();
private readonly TbEventCoupon _tableCoupon = GContext.container.Resolve<Tables>().TbEventCoupon;
public DateTime ActivateTime = new DateTime(1996, 11, 28);
public int EventId { get; private set; }
public int RedirectId { get; private set; }
public bool IsBought => _isBought;
public bool DoesPop = true;
private bool _isBought = false;
public TimeSpan RemainingTime
{
get
{
var eventLimit = DateTime.Parse((_tables.TbFishingEvent[EventId].TimeDefinition as LimitedTime)?.EndTime);
var activeLimit = ActivateTime + TimeSpan.FromSeconds(EventDuration);
var limit = eventLimit < activeLimit ? eventLimit : activeLimit;
return limit - ZZTimeHelper.UtcNow();
}
}
public bool IsWithinEventTime
{
get
{
var now = ZZTimeHelper.UtcNow();
var fishingEvent = _tables.TbFishingEvent[EventId];
return now >= DateTime.Parse((fishingEvent.TimeDefinition as LimitedTime)?.StartTime) &&
now < DateTime.Parse((fishingEvent.TimeDefinition as LimitedTime)?.EndTime);
}
}
public const string PlayFabDataKey = "BlackFridayCouponDate";
public bool IsActive => _tables.TbFishingEvent.DataMap.ContainsKey(EventId) &&
_tableCoupon.DataMap.ContainsKey(RedirectId) && IsWithinEventTime &&
ZZTimeHelper.UtcNow() <= ActivateTime + TimeSpan.FromSeconds(EventDuration) && !IsBought;
public int Multiplier => GContext.container.Resolve<Tables>().TbEventCoupon[RedirectId].Multiple;
public int EventDuration => GContext.container.Resolve<Tables>().TbEventCoupon[RedirectId].Time;
public void LoadData(string s)
{
int[] tokens = s.Split(',').Select(int.Parse).ToArray();
ActivateTime = new DateTime(tokens[0], tokens[1], tokens[2], tokens[3], tokens[4], tokens[5]);
EventId = tokens[6];
if (tokens.Length < 9)
{
_isBought = false;
RedirectId = 0;
}
else
{
RedirectId = tokens[7];
_isBought = tokens[8] == 1;
}
// BlackFridayCouponPopupPanel.DebugWithColor("Debug Activated.");
// EventId = 0;
}
public void UploadData()
{
string s =
$"{ActivateTime.Year},{ActivateTime.Month},{ActivateTime.Day},{ActivateTime.Hour},{ActivateTime.Minute},{ActivateTime.Second},{EventId},{RedirectId},{(IsBought ? 1 : 0)}";
PlayFabMgr.Instance.UpdateUserDataValue(PlayFabDataKey, s);
}
public void UpdateData(FishingEvent e)
{
if (e.Type != 3 || e.SubType != 9 || e.ID == EventId)
return ;
EventId = e.ID;
RedirectId = e.RedirectID;
ActivateTime = ZZTimeHelper.UtcNow();
_isBought = false;
// Debug.Log($"<color=#23aaf2>Black Friday Activated @ {ActivateTime}</color>");
UploadData();
}
public void SetStateBought()
{
_isBought = true;
UploadData();
}
}