using UnityEngine;
|
namespace vnxbqy.UI
|
{
|
public class ChatBubbleCell : CellView
|
{
|
[SerializeField] ChatBubbleSelectBehaviour[] m_ChatBubbles;
|
[SerializeField] int m_LineCount = 7;
|
|
public int lineCount { get { return m_LineCount; } }
|
|
ChatBubbleModel model
|
{
|
get { return ModelCenter.Instance.GetModel<ChatBubbleModel>(); }
|
}
|
PhantasmPavilionModel phantasmPavilionModel {get { return ModelCenter.Instance.GetModel<PhantasmPavilionModel>(); }}
|
public void Display(int line)
|
{
|
var keys = ChatBubbleBoxConfig.GetKeys();
|
keys.Sort(Cmp);
|
for (int i = 0; i < lineCount; i++)
|
{
|
var index = line * 7 + i;
|
if (index < keys.Count)
|
{
|
int id = int.Parse(keys[index]);
|
if (!ChatBubbleBoxConfig.Has(id))
|
continue;
|
m_ChatBubbles[i].SetActive(true);
|
m_ChatBubbles[i].Display(id);
|
}
|
else
|
{
|
m_ChatBubbles[i].SetActive(false);
|
}
|
}
|
}
|
|
public int Cmp(string numA, string numB)
|
{
|
int a = int.Parse(numA);
|
int b = int.Parse(numB);
|
|
PhantasmPavilionTab tab = PhantasmPavilionTab.ChatBubble;
|
// 获取 a 和 b 的解锁状态
|
int stateA = phantasmPavilionModel.GetUnLockState(tab, a);
|
int stateB = phantasmPavilionModel.GetUnLockState(tab, b);
|
|
//0 - 未激活 1 - 可激活 2 - 已激活
|
int priorityA = stateA;
|
int priorityB = stateB;
|
|
if (priorityA != priorityB)
|
{
|
return priorityB.CompareTo(priorityA);
|
}
|
|
// 如果激活状态相同,比较 SortNum
|
int sortNumA = phantasmPavilionModel.GetSortNum(tab, a);
|
int sortNumB = phantasmPavilionModel.GetSortNum(tab, b);
|
|
if (sortNumA != sortNumB)
|
{
|
if (tab == PhantasmPavilionTab.Avatar)
|
{
|
return sortNumB.CompareTo(sortNumA);
|
}
|
else
|
{
|
return sortNumA.CompareTo(sortNumB);
|
}
|
}
|
|
return a.CompareTo(b);
|
}
|
|
}
|
}
|
|