using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
// ÏÉÔµÕ½Áî
|
public class FairyAffinityZhanLingWin : Window
|
{
|
[SerializeField] ScrollerController scroller;
|
[SerializeField] TextEx txtBuy;
|
[SerializeField] TextEx txtProfitRatio;
|
[SerializeField] TextEx txtBuyValue;
|
[SerializeField] ButtonEx btnBuy;
|
[SerializeField] ImageEx imgBuy;
|
TextEx orgPrice;
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
FairyAffinityZhanLingModel model { get { return ModelCenter.Instance.GetModel<FairyAffinityZhanLingModel>(); } }
|
|
#region Built-in
|
|
protected override void AddListeners()
|
{
|
btnBuy.SetListener(() =>
|
{
|
vipModel.CTG(model.ctgIdDict[model.ZhanLingType]);
|
});
|
}
|
|
protected override void BindController()
|
{
|
var obj = btnBuy.FindComponent("Text", "Txt_orgPrice");
|
if (obj != null)
|
orgPrice = obj as TextEx;
|
}
|
|
protected override void OnPreOpen()
|
{
|
PlayerDatas.Instance.playerDataRefreshEvent += OnplayerDataRefreshEvent;
|
model.UpdateGiftStateEvent += UpdateGiftStateEvent;
|
scroller.OnRefreshCell += OnScrollerRefreshCell;
|
|
bool isBuyZhanLing = model.IsBuy();
|
btnBuy.SetActiveIL(!isBuyZhanLing);
|
imgBuy.SetActiveIL(isBuyZhanLing);
|
OrderInfoConfig orderCfg;
|
vipModel.TryGetOrderInfo(model.ctgIdDict[model.ZhanLingType], 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(model.ctgIdDict[model.ZhanLingType]).Percentage);
|
txtBuyValue.text = model.buyValue.ToString();
|
}
|
|
protected override void OnPreClose()
|
{
|
PlayerDatas.Instance.playerDataRefreshEvent -= OnplayerDataRefreshEvent;
|
model.UpdateGiftStateEvent -= UpdateGiftStateEvent;
|
scroller.OnRefreshCell -= OnScrollerRefreshCell;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
Initialize();
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
#endregion
|
|
private void OnplayerDataRefreshEvent(PlayerDataType type)
|
{
|
if (type == PlayerDataType.default42)
|
{
|
if (model.zhanLingInfoDict == null || !model.zhanLingInfoDict.ContainsKey(model.ZhanLingType))
|
return;
|
|
scroller.m_Scorller.RefreshActiveCellViews();
|
model.IsPlayAnimation = true;
|
}
|
}
|
|
private void UpdateGiftStateEvent()
|
{
|
scroller.m_Scorller.RefreshActiveCellViews();
|
bool isBuyZhanLing = model.IsBuy();
|
btnBuy.SetActiveIL(!isBuyZhanLing);
|
imgBuy.SetActiveIL(isBuyZhanLing);
|
model.IsPlayAnimation = true;
|
}
|
|
private void OnScrollerRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell as FairyAffinityZhanLingCell;
|
_cell.Display(_cell.index);
|
model.IsPlayAnimation = true;
|
}
|
|
private void Initialize()
|
{
|
List<int> cellList = ILZhanlingConfig.GetTypeToIDDict(model.ZhanLingType).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.ZhanLingType));
|
model.IsPlayAnimation = true;
|
}
|
}
|
}
|