using UnityEngine; using TMPro; using IVDataFormat; public class IVPpItemUse : MonoBehaviour { protected TextMeshProUGUI txtTitle; protected TextMeshProUGUI txtBtnYes; protected TextMeshProUGUI txtBtnNo; protected GoodsItem goodsItemUse; protected TextMeshProUGUI txtUse; protected TextMeshProUGUI txtCount; protected System.Action actionBtnAdd; protected System.Action actionBtnSub; protected System.Action actionBtnMin; protected System.Action actionBtnMax; protected System.Action actionBtnYes; protected System.Action actionBtnNo; public bool IsOpen() { return gameObject.activeSelf; } public virtual void Init() { txtTitle = transform.Find("txtTitle").GetComponent(); txtBtnYes = transform.Find("btnYes").Find("txt").GetComponent(); txtBtnNo = transform.Find("btnNo").Find("txt").GetComponent(); goodsItemUse = transform.Find("GoodsItemUse").GetComponent(); txtUse = transform.Find("txtUse").GetComponent(); txtCount = transform.Find("txtCount").GetComponent(); } public void Open(nGoods goodsuse, System.Action actionsub, System.Action actionadd, System.Action actionmin, System.Action actionmax, System.Action actionyes, System.Action actionno = null, string strtitle = null, string stryes = null, string strno = null) { if (string.IsNullOrEmpty(strtitle)) strtitle = LocalizationText.GetText(Global.STR_USE); if (string.IsNullOrEmpty(stryes)) stryes = LocalizationText.GetText(Global.STR_USE); if (string.IsNullOrEmpty(strno)) strno = LocalizationText.GetText(Global.STR_CANCEL); txtTitle.text = strtitle; txtBtnYes.text = stryes; txtBtnNo.text = strno; goodsItemUse.SetData(goodsuse); actionBtnSub = actionsub; actionBtnAdd = actionadd; actionBtnMin = actionmin; actionBtnMax = actionmax; actionBtnYes = actionyes; actionBtnNo = actionno; gameObject.SetActive(true); } public void SetCount(int icount, int iuse) { txtCount.text = icount.ToString(); txtUse.text = iuse.ToString("-0"); } public void BtnSubPressed() { SoundMgr.PlaySfx(SoundName.BtnPress); if (actionBtnSub != null) actionBtnSub.Invoke(); } public void BtnAddPressed() { SoundMgr.PlaySfx(SoundName.BtnPress); if (actionBtnAdd != null) actionBtnAdd.Invoke(); } public void BtnMinPressed() { SoundMgr.PlaySfx(SoundName.BtnPress); if (actionBtnMin != null) actionBtnMin.Invoke(); } public void BtnMaxPressed() { SoundMgr.PlaySfx(SoundName.BtnPress); if (actionBtnMax != null) actionBtnMax.Invoke(); } 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(); } }