using vnxbqy.UI;
using System.Collections.Generic;
using System.Linq;
///
/// 境界战令
///
public class RealmLVZhanlingWin : ILWindow
{
ScrollerController scroller;
TextEx txtBuy;
TextEx txtProfitRatio;
ButtonEx btnClose;
ButtonEx btnBuy;
ImageEx imgBuy;
TextEx orgPrice;
VipModel vipModel { get { return ModelCenter.Instance.GetModelEx(); } }
protected override void BindController()
{
scroller = proxy.GetWidgtEx("scroller");
txtBuy = proxy.GetWidgtEx("txtBuy");
txtProfitRatio = proxy.GetWidgtEx("txtProfitRatio");
btnClose = proxy.GetWidgtEx("btnClose");
btnBuy = proxy.GetWidgtEx("btnBuy");
imgBuy = proxy.GetWidgtEx("imgBuy");
var obj = btnBuy.FindComponent("Text", "Txt_orgPrice");
if (obj != null)
orgPrice = obj as TextEx;
}
protected override void AddListeners()
{
btnClose.SetListener(() =>
{
CloseWin();
});
btnBuy.SetListener(() =>
{
vipModel.CTG(RealmLVZhanlingModel.Instance.ctgIdDict[2]);
});
}
protected override void OnPreOpen()
{
RealmLVZhanlingModel.Instance.UpdateGiftStateEvent += UpdateGiftStateEvent;
PlayerDatas.Instance.playerDataRefreshEvent += OnplayerDataRefreshEvent;
scroller.OnRefreshCell += OnScrollerRefreshCell;
bool isBuyZhanLing = RealmLVZhanlingModel.Instance.zhanLingInfoDict[2].isActivite > 0;
btnBuy.SetActiveIL(!isBuyZhanLing);
imgBuy.SetActiveIL(isBuyZhanLing);
OrderInfoConfig orderCfg;
vipModel.TryGetOrderInfo(RealmLVZhanlingModel.Instance.ctgIdDict[2], out orderCfg);
txtBuy.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderCfg.PayRMBNum));
if (orgPrice != null)
{
orgPrice.SetActiveIL(PlayerDatas.Instance.baseData.IsActive90Off);
orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderCfg.m_PayRMBNum));
}
txtProfitRatio.text = Language.Get("BlessedLand039", CTGConfig.Get(RealmLVZhanlingModel.Instance.ctgIdDict[2]).Percentage);
}
protected override void OnAfterOpen()
{
Initialize();
}
protected override void OnPreClose()
{
RealmLVZhanlingModel.Instance.UpdateGiftStateEvent -= UpdateGiftStateEvent;
PlayerDatas.Instance.playerDataRefreshEvent -= OnplayerDataRefreshEvent;
scroller.OnRefreshCell -= OnScrollerRefreshCell;
}
private void OnplayerDataRefreshEvent(PlayerDataType type)
{
if (type == PlayerDataType.RealmLevel)
{
if (RealmLVZhanlingModel.Instance.zhanLingInfoDict == null || !RealmLVZhanlingModel.Instance.zhanLingInfoDict.ContainsKey(2))
return;
scroller.m_Scorller.RefreshActiveCellViews();
RealmLVZhanlingModel.Instance.IsPlayAnimation = true;
}
}
private void UpdateGiftStateEvent()
{
scroller.m_Scorller.RefreshActiveCellViews();
bool isBuyZhanLing = RealmLVZhanlingModel.Instance.zhanLingInfoDict[2].isActivite > 0;
btnBuy.SetActiveIL(!isBuyZhanLing);
imgBuy.SetActiveIL(isBuyZhanLing);
RealmLVZhanlingModel.Instance.IsPlayAnimation = true;
}
private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell)
{
var _cell = cell.GetILBehaviour();
_cell.Display(cell.index);
RealmLVZhanlingModel.Instance.IsPlayAnimation = true;
}
void Initialize()
{
List cellList = ILZhanlingConfig.GetTypeToIDDict(2).Keys.ToList();
scroller.Refresh();
for (int i = 0; i < cellList.Count; i++)
{
scroller.AddCell(ScrollerDataType.Header, cellList[i]);
}
scroller.Restart();
scroller.JumpIndex(RealmLVZhanlingModel.Instance.GetJumpStartIndex(2));
RealmLVZhanlingModel.Instance.IsPlayAnimation = true;
}
}