//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, September 26, 2018
|
//--------------------------------------------------------
|
using UnityEngine;
|
using UnityEngine.UI;
|
using System.Collections.Generic;
|
|
namespace vnxbqy.UI
|
{
|
|
public class CustomizedGiftCell : CellView
|
{
|
[SerializeField] Text title;
|
[SerializeField] Text saleValue;
|
[SerializeField] Text limiteBuyCntText;
|
[SerializeField] List<CustomizedItemCell> itemCells;
|
[SerializeField] Button buyBtn;
|
[SerializeField] Text priceText;
|
[SerializeField] Button haveBtn;
|
[SerializeField] Image buyYetImg;
|
[SerializeField] Image haveYetImg;
|
[SerializeField] ImageEx ImgSale;
|
int girdIndex = 0;
|
TextEx orgPrice;
|
|
CustomizedGiftModel model { get { return ModelCenter.Instance.GetModel<CustomizedGiftModel>(); } }
|
CustomizedRechargeModel crModel { get { return ModelCenter.Instance.GetModel<CustomizedRechargeModel>(); } }
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
|
|
public void Display(int index)
|
{
|
OperationRechargeGiftAct act;
|
if (!OperationTimeHepler.Instance.TryGetOperation(CustomizedGiftModel.operaType, out act))
|
{
|
return;
|
}
|
//免费礼包
|
if (model.IsFree(index))
|
{
|
ImgSale.SetActive(false);
|
buyBtn.SetActive(false);
|
buyYetImg.SetActive(false);
|
limiteBuyCntText.SetActive(false);
|
haveBtn.SetActive(true);
|
title.text = Language.Get("CustomizedGift02");
|
int totalBuyCnt = model.GetBuyTotalCnt();
|
var awardInfo = act.buyCountGifts[index];
|
for (int i = 0; i < itemCells.Count; i++)
|
{
|
if (i < awardInfo.AwardItemList.Length)
|
{
|
var award = awardInfo.AwardItemList[i];
|
itemCells[i].button.interactable = true;
|
itemCells[i].SetActive(true);
|
var itemData = new ItemCellModel((int)award.ItemID, false, award.ItemCount);
|
itemCells[i].Init(itemData);
|
itemCells[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show((int)award.ItemID);
|
});
|
}
|
else
|
{
|
itemCells[i].SetActive(false);
|
}
|
}
|
haveBtn.SetColorful(null, totalBuyCnt >= awardInfo.NeedBuyCount);
|
haveBtn.interactable = totalBuyCnt >= awardInfo.NeedBuyCount;
|
haveBtn.SetListener(() =>
|
{
|
model.SendGetAward(awardInfo.NeedBuyCount);
|
});
|
|
if (index == act.buyCountGifts.Count - 1 && model.GetBuyGiftState(awardInfo.NeedBuyCount) == 2)
|
{
|
haveYetImg.SetActive(true);
|
haveBtn.SetActive(false);
|
}
|
else
|
{
|
haveYetImg.SetActive(false);
|
haveBtn.SetActive(true);
|
}
|
}
|
//付费礼包
|
else
|
{
|
haveBtn.SetActive(false);
|
haveYetImg.SetActive(false);
|
limiteBuyCntText.SetActive(true);
|
ImgSale.SetActive(true);
|
|
int actCtgIndex = index - 1;
|
int ctgID = act.ctgIDs[actCtgIndex];
|
|
crModel.ShowUIItems(itemCells, ctgID);
|
|
var ctgConfig = CTGConfig.Get(ctgID);
|
title.text = ctgConfig.Title;
|
saleValue.text = Language.Get("RechargeGiftActWin3", ctgConfig.Percentage);
|
var countInfo = model.GetBuyCntInfo(ctgID);
|
int buyCnt = countInfo.x;
|
int totalCnt = countInfo.y;
|
limiteBuyCntText.text = Language.Get("RechargeGiftActWin4", UIHelper.AppendColor(buyCnt >= totalCnt ? TextColType.Red : TextColType.Green, buyCnt + "/" + totalCnt, true));
|
buyBtn.SetActive(buyCnt < totalCnt);
|
buyBtn.SetListener(() =>
|
{
|
vipModel.CTG(ctgID);
|
});
|
buyYetImg.SetActive(buyCnt >= totalCnt);
|
OrderInfoConfig orderConfig;
|
vipModel.TryGetOrderInfo(ctgID, out orderConfig);
|
priceText.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat((long)orderConfig.PayRMBNum));
|
|
var obj = buyBtn.FindComponent("Text", "Txt_orgPrice");
|
if (obj != null)
|
orgPrice = obj as TextEx;
|
|
if (orgPrice != null)
|
{
|
orgPrice.SetActiveIL(PlayerDatas.Instance.baseData.IsActive90Off);
|
orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.m_PayRMBNum));
|
}
|
|
}
|
}
|
|
|
}
|
|
}
|