NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Raffle/RaffleButtonData.cs

70 lines
1.7 KiB
C#
Raw Normal View History

2025-03-26 14:05:26 +08:00
using cfg.ActorCfg;
2025-03-26 14:51:26 +08:00
using Gameplay.Net;
2025-03-26 14:05:26 +08:00
/// <summary>
/// 抽卡按钮数据
/// </summary>
public struct RaffleButtonData
{
/// <summary>
/// 配置
/// </summary>
2025-03-26 14:51:26 +08:00
public DataGacha Cfg;
2025-03-26 14:05:26 +08:00
/// <summary>
/// 抽卡次数
/// </summary>
2025-03-26 14:51:26 +08:00
public int Count;
2025-03-26 14:05:26 +08:00
/// <summary>
2025-03-26 14:51:26 +08:00
/// 服务器数据
/// </summary>
public RaffleCount ServerData;
/// <summary>
/// 消耗的货币id
2025-03-26 14:05:26 +08:00
/// </summary>
2025-03-26 14:51:26 +08:00
public readonly int CostId { get { return Cfg.SingleCost.Id; } }
2025-03-26 14:05:26 +08:00
/// <summary>
2025-03-26 14:51:26 +08:00
/// 单次抽取消耗的货币数量
2025-03-26 14:05:26 +08:00
/// </summary>
2025-03-26 14:51:26 +08:00
public readonly int SingleCost { get { return Cfg.SingleCost.Count; } }
2025-03-26 14:05:26 +08:00
/// <summary>
2025-03-26 14:51:26 +08:00
/// 能否抽取
2025-03-26 14:05:26 +08:00
/// </summary>
2025-03-26 14:51:26 +08:00
public readonly bool IsRaffle
{
get
{
if (null == Cfg)
return false;
if (IsFreeOne)
return true;
int needCount = Count - (int)CategoryManager.Instance.GetItemCount(Cfg.TicketItemID); // 需要用货币补足的数目
if (needCount <= 0)
return true;
return (int)CategoryManager.Instance.GetItemCount(CostId) >= needCount * SingleCost;
}
}
2025-03-26 14:05:26 +08:00
/// <summary>
2025-03-26 16:47:36 +08:00
/// 是否只用抽卡券就能抽取
2025-03-26 14:05:26 +08:00
/// </summary>
2025-03-26 14:51:26 +08:00
public readonly bool IsTicketRaffle { get { return CategoryManager.Instance.GetItemCount(Cfg.TicketItemID) >= Count; } }
2025-03-26 14:05:26 +08:00
/// <summary>
2025-03-26 14:51:26 +08:00
/// 是否可以免费单抽
2025-03-26 14:05:26 +08:00
/// </summary>
2025-03-26 14:51:26 +08:00
public readonly bool IsFreeOne
{
get
{
if (1 != Count)
return false;
if (null == ServerData)
return Cfg.DailyFreeCount > 0;
return Cfg.DailyFreeCount > ServerData.FreeCount;
}
}
2025-03-26 14:05:26 +08:00
}