using vnxbqy.UI; using System.Collections.Generic; using System.Linq; using UnityEngine; // 聚魂战令 public class GatheringSoulZhanLingWin : Window { [SerializeField] ScrollerController scroller; [SerializeField] ButtonEx btnClose; [SerializeField] ButtonEx btnPaidLock; [SerializeField] ButtonEx btnPaidLockH; [SerializeField] TextEx txtPaidLock; [SerializeField] TextEx txtPaidLockH; [SerializeField] TextEx txtNowNeedValue; VipModel vipModel { get { return ModelCenter.Instance.GetModel(); } } ZhanLingHBuyModel zhanLingHBuyModel { get { return ModelCenter.Instance.GetModel(); } } GatheringSoulZhanLingModel model { get { return ModelCenter.Instance.GetModel(); } } GatheringSoulModel gsModel { get { return ModelCenter.Instance.GetModel(); } } protected override void AddListeners() { btnClose.SetListener(() => { WindowCenter.Instance.Close(); }); btnPaidLock.SetListener(() => { zhanLingHBuyModel.ShowZhanLingHBuy(GatheringSoulZhanLingModel.ZhanLingHType, 1); }); btnPaidLockH.SetListener(() => { zhanLingHBuyModel.ShowZhanLingHBuy(GatheringSoulZhanLingModel.ZhanLingHType, 2); }); } protected override void OnPreOpen() { model.UpdateGiftStateEvent += UpdateGiftStateEvent; scroller.OnRefreshCell += OnScrollerRefreshCell; vipModel.rechargeCountEvent += OnRechargeCountEvent; gsModel.UpdateSoulInfos += OnUpdateSoulInfos; Display(); } void Display() { //0 没购买进阶和玄级 1 购买了进阶没买玄级 2 购买了玄级没买进阶 3 购买了进阶和玄级 int buyState = model.GetBuyState(GatheringSoulZhanLingModel.ZhanLingHType); scroller.m_Scorller.RefreshActiveCellViews(); int ctgId1 = model.ctgIdDict[GatheringSoulZhanLingModel.ZhanLingHType][0]; int ctgId2 = model.ctgIdDictH[GatheringSoulZhanLingModel.ZhanLingHType][0]; txtNowNeedValue.text = Language.Get("GatheringSoulZhanLing05", gsModel.GetGatherSoulTotalLV()); btnPaidLock.SetActive(buyState == 0 || buyState == 2); btnPaidLockH.SetActive(buyState == 0 || buyState == 1); txtPaidLock.text = CTGConfig.Get(ctgId1).Title; txtPaidLockH.text = CTGConfig.Get(ctgId2).Title; model.IsPlayAnimation = true; } protected override void OnAfterOpen() { Initialize(); } protected override void OnPreClose() { model.UpdateGiftStateEvent -= UpdateGiftStateEvent; scroller.OnRefreshCell -= OnScrollerRefreshCell; vipModel.rechargeCountEvent -= OnRechargeCountEvent; gsModel.UpdateSoulInfos -= OnUpdateSoulInfos; } void OnUpdateSoulInfos(bool noChangeCnt) { Display(); } void OnRechargeCountEvent(int obj) { if (obj == model.ctgIdDict[GatheringSoulZhanLingModel.ZhanLingHType][0] || obj == model.ctgIdDictH[GatheringSoulZhanLingModel.ZhanLingHType][0]) { Display(); } } private void UpdateGiftStateEvent() { Display(); } private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell) { var _cell = cell as GatheringSoulZhanLingCell; _cell.Display(_cell.index); model.IsPlayAnimation = true; } void Initialize() { List cellList = ILZhanlingConfig.GetTypeToIDDict(GatheringSoulZhanLingModel.ZhanLingHType).Keys.ToList(); scroller.Refresh(); for (int i = 0; i < cellList.Count; i++) { scroller.AddCell(ScrollerDataType.Header, cellList[i]); } scroller.Restart(); scroller.JumpIndex(model.GetJumpStartIndex(GatheringSoulZhanLingModel.ZhanLingHType)); model.IsPlayAnimation = true; } protected override void BindController() { } protected override void OnAfterClose() { } }