using System.Collections.Generic;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
public class CycleHallGiftCell : CellView
|
{
|
[SerializeField] TextEx txtTitle;
|
[SerializeField] List<ItemCell> giftItemCells = new List<ItemCell>();
|
[SerializeField] ButtonEx btnBuy;
|
[SerializeField] ImageEx imgRed;
|
[SerializeField] TextEx txtBuy;
|
[SerializeField] ImageEx imgBuy;
|
[SerializeField] TextEx txtLimitCount;
|
|
[SerializeField] TextEx orgPrice;
|
int roundType;
|
|
CycleHallActModel model { get { return ModelCenter.Instance.GetModel<CycleHallActModel>(); } }
|
VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
BossTrialModel bossTrialModel { get { return ModelCenter.Instance.GetModel<BossTrialModel>(); } }
|
StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
|
public void Display(int index, CellView cellView)
|
{
|
roundType = cellView.info.Value.infoInt1;
|
imgRed.SetActive(false);
|
if (model.playerInfoDict == null || !model.playerInfoDict.TryGetValue((byte)roundType, out var playerInfo) || playerInfo == null)
|
return;
|
|
var act = model.GetOperationInfo();
|
if (act == null || !act.TryGetRound(roundType, out var round) || round.CTGIDList == null)
|
return;
|
List<StoreConfig> _list = null;
|
StoreConfig.TryGetStoreConfigs(round.ShopType, out _list);
|
if (_list != null && index < _list.Count)
|
{
|
DisplayStore(_list[index]);
|
return;
|
}
|
index = index - (_list != null ? _list.Count : 0);
|
if (round.CTGIDList.Length <= index || index < 0)
|
return;
|
int ctgId = round.CTGIDList[index];
|
if (!CTGConfig.Has(ctgId))
|
return;
|
CTGConfig config = CTGConfig.Get(ctgId);
|
|
var countInfo = GetBuyCntInfo(ctgId);
|
int buyCnt = countInfo.x;
|
int totalCnt = countInfo.y;
|
btnBuy.SetActive(buyCnt < totalCnt);
|
imgBuy.SetActive(buyCnt >= totalCnt);
|
OrderInfoConfig orderConfig;
|
vipModel.TryGetOrderInfo(ctgId, out orderConfig);
|
txtBuy.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.PayRMBNum));
|
txtLimitCount.SetActive(true);
|
txtLimitCount.text = Language.Get("CycleHall05", UIHelper.AppendColor(buyCnt >= totalCnt ? TextColType.Red : TextColType.Green, Mathf.Max(0, totalCnt - buyCnt).ToString(), true));
|
if (orgPrice != null)
|
{
|
orgPrice.SetActive(PlayerDatas.Instance.baseData.IsActive90Off);
|
orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.m_PayRMBNum));
|
}
|
btnBuy.SetListener(() =>
|
{
|
if (PlayerDatas.Instance.baseData.VIPLv < config.VipLevel)
|
{
|
SysNotifyMgr.Instance.ShowTip("VIPNotEnough", config.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);
|
}
|
});
|
|
txtTitle.text = config.Title;
|
if (vipModel.TryGetRechargeItem(ctgId, out var list) && list != null)
|
{
|
for (int i = 0; i < giftItemCells.Count; i++)
|
{
|
var itemBaisc = giftItemCells[i];
|
if (i < list.Count)
|
{
|
var itemInfo = list[i];
|
itemBaisc.SetActive(true);
|
ItemCellModel cellModel = new ItemCellModel((int)itemInfo.id, false, (ulong)itemInfo.count);
|
itemBaisc.Init(cellModel);
|
itemBaisc.button.AddListener(() =>
|
{
|
ItemTipUtility.Show((int)itemInfo.id);
|
});
|
}
|
else
|
{
|
itemBaisc.SetActive(false);
|
}
|
}
|
}
|
}
|
|
public Int2 GetBuyCntInfo(int ctgID)
|
{
|
VipModel.RechargeCount rechargeCount;
|
vipModel.TryGetRechargeCount(ctgID, out rechargeCount);
|
|
var ctgConfig = CTGConfig.Get(ctgID);
|
int buyCnt = 0;
|
int totalCnt = 0;
|
|
buyCnt = rechargeCount.totalCount;
|
totalCnt = ctgConfig.TotalBuyCount;
|
|
return new Int2(buyCnt, totalCnt);
|
}
|
|
private void DisplayStore(StoreConfig storeConfig)
|
{
|
bool isFree = storeConfig.MoneyNumber == 0;
|
txtTitle.text = isFree ? Language.Get("StoreName_free") : Language.Get("StoreName_money");
|
//saleObj.SetActive(false);
|
int remainNum;
|
storeModel.TryGetIsSellOut(storeConfig, out remainNum);
|
orgPrice.SetActive(false);
|
txtLimitCount.SetActive(!isFree);
|
txtLimitCount.text = Language.Get("CycleHall06", UIHelper.AppendColor(remainNum == 0 ? TextColType.Red : TextColType.Green, Mathf.Max(0, remainNum).ToString(), true));
|
|
imgRed.SetActive(isFree);
|
btnBuy.SetActive(remainNum > 0);
|
btnBuy.SetListener(() =>
|
{
|
storeModel.SendBuyShopItemWithPopCheck(storeConfig, 1, (int)BuyStoreItemCheckType.ActGift);
|
});
|
imgBuy.SetActive(remainNum <= 0);
|
|
txtBuy.text = isFree ? Language.Get("AloneFree") : Language.Get("ItemOverdue105", UIHelper.GetMoneyFormat(storeConfig.MoneyNumber));
|
|
var items = storeModel.GetShopItemlistByIndex(storeConfig);
|
for (int i = 0; i < giftItemCells.Count; i++)
|
{
|
var itemBaisc = giftItemCells[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);
|
}
|
}
|
}
|
}
|
}
|