169 lines
3.8 KiB
C#
169 lines
3.8 KiB
C#
|
|
using cfg.ActorCfg;
|
|||
|
|
using cfg.CharacterCfg;
|
|||
|
|
using Framework;
|
|||
|
|
using Gameplay.Net;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 抽卡结果数据
|
|||
|
|
/// </summary>
|
|||
|
|
public class RaffleResultData
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 抽卡数据
|
|||
|
|
/// </summary>
|
|||
|
|
private DataGacha gachaData;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 初始天井币数量
|
|||
|
|
/// </summary>
|
|||
|
|
private int patioCount;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 记录抽卡前拥有的角色id
|
|||
|
|
/// </summary>
|
|||
|
|
private HashSet<int> setCharacterId;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 记录每个角色是否是新获得的,和listCharacter一一对应
|
|||
|
|
/// </summary>
|
|||
|
|
private List<bool> listIsNew;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 角色数据列表
|
|||
|
|
/// </summary>
|
|||
|
|
private List<DataCharacterAttri> listCharacter;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 显示角色索引
|
|||
|
|
/// </summary>
|
|||
|
|
public int ShowIndex;
|
|||
|
|
|
|||
|
|
#region 属性
|
|||
|
|
/// <summary>
|
|||
|
|
/// 记录角色是否新获得
|
|||
|
|
/// </summary>
|
|||
|
|
public List<bool> ListIsNew
|
|||
|
|
{
|
|||
|
|
get { return listIsNew; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 所有角色信息
|
|||
|
|
/// </summary>
|
|||
|
|
public List<DataCharacterAttri> ListCharacter
|
|||
|
|
{
|
|||
|
|
get { return listCharacter; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 卡池数据
|
|||
|
|
/// </summary>
|
|||
|
|
public DataGacha GachaData
|
|||
|
|
{
|
|||
|
|
get { return gachaData; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 最大星级
|
|||
|
|
/// </summary>
|
|||
|
|
public int MaxStartStar
|
|||
|
|
{
|
|||
|
|
get; private set;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否有下一个要显示的
|
|||
|
|
/// </summary>
|
|||
|
|
public bool IsShowNext
|
|||
|
|
{
|
|||
|
|
get { return ShowIndex < listCharacter.Count - 1; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 是否可以获得天井币
|
|||
|
|
/// </summary>
|
|||
|
|
public bool IsGetPatio
|
|||
|
|
{
|
|||
|
|
get { return 0 != gachaData.PatioCoin; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 初始天井币数量
|
|||
|
|
/// </summary>
|
|||
|
|
public int PatioCount
|
|||
|
|
{
|
|||
|
|
get { return patioCount; }
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
public DataCharacterAttri CharacterAttri
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
if (ShowIndex >= ListCharacter.Count)
|
|||
|
|
return null;
|
|||
|
|
|
|||
|
|
return ListCharacter[ShowIndex];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public RaffleResultData(DataGacha dataGacha)
|
|||
|
|
{
|
|||
|
|
Reset(dataGacha);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void SetInfo(ItemCounts itemCounts)
|
|||
|
|
{
|
|||
|
|
listCharacter.Clear();
|
|||
|
|
listIsNew.Clear();
|
|||
|
|
MaxStartStar = 0;
|
|||
|
|
ShowIndex = 0;
|
|||
|
|
|
|||
|
|
foreach (uint characterId in itemCounts.Ids)
|
|||
|
|
{
|
|||
|
|
DataCharacterAttri cfg = TableManager.Instance.Tables.CharacterAttri.GetOrDefault((int)characterId);
|
|||
|
|
listCharacter.Add(cfg);
|
|||
|
|
DebugUtil.Log($"本次抽取角色id:{characterId}");
|
|||
|
|
if (cfg == null)
|
|||
|
|
{
|
|||
|
|
listIsNew.Add(false);
|
|||
|
|
DebugUtil.LogError($"获取角色配置错误, 错误id:{characterId}");
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
listIsNew.Add(setCharacterId.Add(cfg.RoleID));
|
|||
|
|
|
|||
|
|
if (MaxStartStar < cfg.StartStar)
|
|||
|
|
MaxStartStar = cfg.StartStar;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Reset(DataGacha dataGacha)
|
|||
|
|
{
|
|||
|
|
gachaData = dataGacha;
|
|||
|
|
|
|||
|
|
if (IsGetPatio)
|
|||
|
|
patioCount = (int)Actor.Instance.Item.GetItemCount(gachaData.PatioCoin);
|
|||
|
|
|
|||
|
|
if (null == listCharacter)
|
|||
|
|
listCharacter = new(16);
|
|||
|
|
else
|
|||
|
|
listCharacter.Clear();
|
|||
|
|
|
|||
|
|
if (null == listIsNew)
|
|||
|
|
listIsNew = new(16);
|
|||
|
|
else
|
|||
|
|
listIsNew.Clear();
|
|||
|
|
|
|||
|
|
if (null == setCharacterId)
|
|||
|
|
setCharacterId = new();
|
|||
|
|
else
|
|||
|
|
setCharacterId.Clear();
|
|||
|
|
|
|||
|
|
MaxStartStar = 0;
|
|||
|
|
ShowIndex = 0;
|
|||
|
|
|
|||
|
|
foreach (CharacterDataInfo characterDataInfo in CharacterDataInfoManager.Instance.DataList)
|
|||
|
|
{
|
|||
|
|
setCharacterId.Add(characterDataInfo.Cfg.RoleID);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|