NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Draw/DrawInfo.cs

191 lines
5.2 KiB
C#
Raw Normal View History

2023-12-27 19:45:21 +08:00
using cfg.ActorCfg;
2024-12-09 19:27:56 +08:00
using cfg.RedPoint;
2023-12-27 19:45:21 +08:00
using Gameplay.Net;
2024-06-27 16:18:37 +08:00
using System.Collections.Generic;
2023-12-27 19:45:21 +08:00
2024-12-09 17:11:11 +08:00
/// <summary>
/// 卡池数据
/// </summary>
2024-12-09 19:27:56 +08:00
public sealed class DrawInfo : IRedPointTreeNode
2023-12-27 19:45:21 +08:00
{
2024-06-26 19:37:49 +08:00
#region 属性
2024-03-19 16:57:10 +08:00
/// <summary>
/// 卡池配置数据
/// </summary>
2024-06-26 19:37:49 +08:00
public DataGacha Cfg { get; private set; }
2024-03-19 16:57:10 +08:00
/// <summary>
/// 卡池累计抽取数据
/// </summary>
2024-12-09 17:11:11 +08:00
public RaffleCount ServerData { get; private set; }
2024-03-19 16:57:10 +08:00
2024-12-09 19:27:56 +08:00
/// <summary>
/// 红点
/// </summary>
public RedPointNode RedPoint { get; private set; }
2024-03-19 16:57:10 +08:00
/// <summary>
2024-12-09 17:11:11 +08:00
/// 有可以抽取的
2024-03-19 16:57:10 +08:00
/// </summary>
2024-06-28 14:02:15 +08:00
public bool IsDraw
2024-06-27 16:18:37 +08:00
{
2024-12-09 19:27:56 +08:00
get
2024-06-28 14:02:15 +08:00
{
for (int i = 0; i < Cfg.DrawType.Length; ++i)
{
if (ListDrawButtonData[i].IsDraw)
return true;
}
return false;
}
2024-06-27 16:18:37 +08:00
}
2024-03-19 16:57:10 +08:00
/// <summary>
2024-06-27 16:18:37 +08:00
/// 抽卡按钮数据
2024-03-19 16:57:10 +08:00
/// </summary>
2024-06-27 16:18:37 +08:00
public List<DrawButtonData> ListDrawButtonData { get; private set; }
2024-03-19 16:57:10 +08:00
/// <summary>
/// 剩余免费单抽次数
/// </summary>
public int FreeOneCount
2023-12-27 19:45:21 +08:00
{
2024-03-19 16:57:10 +08:00
get
{
2024-12-09 17:11:11 +08:00
if (null == ServerData)
2024-06-26 19:37:49 +08:00
return Cfg.DailyFreeCount;
2024-12-09 17:11:11 +08:00
if (Cfg.DailyFreeCount <= ServerData.FreeCount)
2024-06-26 19:37:49 +08:00
return 0;
else
2024-12-09 17:11:11 +08:00
return Cfg.DailyFreeCount - (int)ServerData.FreeCount;
2024-06-26 19:37:49 +08:00
}
}
/// <summary>
/// 剩余限定单抽次数
/// </summary>
public int LimitOneCount
{
get
{
2024-12-09 17:11:11 +08:00
if (null == ServerData)
2024-06-26 19:37:49 +08:00
return Cfg.LimitOneCount;
2024-03-19 16:57:10 +08:00
2024-12-09 17:11:11 +08:00
if (Cfg.LimitOneCount <= ServerData.LimitOne)
2024-03-19 16:57:10 +08:00
return 0;
else
2024-12-09 17:11:11 +08:00
return Cfg.LimitOneCount - (int)ServerData.LimitOne;
2024-03-19 16:57:10 +08:00
}
2023-12-27 19:45:21 +08:00
}
2024-03-19 16:57:10 +08:00
/// <summary>
/// 是否可以免费单抽
/// </summary>
public bool IsFreeOne
2023-12-27 19:45:21 +08:00
{
2024-03-19 16:57:10 +08:00
get { return FreeOneCount > 0; }
2023-12-27 19:45:21 +08:00
}
2024-03-19 16:57:10 +08:00
2024-06-26 19:37:49 +08:00
/// <summary>
/// 是否可以限定单抽
/// </summary>
public bool IsLimitOne
{
get { return LimitOneCount > 0; }
}
2024-12-09 17:11:11 +08:00
2024-06-26 19:37:49 +08:00
/// <summary>
/// 剩余限定十连抽次数
/// </summary>
public int LimitTenCount
{
get
{
2024-12-09 17:11:11 +08:00
if (null == ServerData)
2024-06-26 19:37:49 +08:00
return Cfg.LimitTenCount;
2024-12-09 17:11:11 +08:00
if (Cfg.LimitTenCount <= ServerData.LimitTen)
2024-06-26 19:37:49 +08:00
return 0;
else
2024-12-09 17:11:11 +08:00
return Cfg.LimitTenCount - (int)ServerData.LimitTen;
2024-06-26 19:37:49 +08:00
}
}
/// <summary>
/// 是否可以限定十连抽
/// </summary>
public bool IsLimitTen
{
2024-07-03 19:43:24 +08:00
get { return LimitTenCount >= 1; }
2024-06-26 19:37:49 +08:00
}
#endregion
2024-12-09 17:11:11 +08:00
public DrawInfo(DataGacha cfg)
2023-12-27 19:45:21 +08:00
{
2024-06-26 19:37:49 +08:00
Cfg = cfg;
2024-06-27 16:18:37 +08:00
ListDrawButtonData = new(4)
{
new DrawButtonData(),
new DrawButtonData(),
new DrawButtonData(),
new DrawButtonData(),
};
2024-12-09 19:27:56 +08:00
ConstructRedPointTree(50);
2024-03-19 19:09:13 +08:00
}
public void Refresh()
{
2024-12-09 17:11:11 +08:00
ServerData = Actor.Instance.Raffle.GetRaffleInfo((uint)Cfg.Id);
2024-06-26 19:37:49 +08:00
for (int i = 0; i < Cfg.DrawType.Length; ++i)
{
2024-06-27 16:18:37 +08:00
GachaDrawType gachaDrawType = Cfg.DrawType[i];
switch (gachaDrawType)
2024-06-26 19:37:49 +08:00
{
case GachaDrawType.NormalOne:
{
2024-06-27 16:18:37 +08:00
int count = (int)E_DrawCount.One;
if (Actor.Instance.Item.GetItemCount(Cfg.TicketItemID) >= (uint)E_DrawCount.One)
2024-06-27 16:18:37 +08:00
ListDrawButtonData[i] = new(gachaDrawType, E_DrawCount.One, true, IsFreeOne, Cfg.TicketItemID, count, false);
else
ListDrawButtonData[i] = new(gachaDrawType, E_DrawCount.One, true, IsFreeOne, Cfg.Cost[i].Id, Cfg.Cost[i].Count, true);
2024-06-26 19:37:49 +08:00
}
break;
2024-06-27 16:18:37 +08:00
case GachaDrawType.NormalTen:
2024-06-26 19:37:49 +08:00
{
2024-06-27 16:18:37 +08:00
int count = (int)E_DrawCount.Ten;
if (Actor.Instance.Item.GetItemCount(Cfg.TicketItemID) >= (uint)E_DrawCount.Ten)
2024-06-27 16:18:37 +08:00
ListDrawButtonData[i] = new(gachaDrawType, E_DrawCount.Ten, true, false, Cfg.TicketItemID, count, false);
else
ListDrawButtonData[i] = new(gachaDrawType, E_DrawCount.Ten, true, false, Cfg.Cost[i].Id, Cfg.Cost[i].Count, true);
2024-06-26 19:37:49 +08:00
}
break;
2024-06-27 16:18:37 +08:00
case GachaDrawType.LimitOne:
2024-06-26 19:37:49 +08:00
{
2024-06-27 16:18:37 +08:00
ListDrawButtonData[i] = new(gachaDrawType, E_DrawCount.One, IsLimitOne, false, Cfg.Cost[i].Id, Cfg.Cost[i].Count, true);
2024-06-26 19:37:49 +08:00
}
break;
case GachaDrawType.LimitTen:
{
2024-06-27 16:18:37 +08:00
ListDrawButtonData[i] = new(gachaDrawType, E_DrawCount.Ten, IsLimitTen, false, Cfg.Cost[i].Id, Cfg.Cost[i].Count, true);
2024-06-26 19:37:49 +08:00
}
break;
default:
2024-06-27 16:18:37 +08:00
throw new System.Exception("未处理类型");
2024-06-26 19:37:49 +08:00
}
}
2023-12-27 19:45:21 +08:00
}
2024-12-09 19:27:56 +08:00
public void ConstructRedPointTree(int parentID)
{
RedPoint = RedPointManager.Instance.AddDynamicNode(NodeType.Raffle, parentID, Cfg.Id);
}
public void ConstructRedPointTree(RedPointNode parent)
{
}
2024-03-19 16:57:10 +08:00
}