using UnityEngine;
|
using UnityEngine.UI;
|
using System.Collections;
|
using System;
|
|
namespace vnxbqy.UI
|
{
|
public class CrossServerOneVsOneHonorShopCell : MonoBehaviour
|
{
|
[SerializeField] ItemCell itemCell;
|
[SerializeField] Text nameText;
|
[SerializeField] Image moneyIcon;
|
[SerializeField] Text moneyCntText;
|
[SerializeField] Text vipText;
|
[SerializeField] Image stateImg;
|
[SerializeField] Image sellImg;
|
[SerializeField] Button shopCellBtn;
|
[SerializeField] Text refreshTimeText;
|
[SerializeField] RedpointBehaviour redpointBeh;
|
|
StoreModel m_storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
CrossServerOneVsOneModel crossServerModel { get { return ModelCenter.Instance.GetModel<CrossServerOneVsOneModel>(); } }
|
|
public void SetDisplay(StoreConfig storeConfig, int recommendGoodId)
|
{
|
ItemConfig itemConfig = ItemConfig.Get(m_storeModel.GetReplaceId(storeConfig.ID, storeConfig.ItemID));
|
if (itemConfig == null) return;
|
|
Redpoint redpoint = crossServerModel.GetRedpointById(storeConfig.ID);
|
if (redpoint != null)
|
{
|
redpointBeh.redpointId = redpoint.id;
|
}
|
ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, false, 0, "", PackType.Deleted, true);
|
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);
|
if (!string.IsNullOrEmpty(storeConfig.SalesStatus))
|
{
|
stateImg.SetActive(true);
|
stateImg.SetSprite(storeConfig.SalesStatus);
|
stateImg.SetNativeSize();
|
}
|
else
|
{
|
stateImg.SetActive(false);
|
}
|
|
int canBuyCnt = 0;
|
int addBuyCnt = 0;
|
int curVipIndex = -1;
|
int nextVipIndex = -1;
|
bool isVipBuy = BuyItemController.Instance.CheckIsVipBuy(storeConfig, out curVipIndex, out nextVipIndex);
|
bool isLimitBuy = BuyItemController.Instance.CheckIsLimitBuyCnt(storeConfig, out canBuyCnt, out addBuyCnt);
|
bool isShowBuyPrice = true;
|
if (isVipBuy)
|
{
|
if (curVipIndex == -1 && nextVipIndex != -1)
|
{
|
vipText.text = Language.Get("StoreWin101", storeConfig.VIPLV[nextVipIndex]);
|
nameText.color = UIHelper.GetUIColor(TextColType.Red, true);
|
vipText.color = UIHelper.GetUIColor(TextColType.Red, true);
|
isShowBuyPrice = false;
|
}
|
}
|
|
vipText.SetActive(!isShowBuyPrice);
|
refreshTimeText.SetActive(false);
|
moneyIcon.SetActive(isShowBuyPrice);
|
if (canBuyCnt > 0)
|
{
|
itemCell.countText.SetActive(true);
|
BuyShopItemLimit shopItemLimit = m_storeModel.GetBuyShopLimit((uint)storeConfig.ID);
|
int remainNum = canBuyCnt;
|
if (shopItemLimit != null)
|
{
|
remainNum = canBuyCnt - shopItemLimit.BuyCnt;
|
}
|
|
if (remainNum > 0)
|
{
|
itemCell.countText.text = StringUtility.Contact(remainNum.ToString(),
|
"/" + canBuyCnt.ToString());
|
}
|
else
|
{
|
stateImg.SetActive(false);
|
sellImg.SetActive(true);
|
itemCell.countText.text = StringUtility.Contact(UIHelper.AppendColor(TextColType.Red, remainNum.ToString()),
|
"/" + canBuyCnt.ToString());
|
string refreshDes = m_storeModel.GetStoreRefreshTimeByType(storeConfig.RefreshType);
|
if (!string.IsNullOrEmpty(refreshDes))
|
{
|
refreshTimeText.SetActive(true);
|
refreshTimeText.text = refreshDes;
|
}
|
}
|
}
|
else
|
{
|
itemCell.countText.SetActive(false);
|
}
|
|
if (storeConfig.ID == recommendGoodId)
|
{
|
DisplayRecommendEffect();
|
}
|
else
|
{
|
RecycleRecommendEffect();
|
}
|
|
shopCellBtn.RemoveAllListeners();
|
shopCellBtn.AddListener(() =>
|
{
|
m_storeModel.OnClickShopCell(storeConfig);
|
crossServerModel.ClearRedpoint(storeConfig.ID);
|
});
|
}
|
|
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;
|
}
|
}
|
|
}
|
}
|