using System.Collections.Generic;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
public class FairySiegeJoinListWin : Window
|
{
|
[SerializeField] ButtonEx btnClose;
|
[SerializeField] ScrollerController scrFairy;
|
[SerializeField] ScrollerController scrPlayer;
|
[SerializeField] TextEx txtDate;
|
[SerializeField] TextEx txtPlayerJoinCnt;
|
|
FairySiegeActModel model { get { return ModelCenter.Instance.GetModel<FairySiegeActModel>(); } }
|
|
#region Build-in
|
|
protected override void AddListeners()
|
{
|
btnClose.SetListener(CloseClick);
|
}
|
|
protected override void BindController()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
scrFairy.OnRefreshCell += OnRefreshFairyCell;
|
scrPlayer.OnRefreshCell += OnRefreshPlayerCell;
|
if (model.operationCrossAct == null)
|
return;
|
bool hasQualification = model.hasQualification();
|
scrPlayer.SetActive(hasQualification);
|
txtPlayerJoinCnt.SetActive(hasQualification);
|
if (hasQualification)
|
{
|
int familyLv = (int)PlayerDatas.Instance.fairyData.fairy.FamilyLV;
|
int nowCount = model.campMemberDict.Count;
|
int maxCount = FamilyConfig.Get(familyLv).memberCnt;
|
txtPlayerJoinCnt.text = Language.Get("FairySiege092", nowCount, maxCount);
|
}
|
txtDate.text = StringUtility.Contact(Language.Get("OperationDate"), " ", model.operationCrossAct.ToDisplayTime());
|
}
|
|
protected override void OnPreClose()
|
{
|
scrFairy.OnRefreshCell -= OnRefreshFairyCell;
|
scrPlayer.OnRefreshCell -= OnRefreshPlayerCell;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
CreateFairyScroller();
|
CreatePlayerScroller();
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
#endregion
|
|
private void OnRefreshFairyCell(ScrollerDataType type, CellView cell)
|
{
|
if (type == ScrollerDataType.Header)
|
{
|
var _cell = cell.GetComponent<FairySiegeJoinListServerCell>();
|
_cell?.Display(cell.index);
|
}
|
else
|
{
|
var _cell = cell.GetComponent<FairySiegeJoinListFairyCell>();
|
_cell?.Display(cell.index, cell);
|
}
|
}
|
|
private void OnRefreshPlayerCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetComponent<FairySiegeJoinListPlayerCell>();
|
_cell?.Display(cell.index);
|
}
|
|
private void CreateFairyScroller()
|
{
|
scrFairy.Refresh();
|
if (model.TryGetSortServerIdList(out List<uint> list))
|
{
|
foreach (var serverId in list)
|
{
|
scrFairy.AddCell(ScrollerDataType.Header, (int)serverId);
|
if (model.TryGetSortFamilyList(serverId, out List<FairySiegeFamilyInfo> infoList))
|
{
|
int rowCount = Mathf.CeilToInt((float)infoList.Count / model.joinListFairyRowMax);
|
for (int i = 0; i < rowCount; i++)
|
{
|
CellInfo cellInfo = new CellInfo();
|
cellInfo.infoInt1 = (int)serverId;
|
scrFairy.AddCell(ScrollerDataType.Normal, i, cellInfo);
|
}
|
}
|
}
|
}
|
scrFairy.Restart();
|
}
|
|
private void CreatePlayerScroller()
|
{
|
scrPlayer.Refresh();
|
if (model.TryGetSortMemberList(out List<FairySiegeCampMember> list))
|
{
|
int rowCount = Mathf.CeilToInt((float)list.Count / model.joinListFairyRowMax);
|
for (int i = 0; i < rowCount; i++)
|
{
|
scrPlayer.AddCell(ScrollerDataType.Header, i);
|
}
|
}
|
scrPlayer.Restart();
|
}
|
}
|
}
|