You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.0 KiB
92 lines
3.0 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using IVDataFormat;
|
|
|
|
public class EscrExchangePanel : MonoBehaviour
|
|
{
|
|
TextMeshProUGUI txtTitle;
|
|
TextMeshProUGUI txtBuyCount;
|
|
TextMeshProUGUI txtGoodsCount;
|
|
TextMeshProUGUI txtPrice;
|
|
ButtonIV btnBuy;
|
|
Image imgGoods;
|
|
Image imgSpendPrice;
|
|
GameObject soldOut;
|
|
TextMeshProUGUI txtSoldOut;
|
|
|
|
int itemID;
|
|
int[] goodsId;
|
|
|
|
nRewardLimit Goods;
|
|
|
|
public void Init()
|
|
{
|
|
imgGoods = transform.Find("explainImg").GetComponent<Image>();
|
|
txtTitle = transform.Find("txtGoodTitle").GetComponent<TextMeshProUGUI>();
|
|
txtBuyCount = transform.Find("txtChangeCount").GetComponent<TextMeshProUGUI>();
|
|
txtGoodsCount = transform.Find("txtCount").GetComponent<TextMeshProUGUI>();
|
|
btnBuy = transform.Find("btnBuy").GetComponent<ButtonIV>();
|
|
txtPrice = btnBuy.transform.Find("txtCount").GetComponent<TextMeshProUGUI>();
|
|
imgSpendPrice = btnBuy.transform.Find("imgGoods").GetComponent<Image>();
|
|
soldOut = transform.Find("soldOut").gameObject;
|
|
txtSoldOut = soldOut.transform.Find("txtGoodTitle").GetComponent<TextMeshProUGUI>();
|
|
}
|
|
|
|
public void SetData(int itemid, IVDataFormat.nRewardLimit goods)
|
|
{
|
|
Init();
|
|
|
|
itemID = itemid;
|
|
Goods = goods;
|
|
imgGoods.sprite = AddressableMgr.GetIcon(goods.rewardType, goods.rewardId);
|
|
txtTitle.text = LocalizationText.GetText(FormatString.CombineAll("currency", goods.rewardId));
|
|
if (goods.rewardId > 300)
|
|
{
|
|
txtTitle.text = LocalizationText.GetText(FormatString.CombineAll("item", goods.rewardId));
|
|
}
|
|
txtGoodsCount.text = goods.rewardCount.ToString();
|
|
txtPrice.text = goods.price.ToString();
|
|
|
|
int nowLeft = 0;
|
|
for(int i=0;i< DataHandler.GetPlayEventTrade().rewards.Length; i++)
|
|
{
|
|
if(itemid == DataHandler.GetPlayEventTrade().rewards[i].sid - 1)
|
|
{
|
|
nowLeft = goods.limitCnt - DataHandler.GetPlayEventTrade().rewards[i].buyCnt;
|
|
}
|
|
}
|
|
txtBuyCount.text = FormatString.StringFormat(LocalizationText.GetText("event_exchange_count"), Mathf.Max(nowLeft, 0), goods.limitCnt);
|
|
|
|
if(nowLeft <= 0)
|
|
{
|
|
btnBuy.interactable = false;
|
|
soldOut.SetActive(true);
|
|
txtSoldOut.text = LocalizationText.GetText("event_shop_soldout");
|
|
txtPrice.color = new Color(1f, 1f, 1f);
|
|
}
|
|
else if (goods.price > DataHandler.GetPlayEventTrade().item)
|
|
{
|
|
btnBuy.interactable = false;
|
|
txtPrice.color = new Color(255f / 255f, 114f / 255f, 114f / 255f, 1f);
|
|
}
|
|
else
|
|
{
|
|
btnBuy.interactable = true;
|
|
soldOut.SetActive(false);
|
|
txtPrice.color = new Color(1f, 1f, 1f);
|
|
}
|
|
|
|
}
|
|
|
|
public void PressButton()
|
|
{
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
|
|
EventMgr.TradeRewardSetting(itemID,Goods);
|
|
}
|
|
|
|
|
|
}
|