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.
 
 
 
 
 
 

128 lines
4.0 KiB

using UnityEngine;
using TMPro;
using IVDataFormat;
using UnityEngine.UI;
public class IVPpRarityCheck : MonoBehaviour
{
protected TextMeshProUGUI txtTitle;
protected TextMeshProUGUI txtDesc;
protected TextMeshProUGUI txtBtnYes;
protected TextMeshProUGUI txtBtnNo;
protected GoodsItem goodsItem;
protected Toggle[] tglRarities;
protected ButtonIV btnYes;
protected System.Action actionToggle;
protected System.Action actionBtnYes;
protected System.Action actionBtnNo;
public bool IsOpen()
{
return gameObject.activeSelf;
}
public virtual void Init()
{
btnYes = transform.Find("btnYes").GetComponent<ButtonIV>();
txtTitle = transform.Find("txtTitle").GetComponent<TextMeshProUGUI>();
txtDesc = transform.Find("txtDesc").GetComponent<TextMeshProUGUI>();
txtBtnYes = btnYes.transform.Find("txt").GetComponent<TextMeshProUGUI>();
txtBtnNo = transform.Find("btnNo").Find("txt").GetComponent<TextMeshProUGUI>();
goodsItem = transform.Find("GoodsItem").GetComponent<GoodsItem>();
tglRarities = transform.Find("tgls").GetComponentsInChildren<Toggle>(true);
}
public void Open(nGoods goodsuse, fRangeRarity rarities, System.Action actiontoggle, System.Action actionyes, System.Action actionno = null,
string strtitle = null, string strdesc = 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;
txtDesc.text = strdesc;
txtBtnYes.text = stryes;
txtBtnNo.text = strno;
goodsItem.SetData(goodsuse);
tglRarities[0].SetIsOnWithoutNotify(rarities.HasFlag(fRangeRarity.Normal));
tglRarities[1].SetIsOnWithoutNotify(rarities.HasFlag(fRangeRarity.Rare));
tglRarities[2].SetIsOnWithoutNotify(rarities.HasFlag(fRangeRarity.Epic));
tglRarities[3].SetIsOnWithoutNotify(rarities.HasFlag(fRangeRarity.Unique));
tglRarities[4].SetIsOnWithoutNotify(rarities.HasFlag(fRangeRarity.Hero));
tglRarities[5].SetIsOnWithoutNotify(rarities.HasFlag(fRangeRarity.Legend));
tglRarities[6].SetIsOnWithoutNotify(rarities.HasFlag(fRangeRarity.Myth));
actionToggle = actiontoggle;
actionBtnYes = actionyes;
actionBtnNo = actionno;
gameObject.SetActive(true);
}
public void SetBtnYes(bool binteractable)
{
btnYes.interactable = binteractable;
}
public fRangeRarity GetPopupRarityCheck()
{
fRangeRarity rarities = fRangeRarity.None;
if (tglRarities[0].isOn)
rarities |= fRangeRarity.Normal;
if (tglRarities[1].isOn)
rarities |= fRangeRarity.Rare;
if (tglRarities[2].isOn)
rarities |= fRangeRarity.Epic;
if (tglRarities[3].isOn)
rarities |= fRangeRarity.Unique;
if (tglRarities[4].isOn)
rarities |= fRangeRarity.Hero;
if (tglRarities[5].isOn)
rarities |= fRangeRarity.Legend;
if (tglRarities[6].isOn)
rarities |= fRangeRarity.Myth;
return rarities;
}
public void ToggleCheck()
{
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
if (actionToggle != null)
actionToggle.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();
}
}