using UnityEngine;
|
using UnityEngine.UI;
|
using System.Collections;
|
using System;
|
|
namespace vnxbqy.UI
|
{
|
public class ActStoreCell : MonoBehaviour
|
{
|
[SerializeField] ItemCell itemCell;
|
[SerializeField] Text nameText;
|
[SerializeField] Image moneyIcon;
|
[SerializeField] Text moneyCntText;
|
[SerializeField] Text buyLimitCountText;
|
[SerializeField] Text buyConditionText;
|
[SerializeField] Image sellImg;
|
[SerializeField] Button shopCellBtn;
|
|
StoreModel m_storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
BossTrialModel bossTrialModel { get { return ModelCenter.Instance.GetModel<BossTrialModel>(); } }
|
|
public void SetDisplay(StoreConfig storeConfig, int recommendGoodId)
|
{
|
ItemConfig itemConfig = ItemConfig.Get(m_storeModel.GetReplaceId(storeConfig.ID, storeConfig.ItemID));
|
if (itemConfig == null) return;
|
|
ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, false, (ulong)storeConfig.ItemCnt);
|
itemCell.button.enabled = false;
|
itemCell.Init(cellModel);
|
nameText.text = itemConfig.ItemName;
|
nameText.color = UIHelper.GetUIColor(itemConfig.ItemColor, true);
|
moneyIcon.SetIconWithMoneyType(storeConfig.MoneyType);
|
ulong shopCost = (ulong)(storeConfig.MoneyNumber);
|
moneyCntText.text = UIHelper.ReplaceLargeNum(shopCost);
|
sellImg.SetActive(false);
|
|
int canBuyCnt = 0;
|
int addBuyCnt = 0;
|
bool isLimitBuy = BuyItemController.Instance.CheckIsLimitBuyCnt(storeConfig, out canBuyCnt, out addBuyCnt);
|
|
BuyShopItemLimit shopItemLimit = m_storeModel.GetBuyShopLimit((uint)storeConfig.ID);
|
int remainNum = canBuyCnt;
|
if (shopItemLimit != null)
|
{
|
remainNum = canBuyCnt - shopItemLimit.BuyCnt;
|
}
|
|
|
//限制条件
|
bool isCanBuy = m_storeModel.rankActStore_ActType == BossTrialModel.operaType ? bossTrialModel.submitAllCount >= storeConfig.LimitValue : true;
|
buyConditionText.SetActive(!isCanBuy);
|
moneyIcon.SetActive(isCanBuy);
|
buyLimitCountText.SetActive(isCanBuy);
|
|
if (isLimitBuy)
|
{
|
buyLimitCountText.SetActive(isCanBuy);
|
buyLimitCountText.text = Language.Get("RechargeGiftActWin4", remainNum);
|
sellImg.SetActive(remainNum == 0);
|
}
|
else
|
{
|
buyLimitCountText.SetActive(false);
|
sellImg.SetActive(false);
|
}
|
|
buyConditionText.text = Language.Get("BossTrial10", storeConfig.LimitValue);
|
|
|
|
|
if (storeConfig.ID == recommendGoodId)
|
{
|
DisplayRecommendEffect();
|
}
|
else
|
{
|
RecycleRecommendEffect();
|
}
|
|
shopCellBtn.RemoveAllListeners();
|
shopCellBtn.AddListener(() =>
|
{
|
if (!isCanBuy)
|
return;
|
m_storeModel.OnClickShopCell(storeConfig);
|
});
|
}
|
|
AchievementGuideEffect recommendEffect;
|
private void DisplayRecommendEffect()
|
{
|
RecycleRecommendEffect();
|
recommendEffect = AchievementGuideEffectPool.Require(7);
|
recommendEffect.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
recommendEffect.effect.SetMask();
|
}
|
|
private void RecycleRecommendEffect()
|
{
|
if (recommendEffect != null)
|
{
|
AchievementGuideEffectPool.Recycle(recommendEffect);
|
recommendEffect = null;
|
}
|
}
|
|
}
|
}
|