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(); txtTitle = transform.Find("txtGoodTitle").GetComponent(); txtBuyCount = transform.Find("txtChangeCount").GetComponent(); txtGoodsCount = transform.Find("txtCount").GetComponent(); btnBuy = transform.Find("btnBuy").GetComponent(); txtPrice = btnBuy.transform.Find("txtCount").GetComponent(); imgSpendPrice = btnBuy.transform.Find("imgGoods").GetComponent(); soldOut = transform.Find("soldOut").gameObject; txtSoldOut = soldOut.transform.Find("txtGoodTitle").GetComponent(); } 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); } }