using vnxbqy.UI;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
|
/// <summary>
|
/// 天星塔
|
/// </summary>
|
public class CelestialStarTowerWin : ILWindow
|
{
|
ScrollerController scroller;
|
TextEx txtBuy;
|
TextEx txtProfitRatio;
|
ButtonEx btnClose;
|
ButtonEx btnBuy;
|
ImageEx imgBuy;
|
TextEx orgPrice;
|
|
|
VipModel vipModel { get { return ModelCenter.Instance.GetModelEx<VipModel>(); } }
|
protected override void BindController()
|
{
|
scroller = proxy.GetWidgtEx<ScrollerController>("scroller");
|
txtBuy = proxy.GetWidgtEx<TextEx>("txtBuy");
|
txtProfitRatio = proxy.GetWidgtEx<TextEx>("txtProfitRatio");
|
btnClose = proxy.GetWidgtEx<ButtonEx>("btnClose");
|
btnBuy = proxy.GetWidgtEx<ButtonEx>("btnBuy");
|
imgBuy = proxy.GetWidgtEx<ImageEx>("imgBuy");
|
|
var obj = btnBuy.FindComponent("Text", "Txt_orgPrice");
|
if (obj != null)
|
orgPrice = obj as TextEx;
|
}
|
|
protected override void AddListeners()
|
{
|
btnClose.SetListener(() =>
|
{
|
CloseWin<CelestialStarTowerWin>();
|
});
|
|
btnBuy.SetListener(() =>
|
{
|
vipModel.CTG(CelestialStarTowerModel.Instance.ctgIdDict[3]);
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
CelestialStarTowerModel.Instance.UpdateGiftStateEvent += UpdateGiftStateEvent;
|
ModelCenter.Instance.GetModel<SkyTowerModel>().OnChallengeState += OnFloorChangeEvent;
|
scroller.OnRefreshCell += OnScrollerRefreshCell;
|
|
bool isBuyZhanLing = CelestialStarTowerModel.Instance.zhanLingInfoDict[3].isActivite > 0;
|
btnBuy.SetActiveIL(isBuyZhanLing ? false : true);
|
imgBuy.SetActiveIL(isBuyZhanLing);
|
OrderInfoConfig orderCfg;
|
vipModel.TryGetOrderInfo(CelestialStarTowerModel.Instance.ctgIdDict[3], out orderCfg);
|
txtBuy.text = Language.Get("PayMoneyNum", 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(CelestialStarTowerModel.Instance.ctgIdDict[3]).Percentage);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
Initialize();
|
}
|
|
|
protected override void OnPreClose()
|
{
|
CelestialStarTowerModel.Instance.UpdateGiftStateEvent -= UpdateGiftStateEvent;
|
ModelCenter.Instance.GetModel<SkyTowerModel>().OnChallengeState -= OnFloorChangeEvent;
|
scroller.OnRefreshCell -= OnScrollerRefreshCell;
|
}
|
|
private void OnFloorChangeEvent()
|
{
|
if (CelestialStarTowerModel.Instance.zhanLingInfoDict == null ||!CelestialStarTowerModel.Instance.zhanLingInfoDict.ContainsKey(3))
|
return;
|
scroller.m_Scorller.RefreshActiveCellViews();
|
CelestialStarTowerModel.Instance.IsPlayAnimation = true;
|
}
|
|
private void UpdateGiftStateEvent()
|
{
|
scroller.m_Scorller.RefreshActiveCellViews();
|
bool isBuyZhanLing = CelestialStarTowerModel.Instance.zhanLingInfoDict[3].isActivite > 0;
|
btnBuy.SetActiveIL(!isBuyZhanLing);
|
imgBuy.SetActiveIL(isBuyZhanLing);
|
CelestialStarTowerModel.Instance.IsPlayAnimation = true;
|
}
|
|
private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetILBehaviour<CelestialStarTowerCell>();
|
_cell.Display(cell.index);
|
CelestialStarTowerModel.Instance.IsPlayAnimation = true;
|
}
|
void Initialize()
|
{
|
List<int> cellList = ILZhanlingConfig.GetTypeToIDDict(3).Keys.ToList();
|
scroller.Refresh();
|
for (int i = 0; i < cellList.Count; i++)
|
{
|
scroller.AddCell(ScrollerDataType.Header, cellList[i]);
|
}
|
scroller.Restart();
|
scroller.JumpIndex(CelestialStarTowerModel.Instance.GetJumpStartIndex(3));
|
CelestialStarTowerModel.Instance.IsPlayAnimation = true;
|
}
|
|
}
|