using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class FairySiegeScheduleGroupWin : Window
|
{
|
[SerializeField] Dropdown dropType;
|
[SerializeField] ScrollerController scrGroup;
|
[SerializeField] TextEx txtBattlefieldType;
|
[SerializeField] TextEx txtTip;
|
RankModel rankModel { get { return ModelCenter.Instance.GetModel<RankModel>(); } }
|
FairySiegeActModel model { get { return ModelCenter.Instance.GetModel<FairySiegeActModel>(); } }
|
int nowBattleType;
|
int nowBattleGroup;
|
|
#region Build-in
|
|
protected override void AddListeners()
|
{
|
dropType.SetListener(value =>
|
{
|
nowBattleGroup = value + 1;
|
int groupValue2 = nowBattleType * 100 + nowBattleGroup;
|
Send(groupValue2);
|
});
|
}
|
|
void Send(int groupValue2)
|
{
|
dropType.interactable = false;
|
scrGroup.Refresh();
|
scrGroup.Restart();
|
rankModel.ResetQueryParam();
|
rankModel.QueryCrossRank(FairySiegeActModel.crossRoundRankType, model.operationCrossAct.zoneID, groupValue2: groupValue2);
|
}
|
protected override void BindController()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
dropType.interactable = true;
|
scrGroup.OnRefreshCell += OnRefreshGroupCell;
|
rankModel.onRankRefresh += OnRefreshRankList;
|
int myBattleType;
|
int myBattleGroup;
|
if (!model.TryGetNowBatTypeAndGroup(model.myFamilyID, out myBattleType, out myBattleGroup))
|
return;
|
nowBattleType = myBattleType;
|
int groupValue2 = nowBattleType * 100 + myBattleGroup;
|
Send(groupValue2);
|
}
|
|
protected override void OnPreClose()
|
{
|
scrGroup.OnRefreshCell -= OnRefreshGroupCell;
|
rankModel.onRankRefresh -= OnRefreshRankList;
|
}
|
|
private void OnRefreshRankList(int type)
|
{
|
if (type != FairySiegeActModel.crossRoundRankType)
|
return;
|
CreateGroupScroller();
|
dropType.interactable = true;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
CreateDropdown();
|
Display();
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
#endregion
|
|
private void OnRefreshGroupCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetComponent<FairySiegeScheduleGroupCell>();
|
_cell?.Display(cell.index, cell);
|
}
|
|
private void CreateDropdown()
|
{
|
dropType.ClearOptions();
|
var optionDatas = new List<Dropdown.OptionData>();
|
int myBattleType;
|
int myBattleGroup;
|
int myIndex = -1;
|
if (model.TryGetNowBatTypeAndGroup(model.myFamilyID, out myBattleType, out myBattleGroup))
|
{
|
if (model.batGroupInfo.TryGetValue(myBattleType, out var groupDict) && !groupDict.IsNullOrEmpty())
|
{
|
var list = groupDict.Keys.ToList();
|
list.Sort();
|
for (int i = 0; i < list.Count; i++)
|
{
|
int battlefieldGroup = list[i];
|
if (battlefieldGroup == myBattleGroup)
|
{
|
myIndex = i;
|
}
|
var groupStr = Language.Get(StringUtility.Contact("FairySiegeBattlefieldGroup", battlefieldGroup));
|
optionDatas.Add(new Dropdown.OptionData(groupStr));
|
}
|
}
|
}
|
dropType.AddOptions(optionDatas);
|
if (myIndex > -1)
|
{
|
dropType.value = myIndex;
|
int groupValue2 = myBattleType * 100 + myBattleGroup;
|
rankModel.ResetQueryParam();
|
rankModel.QueryCrossRank(FairySiegeActModel.crossRoundRankType, model.operationCrossAct.zoneID, groupValue2: groupValue2);
|
}
|
}
|
|
private void Display()
|
{
|
if (model.operationCrossAct == null)
|
return;
|
if (!model.TryGetNowBatTypeAndGroup(model.myFamilyID, out int myBattleType, out int myBattleGroup))
|
return;
|
|
bool isShowTip = model.TryGetMatchUpNum(model.operationCrossAct.JoinFamilyCnt, model.matchRound, myBattleType, out int num);
|
txtTip.SetActive(isShowTip && num > 0);
|
if (isShowTip && num > 0)
|
{
|
txtTip.text = Language.Get("FairySiege122", num);
|
}
|
var myTypeStr = Language.Get(StringUtility.Contact("FairySiegeBattlefieldType", myBattleType));
|
txtBattlefieldType.text = StringUtility.Contact(myTypeStr, Language.Get("FairySiege121"));
|
}
|
|
private void CreateGroupScroller()
|
{
|
scrGroup.Refresh();
|
var rankInfo = rankModel.GetRankPageDatas(FairySiegeActModel.crossRoundRankType);
|
if (!rankInfo.IsNullOrEmpty())
|
{
|
var list = rankInfo.Keys.ToList();
|
for (int i = 0; i < list.Count; i++)
|
{
|
CellInfo info = new CellInfo();
|
info.infoInt1 = nowBattleType;
|
scrGroup.AddCell(ScrollerDataType.Header, i, info);
|
}
|
}
|
scrGroup.Restart();
|
}
|
}
|
}
|