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.
 
 
 
 
 
 

123 lines
3.4 KiB

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<TextMeshProUGUI>();
txtBtnYes = transform.Find("btnYes").Find("txt").GetComponent<TextMeshProUGUI>();
txtBtnNo = transform.Find("btnNo").Find("txt").GetComponent<TextMeshProUGUI>();
goodsItemUse = transform.Find("GoodsItemUse").GetComponent<GoodsItem>();
txtUse = transform.Find("txtUse").GetComponent<TextMeshProUGUI>();
txtCount = transform.Find("txtCount").GetComponent<TextMeshProUGUI>();
}
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.Instance.PlaySfx(SoundName.BtnPress);
if (actionBtnSub != null)
actionBtnSub.Invoke();
}
public void BtnAddPressed()
{
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
if (actionBtnAdd != null)
actionBtnAdd.Invoke();
}
public void BtnMinPressed()
{
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
if (actionBtnMin != null)
actionBtnMin.Invoke();
}
public void BtnMaxPressed()
{
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
if (actionBtnMax != null)
actionBtnMax.Invoke();
}
public void BtnYesPressed()
{
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
GameUIMgr.SOnClosePopup();
gameObject.SetActive(false);
if (actionBtnYes != null)
actionBtnYes.Invoke();
}
public void BtnNoPressed()
{
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
GameUIMgr.SOnClosePopup();
gameObject.SetActive(false);
if (actionBtnNo != null)
actionBtnNo.Invoke();
}
}