using UnityEngine.UI;
|
using UnityEngine;
|
using vnxbqy.UI;
|
using System.Collections.Generic;
|
|
public class Buy1Free5Cell : ILBehaviour
|
{
|
List<ItemCell> items = new List<ItemCell>();
|
Button buyBtn;
|
Text buyBtnTxt;
|
ImageEx freeLock;
|
Image stateImg;
|
TextEx orgPrice;
|
|
VipModel vipModel { get { return ModelCenter.Instance.GetModelEx<VipModel>(); } }
|
protected override void Awake()
|
{
|
buyBtn = proxy.GetWidgtEx<Button>("BuyButton");
|
buyBtnTxt = proxy.GetWidgtEx<Text>("Text");
|
freeLock = proxy.GetWidgtEx<ImageEx>("lockimg");
|
stateImg = proxy.GetWidgtEx<Image>("BoughtObj");
|
for (int i = 0; i < 2; i++)
|
{
|
items.Add(proxy.GetWidgtEx<ItemCell>("ItemCell" + i));
|
}
|
|
var obj = buyBtn.FindComponent("Text", "Txt_orgPrice");
|
if (obj != null)
|
orgPrice = obj as TextEx;
|
}
|
|
public void Display(int index)
|
{
|
OperationBuy1Free5 operation;
|
if (!OperationTimeHepler.Instance.TryGetOperation(Buy1Free5Model.operationType, out operation))
|
{
|
return;
|
}
|
int actNum = operation.ActNum;
|
int ctgID = operation.indexToCTGIDDict[Buy1Free5Model.Instance.selectCTGIDIndex];
|
VipModel.RechargeCount rechargeCount;
|
vipModel.TryGetRechargeCount(ctgID, out rechargeCount);
|
if (index == 0)
|
{
|
buyBtn.SetActiveIL(rechargeCount.todayCount == 0);
|
buyBtn.AddListener(() =>
|
{
|
vipModel.CTG(ctgID);
|
});
|
OrderInfoConfig config;
|
vipModel.TryGetOrderInfo(ctgID, out config);
|
buyBtnTxt.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));
|
}
|
|
freeLock.SetActiveIL(false);
|
stateImg.SetActiveIL(rechargeCount.todayCount != 0);
|
|
List<Item> awards = new List<Item>();
|
vipModel.TryGetRechargeItem(ctgID, out awards);
|
for (int i = 0; i < items.Count; i++)
|
{
|
if (awards != null && i < awards.Count)
|
{
|
items[i].SetActiveIL(true);
|
var itemId = awards[i].id;
|
var model = new ItemCellModel(itemId, false, (ulong)awards[i].count);
|
items[i].Init(model);
|
items[i].auctionIcon.SetActiveIL(awards[i].bind != 0);
|
items[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
else
|
{
|
items[i].SetActiveIL(false);
|
}
|
}
|
}
|
else
|
{
|
int freeIndex = index - 1;
|
|
var state = Buy1Free5Model.Instance.GetFreeGiftState(Buy1Free5Model.Instance.selectCTGIDIndex, ctgID, freeIndex);
|
buyBtn.SetActiveIL(state != 2);
|
buyBtn.AddListener(() =>
|
{
|
if (state == 1)
|
{
|
var pak = new IL_CA504_tagCMPlayerGetReward();
|
pak.RewardType = 60;
|
pak.DataEx = (uint)(Buy1Free5Model.Instance.selectCTGIDIndex * 100 + freeIndex); // 奖励索引
|
pak.DataExStr = actNum.ToString(); // 活动编号
|
pak.DataExStrLen = (byte)pak.DataExStr.Length;
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("Buy1Free5");
|
}
|
});
|
|
buyBtnTxt.text = Language.Get("Z2014");
|
freeLock.SetActiveIL(state != 1);
|
stateImg.SetActiveIL(state == 2);
|
|
|
var awards = operation.CTGIDToFreeDict[ctgID][freeIndex];
|
for (int i = 0; i < items.Count; i++)
|
{
|
if (i < awards.Count)
|
{
|
items[i].SetActiveIL(true);
|
var itemId = awards[i].id;
|
var model = new ItemCellModel(itemId, false, (ulong)awards[i].count);
|
items[i].Init(model);
|
items[i].auctionIcon.SetActiveIL(awards[i].bind != 0);
|
items[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
else
|
{
|
items[i].SetActiveIL(false);
|
}
|
}
|
}
|
}
|
|
}
|