using UnityEngine; using TMPro; using IVDataFormat; using UnityEngine.UI; public class IVPpItemBuy : MonoBehaviour { protected Image imgBtnYes; protected Image imgBuyIcon; protected TextMeshProUGUI txtTitle; protected TextMeshProUGUI txtBtnYes; protected TextMeshProUGUI txtBtnNo; protected TextMeshProUGUI txtName; protected GoodsItem goodsItem; protected System.Action actionBtnYes; protected System.Action actionBtnNo; public bool IsOpen() { return gameObject.activeSelf; } public virtual void Init() { imgBtnYes = transform.Find("btnYes").GetComponent(); imgBuyIcon = imgBtnYes.transform.Find("icon").GetComponent(); txtTitle = transform.Find("txtTitle").GetComponent(); txtBtnYes = imgBtnYes.transform.Find("txt").GetComponent(); txtBtnNo = transform.Find("btnNo").Find("txt").GetComponent(); txtName = transform.Find("txtName").GetComponent(); goodsItem = transform.Find("GoodsItem").GetComponent(); } public void Open(nGoods goods, int ibuytype, int ibuyid, int iprice, System.Action actionyes, System.Action actionno = null, string strtitle = null, string strno = null, Sprite sprBtn=null) { if (string.IsNullOrEmpty(strtitle)) strtitle = LocalizationText.GetText(Global.STR_USE); if (string.IsNullOrEmpty(strno)) strno = LocalizationText.GetText(Global.STR_CANCEL); txtTitle.text = strtitle; txtBtnNo.text = strno; txtBtnYes.text = FormatString.TextInt(iprice); txtName.text = FormatString.GetGoodsName(goods.propertyType, goods.propertyId); //if (ibuyid == cGoods.CMileage) // imgBtnYes.color = Global.CLR_BtnMileage; //else // imgBtnYes.color = Global.CLR_BtnDia; if(sprBtn != null) { imgBtnYes.sprite = sprBtn; } imgBuyIcon.sprite = AddressableMgr.GetIcon(ibuytype, ibuyid); txtBtnYes.color = Global.CLR_White; goodsItem.SetData(goods); actionBtnYes = actionyes; actionBtnNo = actionno; gameObject.SetActive(true); } public void BtnYesPressed() { SoundMgr.PlaySfx(SoundName.BtnPress); GameUIMgr.SOnClosePopup(); gameObject.SetActive(false); if (actionBtnYes != null) actionBtnYes.Invoke(); } public void BtnNoPressed() { SoundMgr.PlaySfx(SoundName.BtnPress); GameUIMgr.SOnClosePopup(); gameObject.SetActive(false); if (actionBtnNo != null) actionBtnNo.Invoke(); } }