//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, June 11, 2019
|
//--------------------------------------------------------
|
|
using vnxbqy.UI;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
|
public class NewGuyGiftWin : ILWindow
|
{
|
|
Button m_Close;
|
List<ItemCell> awardList = new List<ItemCell>();
|
Image state;
|
Button Btn_Buy;
|
Text buyText;
|
Text title;
|
Text timeText;
|
Text saleInfo;
|
TextEx orgPrice;
|
|
VipModel vipModel { get { return ModelCenter.Instance.GetModelEx<VipModel>(); } }
|
|
int ctgID = 0;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
m_Close = proxy.GetWidgtEx<Button>("closebtn");
|
for (int i = 0; i < 5; i++)
|
{
|
awardList.Add(proxy.GetWidgtEx<ItemCell>("itemcell" + i));
|
}
|
|
Btn_Buy = proxy.GetWidgtEx<Button>("buybtn");
|
state = proxy.GetWidgtEx<Image>("ImageEx");
|
buyText = proxy.GetWidgtEx<Text>("buytext");
|
title = proxy.GetWidgtEx<Text>("title");
|
timeText = proxy.GetWidgtEx<Text>("time");
|
saleInfo = proxy.GetWidgtEx<Text>("saleinfo");
|
var obj = Btn_Buy.FindComponent("Text", "Txt_orgPrice");
|
if (obj != null)
|
orgPrice = obj as TextEx;
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.SetListener(()=> {
|
CloseWin<NewGuyGiftWin>();
|
});
|
|
Btn_Buy.SetListener(() => {
|
if (ctgID == 0) return;
|
vipModel.CTG(ctgID);
|
NewGuyGiftModel.Instance.buyPlayerID = (int)PlayerDatas.Instance.PlayerId;
|
NewGuyGiftModel.Instance.buyCTGID = ctgID;
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
ctgID = NewGuyGiftModel.Instance.RefreshShowCtgID();
|
GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
|
vipModel.rechargeCountEvent += OnRechargeCountEvent;
|
Display();
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
|
vipModel.rechargeCountEvent -= OnRechargeCountEvent;
|
}
|
#endregion
|
|
void Display()
|
{
|
if (ctgID == 0)
|
{
|
return;
|
}
|
List<Item> itemList;
|
vipModel.TryGetRechargeItem(ctgID, out itemList);
|
for (int i = 0; i < awardList.Count; i++)
|
{
|
if (i < itemList.Count)
|
{
|
awardList[i].SetActiveIL(true);
|
var itemId = itemList[i].id;
|
var model = new ItemCellModel(itemId, false, (ulong)itemList[i].count);
|
awardList[i].Init(model);
|
awardList[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
else
|
{
|
awardList[i].SetActiveIL(false);
|
}
|
}
|
VipModel.RechargeCount rechargeCount;
|
vipModel.TryGetRechargeCount(ctgID, out rechargeCount);
|
|
state.SetActiveIL(rechargeCount.totalCount > 0);
|
Btn_Buy.SetActiveIL(rechargeCount.totalCount == 0);
|
OrderInfoConfig config;
|
vipModel.TryGetOrderInfo(ctgID, out config);
|
buyText.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(config.PayRMBNum));
|
if (orgPrice != null)
|
{
|
orgPrice.SetActiveIL(PlayerDatas.Instance.baseData.IsActive90Off);
|
orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(config.m_PayRMBNum));
|
}
|
var ctgConfig = CTGConfig.Get(ctgID);
|
title.text = ctgConfig.Title;
|
saleInfo.text = Language.Get("SaleOffInfo02", ctgConfig.Percentage);
|
}
|
|
void OnSecondEvent()
|
{
|
if (ctgID == 0)
|
{
|
CloseWin<NewGuyGiftWin>();
|
return;
|
}
|
timeText.text = TimeUtility.SecondsToHMS(NewGuyGiftModel.Instance.GetShowCTGTime());
|
}
|
|
void OnRechargeCountEvent(int ctgid)
|
{
|
Display();
|
}
|
}
|