using UnityEngine;
|
using UnityEngine.UI;
|
|
using System;
|
|
namespace Snxxz.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 _storeModel;
|
StoreModel m_storeModel
|
{
|
get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel<StoreModel>()); }
|
}
|
|
CrossServerOneVsOneModel crossServerModel { get { return ModelCenter.Instance.GetModel<CrossServerOneVsOneModel>(); } }
|
|
public void SetDisplay(StoreConfig storeConfig)
|
{
|
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.gameObject.SetActive(false);
|
if (!string.IsNullOrEmpty(storeConfig.SalesStatus))
|
{
|
stateImg.gameObject.SetActive(true);
|
stateImg.SetSprite(storeConfig.SalesStatus);
|
stateImg.SetNativeSize();
|
}
|
else
|
{
|
stateImg.gameObject.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.gameObject.SetActive(!isShowBuyPrice);
|
refreshTimeText.gameObject.SetActive(false);
|
moneyIcon.gameObject.SetActive(isShowBuyPrice);
|
if (canBuyCnt > 0)
|
{
|
itemCell.countText.gameObject.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.gameObject.SetActive(false);
|
sellImg.gameObject.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.gameObject.SetActive(true);
|
refreshTimeText.text = refreshDes;
|
}
|
}
|
}
|
else
|
{
|
itemCell.countText.gameObject.SetActive(false);
|
}
|
|
shopCellBtn.RemoveAllListeners();
|
shopCellBtn.AddListener(()=>
|
{
|
m_storeModel.OnClickShopCell(storeConfig);
|
crossServerModel.ClearRedpoint(storeConfig.ID);
|
});
|
|
}
|
|
private void UpdateRefreshTime()
|
{
|
if (!sellImg.gameObject.activeInHierarchy) return;
|
|
|
}
|
}
|
}
|