//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, June 11, 2019
|
//--------------------------------------------------------
|
|
using vnxbqy.UI;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
|
public class OnlineRechargeWin : ILWindow
|
{
|
|
Button m_Close;
|
List<ItemCell> awardList = new List<ItemCell>();
|
Image state;
|
Button Btn_Get;
|
List<ItemCell> buyList1000 = new List<ItemCell>();
|
List<ItemCell> buyList30 = new List<ItemCell>();
|
Button buy1000;
|
Button buy30;
|
|
Button CloseBtn2;
|
Button NoWaitBtn;
|
Text NoWaitText1;
|
Text NoWaitText2;
|
Transform SecondBG;
|
Transform AwardList;
|
Text Price648;
|
Text Price30;
|
|
VipModel vipModel { get { return ModelCenter.Instance.GetModelEx<VipModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
m_Close = proxy.GetWidgtEx<Button>("CloseButton");
|
awardList.Add(proxy.GetWidgtEx<ItemCell>("award0"));
|
awardList.Add(proxy.GetWidgtEx<ItemCell>("award1"));
|
awardList.Add(proxy.GetWidgtEx<ItemCell>("award2"));
|
awardList.Add(proxy.GetWidgtEx<ItemCell>("award3"));
|
awardList.Add(proxy.GetWidgtEx<ItemCell>("award4"));
|
state = proxy.GetWidgtEx<Image>("Img_State");
|
Btn_Get = proxy.GetWidgtEx<Button>("Btn_Get");
|
buyList1000.Add(proxy.GetWidgtEx<ItemCell>("item1_1000"));
|
buyList1000.Add(proxy.GetWidgtEx<ItemCell>("item2_1000"));
|
buyList30.Add(proxy.GetWidgtEx<ItemCell>("item1_30"));
|
buyList30.Add(proxy.GetWidgtEx<ItemCell>("item2_30"));
|
buy1000 = proxy.GetWidgtEx<Button>("buy1000");
|
buy30 = proxy.GetWidgtEx<Button>("buy30");
|
|
CloseBtn2 = proxy.GetWidgtEx<Button>("CloseButton2");
|
NoWaitBtn = proxy.GetWidgtEx<Button>("nowait");
|
NoWaitText1 = proxy.GetWidgtEx<Text>("nowaitText1");
|
NoWaitText2 = proxy.GetWidgtEx<Text>("nowaitText2");
|
SecondBG = proxy.GetWidgtEx<Transform>("SecondBG");
|
AwardList = proxy.GetWidgtEx<Transform>("awardList");
|
Price648 = proxy.GetWidgtEx<Text>("TextEx648");
|
Price30 = proxy.GetWidgtEx<Text>("TextEx30");
|
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.SetListener(()=> {
|
CloseWin<OnlineRechargeWin>();
|
});
|
Btn_Get.SetListener(()=> {
|
OnlineRechargeModel.Instance.GetAward();
|
});
|
|
buy1000.SetListener(()=> {
|
vipModel.CTG(OnlineRechargeModel.Instance.ctgArray[0]);
|
});
|
|
buy30.SetListener(() => {
|
vipModel.CTG(OnlineRechargeModel.Instance.ctgArray[1]);
|
});
|
|
NoWaitBtn.SetListener(()=> {
|
SecondBG.SetActiveIL(true);
|
AwardList.SetActiveIL(false);
|
});
|
|
CloseBtn2.SetListener(() => {
|
SecondBG.SetActiveIL(false);
|
AwardList.SetActiveIL(true);
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
OnlineRechargeModel.Instance.updateEvent += Display;
|
Display();
|
OnlineRechargeModel.Instance.openyet = true;
|
OnlineRechargeModel.Instance.UpdateRedpoint();
|
if (IL_DTCA109_tagMCOnLineTimeTotal.onlineSeconds >= OnlineRechargeModel.Instance.changeSeconds)
|
{
|
LocalSave.SetBool(StringUtility.Contact(PlayerDatas.Instance.PlayerId, "zxth15"), true);
|
}
|
SecondBG.SetActiveIL(false);
|
AwardList.SetActiveIL(true);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
//OnPreOpen处理 第一次打开是亮的 此处重复调用一次
|
DisplayButton();
|
}
|
protected override void OnPreClose()
|
{
|
OnlineRechargeModel.Instance.updateEvent -= Display;
|
}
|
#endregion
|
|
void Display()
|
{
|
for (int i = 0; i < awardList.Count; i++)
|
{
|
if (i < OnlineRechargeModel.Instance.awards.Length)
|
{
|
awardList[i].SetActiveIL(true);
|
var itemId = OnlineRechargeModel.Instance.awards[i][0];
|
var model = new ItemCellModel(itemId, false, (ulong)OnlineRechargeModel.Instance.awards[i][1]);
|
awardList[i].Init(model);
|
awardList[i].auctionIcon.SetActiveIL(OnlineRechargeModel.Instance.awards[i][2] != 0);
|
awardList[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
else
|
{
|
awardList[i].SetActiveIL(false);
|
}
|
}
|
|
state.SetActiveIL(OnlineRechargeModel.Instance.state == 1);
|
//Btn_Get.SetActiveIL(OnlineRechargeModel.Instance.state == 0);
|
//Btn_Get.SetColorful(null, false);
|
|
List<Item> awards;
|
vipModel.TryGetRechargeItem(OnlineRechargeModel.Instance.ctgArray[0], out awards);
|
for (int i = 0; i < buyList1000.Count; i++)
|
{
|
if (i < awards.Count)
|
{
|
buyList1000[i].SetActiveIL(true);
|
var itemId = awards[i].id;
|
var model = new ItemCellModel(itemId, false, (ulong)awards[i].count);
|
buyList1000[i].Init(model);
|
buyList1000[i].auctionIcon.SetActiveIL(awards[i].bind != 0);
|
buyList1000[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
else
|
{
|
buyList1000[i].SetActiveIL(false);
|
}
|
}
|
|
vipModel.TryGetRechargeItem(OnlineRechargeModel.Instance.ctgArray[1], out awards);
|
for (int i = 0; i < buyList30.Count; i++)
|
{
|
if (i < awards.Count)
|
{
|
buyList30[i].SetActiveIL(true);
|
var itemId = awards[i].id;
|
var model = new ItemCellModel(itemId, false, (ulong)awards[i].count);
|
buyList30[i].Init(model);
|
buyList30[i].auctionIcon.SetActiveIL(awards[i].bind != 0);
|
buyList30[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
else
|
{
|
buyList30[i].SetActiveIL(false);
|
}
|
}
|
|
if (IL_DTCA109_tagMCOnLineTimeTotal.onlineSeconds < OnlineRechargeModel.Instance.changeSeconds)
|
{
|
buy1000.SetColorful(null, true);
|
buy1000.interactable = true;
|
buy30.SetColorful(null, false);
|
buy30.interactable = false;
|
NoWaitText1.SetActiveIL(true);
|
NoWaitText2.SetActiveIL(false);
|
}
|
else
|
{
|
buy1000.SetColorful(null, false);
|
buy1000.interactable = false;
|
buy30.SetColorful(null, true);
|
buy30.interactable = true;
|
NoWaitText1.SetActiveIL(false);
|
NoWaitText2.SetActiveIL(true);
|
|
}
|
OrderInfoConfig config;
|
vipModel.TryGetOrderInfo(OnlineRechargeModel.Instance.ctgArray[1], out config);
|
NoWaitText2.text = Language.Get("PriceBuy", UIHelper.GetMoneyFormat((int)config.PayRMBNum));
|
Price30.text = Language.Get("PriceBuy", UIHelper.GetMoneyFormat((int)config.PayRMBNum));
|
|
vipModel.TryGetOrderInfo(OnlineRechargeModel.Instance.ctgArray[0], out config);
|
Price648.text = Language.Get("PriceBuy", UIHelper.GetMoneyFormat((int)config.PayRMBNum));
|
DisplayButton();
|
}
|
|
void DisplayButton()
|
{
|
int buycnt = 0;
|
VipModel.RechargeCount rechargeCount;
|
if (vipModel.TryGetRechargeCount(OnlineRechargeModel.Instance.ctgArray[0], out rechargeCount))
|
{
|
buy1000.SetActiveIL(rechargeCount.totalCount == 0);
|
if (rechargeCount.totalCount > 0)
|
{
|
buycnt++;
|
}
|
}
|
if (vipModel.TryGetRechargeCount(OnlineRechargeModel.Instance.ctgArray[1], out rechargeCount))
|
{
|
buy30.SetActiveIL(rechargeCount.totalCount == 0);
|
if (rechargeCount.totalCount > 0)
|
{
|
buycnt++;
|
}
|
}
|
//Btn_Get.SetColorful(null, buycnt > 0);
|
Btn_Get.SetActiveIL(OnlineRechargeModel.Instance.state == 0 && buycnt > 0);
|
NoWaitBtn.SetActiveIL(buycnt == 0);
|
|
}
|
}
|