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.
152 lines
5.9 KiB
152 lines
5.9 KiB
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using IVDataFormat;
|
|
|
|
public class EScrTreasure : EScrCell
|
|
{
|
|
Image imgIcon;
|
|
Image imgPriceIcon;
|
|
TextMeshProUGUI txtName;
|
|
TextMeshProUGUI txtLevel;
|
|
TextMeshProUGUI txtEfcT;
|
|
TextMeshProUGUI txtEfcCur;
|
|
[SerializeField] GameObject efcArrowObj;
|
|
TextMeshProUGUI txtEfcNext;
|
|
TextMeshProUGUI txtProp;
|
|
TextMeshProUGUI txtPrice;
|
|
ButtonIV btnEnhance;
|
|
Image imgBtnEnhance;
|
|
ButtonIV btnSell;
|
|
GameObject goMax;
|
|
GameObject goLock;
|
|
GameObject imgLock;
|
|
ParticleSystem ptcSucc, ptcFail;
|
|
|
|
public override void InitCell()
|
|
{
|
|
imgIcon = transform.Find("icon").GetComponent<Image>();
|
|
|
|
txtName = transform.Find("txtName").GetComponent<TextMeshProUGUI>();
|
|
txtLevel = transform.Find("txtLevel").GetComponent<TextMeshProUGUI>();
|
|
txtEfcT = transform.Find("txtEfcT").GetComponent<TextMeshProUGUI>();
|
|
txtEfcCur = transform.Find("txtEfcCur").GetComponent<TextMeshProUGUI>();
|
|
txtEfcNext = transform.Find("txtEfcNext").GetComponent<TextMeshProUGUI>();
|
|
txtProp = transform.Find("txtProp").GetComponent<TextMeshProUGUI>();
|
|
|
|
ptcFail = transform.Find("enhance_fail").GetComponent<ParticleSystem>();
|
|
ptcSucc = transform.Find("enhance_succ").GetComponent<ParticleSystem>();
|
|
|
|
btnEnhance = transform.Find("btnEnhance").GetComponent<ButtonIV>();
|
|
imgBtnEnhance = btnEnhance.GetComponent<Image>();
|
|
imgPriceIcon = btnEnhance.transform.Find("icon").GetComponent<Image>();
|
|
btnEnhance.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_enhance");
|
|
txtPrice = btnEnhance.transform.Find("txtPrice").GetComponent<TextMeshProUGUI>();
|
|
|
|
btnSell = transform.Find("btnSell").GetComponent<ButtonIV>();
|
|
btnSell.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_sell");
|
|
|
|
goMax = transform.Find("max").gameObject;
|
|
goLock = transform.Find("txtLock").gameObject;
|
|
imgLock = transform.Find("imgLock").gameObject;
|
|
goLock.GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_nothave");
|
|
}
|
|
|
|
public override void Localize()
|
|
{
|
|
btnEnhance.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_enhance");
|
|
btnSell.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_sell");
|
|
goLock.GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_nothave");
|
|
}
|
|
|
|
public override void SetData(int itemid)
|
|
{
|
|
itemID = itemid;
|
|
|
|
dTreasure data = DataHandler.GetGearTreasure(itemid);
|
|
if (data == null)
|
|
return;
|
|
|
|
//imgBg.color = Global.CLR_RarityBack[cGoods.RRare];
|
|
imgIcon.sprite = AddressableMgr.GetBagIcon(FormatString.CombineAllString("trs", itemid.ToString()));
|
|
imgPriceIcon.sprite = imgIcon.sprite;
|
|
|
|
txtName.text = FormatString.GetGoodsName(cGoods.TBagTreasure, itemid);
|
|
txtLevel.text = FormatString.TextLv(data.level);
|
|
txtEfcT.text = FormatString.TextEffectTitle(data.abilityType);
|
|
|
|
if (data.level >= data.maxLv)
|
|
{
|
|
goLock.SetActive(false);
|
|
imgLock.SetActive(false);
|
|
btnEnhance.gameObject.SetActive(false);
|
|
goMax.SetActive(data.count <= 0);
|
|
btnSell.gameObject.SetActive(!goMax.activeSelf);
|
|
txtProp.enabled = false;
|
|
txtEfcCur.text = FormatString.TextEffectValue(data.abilityType, DataHandler.GetGearTreasureEffect(data.abilityValue, data.abilityValueInc, data.level));
|
|
efcArrowObj.SetActive(false);
|
|
txtEfcNext.enabled = false;
|
|
}
|
|
else
|
|
{
|
|
txtPrice.text = FormatString.TextCntPerRed(data.count, 1);
|
|
if (data.have)
|
|
{
|
|
goLock.SetActive(false);
|
|
imgLock.SetActive(false);
|
|
txtProp.text = FormatString.StringFormat(LocalizationText.GetText("all_succrate"), FormatString.TextIntPer0(DataHandler.GetGearTreasureProp(data.level)));
|
|
txtProp.enabled = true;
|
|
txtEfcCur.text = FormatString.TextEffectValue(data.abilityType, DataHandler.GetGearTreasureEffect(data.abilityValue, data.abilityValueInc, data.level));
|
|
txtEfcNext.text = FormatString.TextEffectValue(data.abilityType, DataHandler.GetGearTreasureEffect(data.abilityValue, data.abilityValueInc, data.level + 1));
|
|
btnEnhance.interactable = data.count > 0;
|
|
btnEnhance.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
txtProp.enabled = false;
|
|
txtEfcCur.text = FormatString.TextEffectValue(data.abilityType, 0);
|
|
txtEfcNext.text = FormatString.TextEffectValue(data.abilityType, DataHandler.GetGearTreasureEffect(data.abilityValue, data.abilityValueInc, 1));
|
|
btnEnhance.interactable = false;
|
|
goLock.SetActive(true);
|
|
imgLock.SetActive(true);
|
|
btnEnhance.gameObject.SetActive(false);
|
|
}
|
|
imgBtnEnhance.raycastTarget = btnEnhance.interactable;
|
|
efcArrowObj.SetActive(true);
|
|
txtEfcNext.enabled = true;
|
|
btnSell.gameObject.SetActive(false);
|
|
goMax.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public override void RefreshCellView()
|
|
{
|
|
base.RefreshCellView();
|
|
SetData(itemID);
|
|
}
|
|
|
|
public void EnhanceEffectSuccess()
|
|
{
|
|
ptcSucc.Play();
|
|
}
|
|
|
|
public void EnhanceEffectFail()
|
|
{
|
|
ptcFail.Play();
|
|
}
|
|
|
|
public void OnBtnEnhanceDown()
|
|
{
|
|
BagMgr.SOnBtnTreasureEnhanceDown(itemID, EnhanceEffectSuccess, EnhanceEffectFail);
|
|
}
|
|
|
|
public void OnBtnEnhanceUp()
|
|
{
|
|
BagMgr.SOnBtnTreasureEnhanceUp(itemID);
|
|
}
|
|
|
|
public void OnBtnSell()
|
|
{
|
|
BagMgr.SSellTreasure(itemID);
|
|
}
|
|
}
|