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(); txtName = transform.Find("txtName").GetComponent(); txtLevel = transform.Find("txtLevel").GetComponent(); txtEfcT = transform.Find("txtEfcT").GetComponent(); txtEfcCur = transform.Find("txtEfcCur").GetComponent(); txtEfcNext = transform.Find("txtEfcNext").GetComponent(); txtProp = transform.Find("txtProp").GetComponent(); ptcFail = transform.Find("enhance_fail").GetComponent(); ptcSucc = transform.Find("enhance_succ").GetComponent(); btnEnhance = transform.Find("btnEnhance").GetComponent(); imgBtnEnhance = btnEnhance.GetComponent(); imgPriceIcon = btnEnhance.transform.Find("icon").GetComponent(); btnEnhance.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_enhance"); txtPrice = btnEnhance.transform.Find("txtPrice").GetComponent(); btnSell = transform.Find("btnSell").GetComponent(); btnSell.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_sell"); goMax = transform.Find("max").gameObject; goLock = transform.Find("txtLock").gameObject; imgLock = transform.Find("imgLock").gameObject; goLock.GetComponent().text = LocalizationText.GetText("all_nothave"); } public override void Localize() { btnEnhance.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_enhance"); btnSell.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_sell"); goLock.GetComponent().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); } }