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.
95 lines
2.7 KiB
95 lines
2.7 KiB
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<Image>();
|
|
imgBuyIcon = imgBtnYes.transform.Find("icon").GetComponent<Image>();
|
|
|
|
txtTitle = transform.Find("txtTitle").GetComponent<TextMeshProUGUI>();
|
|
txtBtnYes = imgBtnYes.transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
txtBtnNo = transform.Find("btnNo").Find("txt").GetComponent<TextMeshProUGUI>();
|
|
txtName = transform.Find("txtName").GetComponent<TextMeshProUGUI>();
|
|
|
|
goodsItem = transform.Find("GoodsItem").GetComponent<GoodsItem>();
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
}
|
|
|
|
}
|