using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
// 炼器战令
|
public class LianQiZhanLingWin : Window
|
{
|
[SerializeField] ScrollerController scroller;
|
[SerializeField] ButtonEx btnClose;
|
[SerializeField] ButtonEx btnPaidLock;
|
[SerializeField] ButtonEx btnPaidLockH;
|
[SerializeField] TextEx txtNowNeedValue;
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
ZhanLingHActBuyModel zhanLingHActBuyModel { get { return ModelCenter.Instance.GetModel<ZhanLingHActBuyModel>(); } }
|
LianQiZhanLingModel model { get { return ModelCenter.Instance.GetModel<LianQiZhanLingModel>(); } }
|
|
protected override void AddListeners()
|
{
|
btnClose.SetListener(() =>
|
{
|
CloseClick();
|
});
|
|
btnPaidLock.SetListener(() =>
|
{
|
zhanLingHActBuyModel.ShowZhanLingHBuy(model.ZhanLingHType, 1, model.GetValue1());
|
});
|
|
btnPaidLockH.SetListener(() =>
|
{
|
zhanLingHActBuyModel.ShowZhanLingHBuy(model.ZhanLingHType, 2, model.GetValue1());
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
model.UpdateGiftStateEvent += UpdateGiftStateEvent;
|
scroller.OnRefreshCell += OnScrollerRefreshCell;
|
vipModel.rechargeCountEvent += OnRechargeCountEvent;
|
Display();
|
}
|
|
private void Display()
|
{
|
//0 没购买进阶和玄级 1 购买了进阶没买玄级 2 购买了玄级没买进阶 3 购买了进阶和玄级
|
int buyState = model.GetBuyState(model.ZhanLingHType);
|
scroller.m_Scorller.RefreshActiveCellViews();
|
txtNowNeedValue.text = Language.Get("LianQiZhanLing04", model.GetValue1());
|
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];
|
model.IsPlayAnimation = true;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
Initialize();
|
}
|
|
protected override void OnPreClose()
|
{
|
model.UpdateGiftStateEvent -= UpdateGiftStateEvent;
|
scroller.OnRefreshCell -= OnScrollerRefreshCell;
|
vipModel.rechargeCountEvent -= OnRechargeCountEvent;
|
}
|
|
private void OnRechargeCountEvent(int obj)
|
{
|
if (obj == model.ctgIdDict[model.ZhanLingHType][0] ||
|
obj == model.ctgIdDictH[model.ZhanLingHType][0])
|
{
|
Display();
|
scroller.m_Scorller.RefreshActiveCellViews();
|
}
|
}
|
|
private void UpdateGiftStateEvent()
|
{
|
Display();
|
scroller.m_Scorller.RefreshActiveCellViews();
|
}
|
|
private float timer = 0.0f;
|
private bool canPlayAnimation = true;
|
|
protected override void LateUpdate()
|
{
|
// 更新计时器
|
timer += Time.unscaledDeltaTime;
|
|
// 检查计时器是否超过 0.3 秒
|
if (timer >= 0.3f)
|
{
|
canPlayAnimation = true;
|
|
timer = 0.0f;
|
}
|
}
|
|
private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell as LianQiZhanLingCell;
|
_cell.Display(_cell.index);
|
|
if (canPlayAnimation)
|
{
|
model.IsPlayAnimation = true;
|
canPlayAnimation = false;
|
}
|
}
|
|
private 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()
|
{
|
}
|
}
|
}
|