//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, September 26, 2018
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
using System.Collections.Generic;
|
|
namespace vnxbqy.UI
|
{
|
public class FairyAffinityRechargeGiftActCell : CellView
|
{
|
[SerializeField] Text title;
|
[SerializeField] ImageEx bg;
|
[SerializeField] ImageEx titleBG;
|
[SerializeField] List<CustomizedItemCell> itemCells;
|
[SerializeField] Button buyBtn;
|
[SerializeField] Text priceText;
|
[SerializeField] Image buyYetImg;
|
[SerializeField] Image imgProfitRatio;
|
[SerializeField] Text txtProfitRatio;
|
|
TextEx orgPrice;
|
|
FairyAffinityRechargeGiftActModel model { get { return ModelCenter.Instance.GetModel<FairyAffinityRechargeGiftActModel>(); } }
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
|
BossTrialModel bossTrialModel { get { return ModelCenter.Instance.GetModel<BossTrialModel>(); } }
|
StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
CustomizedRechargeModel customizedRechargeModel { get { return ModelCenter.Instance.GetModel<CustomizedRechargeModel>(); } }
|
|
public void Display(int index)
|
{
|
OperationRechargeGiftAct act;
|
OperationTimeHepler.Instance.TryGetOperation(FairyAffinityRechargeGiftActModel.operaType, out act);
|
if (act == null)
|
return;
|
bg.SetSprite(index % 2 == 0 ? "FairyAffinityGiftBG1" : "FairyAffinityGiftBG2");
|
titleBG.SetSprite(index % 2 == 0 ? "FairyAffinityGiftTitleBG1" : "FairyAffinityGiftTitleBG2");
|
|
List<StoreConfig> _list = null;
|
StoreConfig.TryGetStoreConfigs(act.shopType, out _list);
|
|
if (_list != null && index < _list.Count)
|
{
|
DisplayStore(_list[index]);
|
return;
|
}
|
index = index - (_list != null ? _list.Count : 0);
|
|
int ctgID = act.ctgIDs[index];
|
var ctgConfig = CTGConfig.Get(ctgID);
|
title.text = ctgConfig.Title;
|
|
var countInfo = model.GetBuyCntInfo(ctgID);
|
|
int buyCnt = countInfo.x;
|
int totalCnt = countInfo.y;
|
|
customizedRechargeModel.ShowUIItems(itemCells, ctgID);
|
|
buyBtn.SetActive(buyCnt < totalCnt);
|
buyBtn.SetListener(() =>
|
{
|
if (PlayerDatas.Instance.baseData.VIPLv < ctgConfig.VipLevel)
|
{
|
SysNotifyMgr.Instance.ShowTip("VIPNotEnough", ctgConfig.VipLevel);
|
return;
|
}
|
|
if (bossTrialModel.IsOpen)
|
{
|
//参与时间结束前直接购买,时间结束后再购买需要弹窗提示
|
if (bossTrialModel.IsPrepareTime || bossTrialModel.IsJoin)
|
vipModel.CTG(ctgID);
|
else
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("BossTrial14"), (bool isOk) =>
|
{
|
if (isOk)
|
{
|
vipModel.CTG(ctgID);
|
}
|
});
|
}
|
}
|
else
|
{
|
vipModel.CTG(ctgID);
|
}
|
});
|
buyYetImg.SetActive(buyCnt >= totalCnt);
|
|
OrderInfoConfig orderConfig;
|
vipModel.TryGetOrderInfo(ctgID, out orderConfig);
|
imgProfitRatio.SetActive(orderConfig != null);
|
priceText.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat((long)orderConfig.PayRMBNum));
|
txtProfitRatio.text = Language.Get("BlessedLand039", ctgConfig.Percentage);
|
|
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));
|
}
|
}
|
|
private void DisplayStore(StoreConfig storeConfig)
|
{
|
bool isFree = storeConfig.MoneyNumber == 0;
|
title.text = isFree ? Language.Get("StoreName_free") : Language.Get("StoreName_money");
|
|
int remainNum;
|
storeModel.TryGetIsSellOut(storeConfig, out remainNum);
|
|
var items = storeModel.GetShopItemlistByIndex(storeConfig);
|
|
for (int i = 0; i < itemCells.Count; i++)
|
{
|
var itemBaisc = itemCells[i];
|
if (i < items.Count)
|
{
|
var itemInfo = items[i];
|
itemBaisc.SetActive(true);
|
ItemCellModel cellModel = new ItemCellModel(itemInfo.itemId, false, (ulong)itemInfo.count);
|
itemBaisc.Init(cellModel);
|
itemBaisc.button.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemInfo.itemId);
|
});
|
}
|
else
|
{
|
itemBaisc.SetActive(false);
|
}
|
}
|
|
buyBtn.SetActive(remainNum > 0);
|
buyBtn.SetListener(() =>
|
{
|
storeModel.SendBuyShopItemWithPopCheck(storeConfig, 1, (int)BuyStoreItemCheckType.ActGift);
|
});
|
buyYetImg.SetActive(remainNum <= 0);
|
|
priceText.text = isFree ? Language.Get("AloneFree") : Language.Get("ItemOverdue105", storeConfig.MoneyNumber);
|
imgProfitRatio.SetActive(false);
|
//txtProfitRatio.text = Language.Get("BlessedLand039", ctgConfig.Percentage);
|
}
|
}
|
}
|