//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, June 11, 2019
|
//--------------------------------------------------------
|
|
using UnityEngine.UI;
|
using System.Collections.Generic;
|
using vnxbqy.UI;
|
|
public class LuckyCloudBuyWin : ILWindow
|
{
|
Button m_Close;
|
ItemCell bigItemCell;
|
Text bigPrice;
|
List<Image> moneyTypes = new List<Image>();
|
ScrollerController items;
|
ButtonEx buyOneBtn;
|
ButtonEx buyTenBtn;
|
Text buyYetCnt;
|
Text remainCnt;
|
Text priceOne;
|
Text priceTen;
|
Button lastAwardBtn;
|
RichText buyersText;
|
Image overImg;
|
TextEx nextTime;
|
|
|
OperationLuckyCloudBuy operation;
|
#region Built-in
|
protected override void BindController()
|
{
|
m_Close = proxy.GetWidgtEx<Button>("CloseButton");
|
bigItemCell = proxy.GetWidgtEx<ItemCell>("BigGift");
|
bigPrice = proxy.GetWidgtEx<Text>("bigprice");
|
items = proxy.GetWidgtEx<ScrollerController>("Scroller");
|
buyOneBtn = proxy.GetWidgtEx<ButtonEx>("buyonebtn");
|
buyTenBtn = proxy.GetWidgtEx<ButtonEx>("buytenbtn");
|
buyYetCnt = proxy.GetWidgtEx<Text>("buycntyet");
|
remainCnt = proxy.GetWidgtEx<Text>("opencnt");
|
priceOne = proxy.GetWidgtEx<Text>("priceone");
|
priceTen = proxy.GetWidgtEx<Text>("priceten");
|
lastAwardBtn = proxy.GetWidgtEx<Button>("lastaward");
|
buyersText = proxy.GetWidgtEx<RichText>("buyertext");
|
|
moneyTypes.Add(proxy.GetWidgtEx<Image>("moneytype1"));
|
moneyTypes.Add(proxy.GetWidgtEx<Image>("moneytype2"));
|
moneyTypes.Add(proxy.GetWidgtEx<Image>("moneytype3"));
|
overImg = proxy.GetWidgtEx<Image>("overimg");
|
nextTime = proxy.GetWidgtEx<TextEx>("nextTime");
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.SetListener(()=> {
|
CloseWin<LuckyCloudBuyWin>();
|
});
|
|
buyOneBtn.SetListener(BuyOne);
|
buyTenBtn.SetListener(BuyTen);
|
|
lastAwardBtn.SetListener(()=> {
|
LuckyCloudBuyModel.Instance.QueryLuckyCloudAward((byte)operation.m_ZoneID);
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
QueryBuyersInfo();
|
items.OnRefreshCell += OnRefreshCell;
|
LuckyCloudBuyModel.Instance.LuckyCloudBuyEvent += DisplayAfterBuy;
|
LuckyCloudBuyModel.Instance.LuckyCloudBuyStarNewRound += Display;
|
|
OperationBase operationBase;
|
if (!OperationTimeHepler.Instance.TryGetOperationTime(LuckyCloudBuyModel.operationType, out operationBase))
|
{
|
CloseWin<LuckyCloudBuyWin>();
|
return;
|
}
|
operation = operationBase as OperationLuckyCloudBuy;
|
}
|
protected override void OnAfterOpen()
|
{
|
Display();
|
}
|
|
void QueryBuyersInfo()
|
{
|
if (LuckyCloudBuyModel.Instance.buyersInfo.Count > 0) return;
|
var pack = new IL_CC005_tagCGQueryLuckyCloudBuyNumRec();
|
GameNetSystem.Instance.SendInfo(pack);
|
}
|
|
|
protected override void OnPreClose()
|
{
|
items.OnRefreshCell -= OnRefreshCell;
|
LuckyCloudBuyModel.Instance.LuckyCloudBuyEvent -= DisplayAfterBuy;
|
LuckyCloudBuyModel.Instance.LuckyCloudBuyStarNewRound -= Display;
|
}
|
|
#endregion
|
|
void Display()
|
{
|
int superItemID = operation.m_SuperItemID;
|
var itemModel = new ItemCellModel(superItemID, false, (ulong)operation.m_SuperItemCount);
|
bigItemCell.Init(itemModel);
|
bigItemCell.button.SetListener(() => {
|
ItemTipUtility.Show(superItemID);
|
});
|
|
bigPrice.text = operation.m_SuperItemMoneyValue.ToString();
|
for (int i = 0; i < moneyTypes.Count; i++)
|
{
|
moneyTypes[i].SetIconWithMoneyType(operation.m_SuperItemMoneyType);
|
}
|
|
items.Refresh();
|
|
for (int i = 0; i < operation.m_RandItemList.Count; i++)
|
{
|
items.AddCell(ScrollerDataType.Header, i);
|
}
|
items.Restart();
|
|
priceOne.text = LuckyCloudBuyModel.Instance.luckyCloudCost[1][1].ToString();
|
priceTen.text = LuckyCloudBuyModel.Instance.luckyCloudCost[10][1].ToString();
|
|
DisplayAfterBuy();
|
}
|
|
void DisplayAfterBuy()
|
{
|
buyYetCnt.text = LuckyCloudBuyModel.Instance.buyCntYet.ToString();
|
remainCnt.text = LuckyCloudBuyModel.Instance.remainCnt.ToString();
|
|
string showStr = string.Empty;
|
for (int i = LuckyCloudBuyModel.Instance.buyersInfo.Count - 1; i >= 0; i--)
|
{
|
showStr += Language.Get("LuckyCloundBuy2", LuckyCloudBuyModel.Instance.buyersInfo[i].name, LuckyCloudBuyModel.Instance.buyersInfo[i].num);
|
}
|
buyersText.text = showStr;
|
|
overImg.SetActiveIL(LuckyCloudBuyModel.Instance.remainCnt == 0);
|
buyOneBtn.SetColorful(null, LuckyCloudBuyModel.Instance.remainCnt != 0);
|
buyTenBtn.SetColorful(null, LuckyCloudBuyModel.Instance.remainCnt != 0);
|
if (operation.IsOver())
|
{
|
var timeList = operation.GetStartTime();
|
if (timeList == null)
|
nextTime.text = Language.Get("LuckyCloudTime2");
|
else
|
nextTime.text = Language.Get("LuckyCloudTime1", timeList[0].ToString("D2") + ":" + timeList[1].ToString("D2"));
|
}
|
else
|
{
|
nextTime.text = string.Empty;
|
}
|
}
|
|
void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetComponentEx<ItemCell>();
|
int index = cell.index;
|
int itemID = operation.m_RandItemList[index].id;
|
var itemModel = new ItemCellModel(itemID, false, (ulong)operation.m_RandItemList[index].count);
|
_cell.Init(itemModel);
|
_cell.button.SetListener(() => {
|
ItemTipUtility.Show(itemID);
|
});
|
}
|
|
void BuyOne()
|
{
|
LuckyCloudBuyModel.Instance.LuckyCloudBuy(1);
|
}
|
|
void BuyTen()
|
{
|
LuckyCloudBuyModel.Instance.LuckyCloudBuy(10);
|
}
|
}
|