using vnxbqy.UI; using System; using System.Collections.Generic; using System.Linq; /// /// 等级战令 /// public class LvZhanlingWin : 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(LvZhanlingModel.Instance.ctgIdDict[1]); }); } protected override void OnPreOpen() { PlayerDatas.Instance.playerDataRefreshEvent += OnplayerDataRefreshEvent; LvZhanlingModel.Instance.UpdateGiftStateEvent += UpdateGiftStateEvent; scroller.OnRefreshCell += OnScrollerRefreshCell; bool isBuyZhanLing = LvZhanlingModel.Instance.zhanLingInfoDict[1].isActivite > 0; btnBuy.SetActiveIL(!isBuyZhanLing); imgBuy.SetActiveIL(isBuyZhanLing); OrderInfoConfig orderCfg; vipModel.TryGetOrderInfo(LvZhanlingModel.Instance.ctgIdDict[1], 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(LvZhanlingModel.Instance.ctgIdDict[1]).Percentage); } protected override void OnAfterOpen() { Initialize(); } protected override void OnPreClose() { PlayerDatas.Instance.playerDataRefreshEvent -= OnplayerDataRefreshEvent; LvZhanlingModel.Instance.UpdateGiftStateEvent -= UpdateGiftStateEvent; scroller.OnRefreshCell -= OnScrollerRefreshCell; } private void OnplayerDataRefreshEvent(PlayerDataType type) { if (type == PlayerDataType.LV) { if (LvZhanlingModel.Instance.zhanLingInfoDict == null || !LvZhanlingModel.Instance.zhanLingInfoDict.ContainsKey(1)) return; scroller.m_Scorller.RefreshActiveCellViews(); LvZhanlingModel.Instance.IsPlayAnimation = true; } } private void UpdateGiftStateEvent() { scroller.m_Scorller.RefreshActiveCellViews(); bool isBuyZhanLing = LvZhanlingModel.Instance.zhanLingInfoDict[1].isActivite > 0; btnBuy.SetActiveIL(!isBuyZhanLing); imgBuy.SetActiveIL(isBuyZhanLing); LvZhanlingModel.Instance.IsPlayAnimation = true; } private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell) { var _cell = cell.GetILBehaviour(); _cell.Display(cell.index); LvZhanlingModel.Instance.IsPlayAnimation = true; } void Initialize() { List cellList = ILZhanlingConfig.GetTypeToIDDict(1).Keys.ToList(); scroller.Refresh(); for (int i = 0; i < cellList.Count; i++) { scroller.AddCell(ScrollerDataType.Header, cellList[i]); } scroller.Restart(); scroller.JumpIndex(LvZhanlingModel.Instance.GetJumpStartIndex(1)); LvZhanlingModel.Instance.IsPlayAnimation = true; } }