using vnxbqy.UI;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
|
// 骑宠战令
|
public class MountedPetZhanLingWin : 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<VipModel>(); } }
|
ZhanLingHBuyModel zhanLingHBuyModel { get { return ModelCenter.Instance.GetModel<ZhanLingHBuyModel>(); } }
|
MountedPetZhanLingModel model { get { return ModelCenter.Instance.GetModel<MountedPetZhanLingModel>(); } }
|
PetHorseActModel petHorseActModel { get { return ModelCenter.Instance.GetModel<PetHorseActModel>(); } }
|
protected override void AddListeners()
|
{
|
btnClose.SetListener(() =>
|
{
|
WindowCenter.Instance.Close<MountedPetZhanLingWin>();
|
});
|
|
btnPaidLock.SetListener(() =>
|
{
|
zhanLingHBuyModel.ShowZhanLingHBuy(model.ZhanLingHType, 1, "ZhanLingHBuyBG2");
|
});
|
|
btnPaidLockH.SetListener(() =>
|
{
|
zhanLingHBuyModel.ShowZhanLingHBuy(model.ZhanLingHType, 2, "ZhanLingHBuyBG2");
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
model.UpdateGiftStateEvent += UpdateGiftStateEvent;
|
scroller.OnRefreshCell += OnScrollerRefreshCell;
|
vipModel.rechargeCountEvent += OnRechargeCountEvent;
|
Display();
|
}
|
|
void Display()
|
{
|
//0 没购买进阶和玄级 1 购买了进阶没买玄级 2 购买了玄级没买进阶 3 购买了进阶和玄级
|
int buyState = model.GetBuyState(model.ZhanLingHType);
|
scroller.m_Scorller.RefreshActiveCellViews();
|
txtNowNeedValue.text = Language.Get("MountedPetZhanLingWin01", petHorseActModel.actScore);
|
btnPaidLock.SetActive(buyState == 0 || buyState == 2);
|
btnPaidLockH.SetActive(buyState == 0 || buyState == 1);
|
int ctgId1 = model.ctgIdDict[model.ZhanLingHType][0];
|
int ctgId2 = model.ctgIdDictH[model.ZhanLingHType][0];
|
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;
|
}
|
|
void OnUpdateSoulInfos(bool noChangeCnt)
|
{
|
Display();
|
}
|
|
void OnRechargeCountEvent(int obj)
|
{
|
if (obj == model.ctgIdDict[model.ZhanLingHType][0] ||
|
obj == model.ctgIdDictH[model.ZhanLingHType][0])
|
{
|
Display();
|
}
|
}
|
|
private void UpdateGiftStateEvent()
|
{
|
Display();
|
}
|
|
private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell as MountedPetZhanLingCell;
|
_cell.Display(_cell.index);
|
model.IsPlayAnimation = true;
|
}
|
|
void Initialize()
|
{
|
List<int> cellList = ILZhanlingConfig.GetTypeToIDDict(model.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(model.ZhanLingHType));
|
model.IsPlayAnimation = true;
|
|
}
|
|
protected override void BindController()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
}
|