using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
namespace Snxxz.UI
|
{
|
public class CrossServerOneVsOneHonorStoreWin : Window
|
{
|
[SerializeField] ScrollerController shopCtrl;
|
|
StoreModel _storeModel;
|
StoreModel m_storeModel
|
{
|
get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel<StoreModel>()); }
|
}
|
|
List<StoreModel.StoreData> shoplist;
|
int SingleLineCnt = 2;
|
|
protected override void BindController()
|
{
|
shopCtrl.OnRefreshCell += RefreshShopCell;
|
shopCtrl.lockType = EnhanceLockType.KeepVertical;
|
}
|
|
protected override void AddListeners()
|
{
|
|
}
|
|
protected override void OnPreOpen()
|
{
|
m_storeModel.RefreshBuyShopLimitEvent += CreateShopCell;
|
m_storeModel.storeFuncType = StoreFunc.CrossOneVsOneHonor;
|
CreateShopCell();
|
}
|
protected override void OnAfterOpen()
|
{
|
|
}
|
|
protected override void OnPreClose()
|
{
|
m_storeModel.RefreshBuyShopLimitEvent -= CreateShopCell;
|
}
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
private void CreateShopCell()
|
{
|
|
shoplist = m_storeModel.TryGetStoreDatas(m_storeModel.storeFuncType);
|
if(shoplist == null)
|
{
|
DebugEx.Log("跨服商店数据为空");
|
return;
|
}
|
|
shopCtrl.Refresh();
|
if (shoplist.Count > 0)
|
{
|
int i = 0;
|
int remain = shoplist.Count % SingleLineCnt;
|
int line = (int)shoplist.Count / SingleLineCnt;
|
if (remain > 0)
|
{
|
line += 1;
|
}
|
|
for (i = 0; i < line; i++)
|
{
|
shopCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
}
|
shopCtrl.Restart();
|
|
shopCtrl.JumpIndex(0);
|
}
|
|
private void RefreshShopCell(ScrollerDataType type, CellView cell)
|
{
|
int length = cell.transform.childCount;
|
for(int i = 0; i < length;i++)
|
{
|
int cellCount = length * cell.index + (i + 1);
|
CrossServerOneVsOneHonorShopCell shopCell = cell.transform.GetChild(i).GetComponent<CrossServerOneVsOneHonorShopCell>();
|
if(shoplist.Count >= cellCount)
|
{
|
shopCell.gameObject.SetActive(true);
|
shopCell.SetDisplay(shoplist[cellCount-1].storeConfig);
|
}
|
else
|
{
|
shopCell.gameObject.SetActive(false);
|
}
|
}
|
}
|
|
}
|
}
|