using UnityEngine; using UnityEngine.UI; using TMPro; using IVDataFormat; public class EfcAddItem : MonoBehaviour { [SerializeField] private int iType; private Toggle tglLock; private GameObject goOpened; private GameObject goClosed; private Image imgUnlock; private Image imgLock; private TextMeshProUGUI txtNumber; private TextMeshProUGUI txtAbility; private bool bEmpty = true; public void Init() { Transform trf = transform; tglLock = GetComponent(); goOpened = trf.Find("open").gameObject; goClosed = trf.Find("close").gameObject; imgUnlock = goOpened.transform.Find("imgUnlock").GetComponent(); imgLock = goOpened.transform.Find("imgLock").GetComponent(); txtNumber = goOpened.transform.Find("txtNumber").GetComponent(); txtAbility = goOpened.transform.Find("txtAbility").GetComponent(); } public void SetCondition(int iawaken) { if (GuardianMgr.GetIsOpenAwaken()) { goClosed.transform.GetChild(0).GetComponent().text = FormatString.StringFormat(LocalizationText.GetText("guardian_awaken_lock"), iawaken.ToString()); } else { goClosed.transform.GetChild(0).GetComponent().text = FormatString.StringFormat(LocalizationText.GetText("all_awakenopen"), iawaken.ToString()); } } public void SetCondition(string strcond) { goClosed.transform.GetChild(0).GetComponent().text = strcond; } // 효과 변경 가능 상태. 해금되었으며 잠겨있지 않음. public bool IsChangable() { return gameObject.activeSelf && goOpened.activeSelf && (bEmpty || !tglLock.isOn); } // 무기/펫 전환. public void SetChangeOpen(bool bopen) { tglLock.interactable = bopen; goOpened.SetActive(bopen); goClosed.SetActive(!bopen); imgLock.gameObject.SetActive(!bopen); imgUnlock.gameObject.SetActive(bopen); tglLock.SetIsOnWithoutNotify(false); } // 해금 상태 설정. public void SetOpen(bool bopen) { goOpened.SetActive(bopen); goClosed.SetActive(!bopen); } // 효과 설정. public void SetEffect(int key) { if (key < 0) { bEmpty = true; Color clr = Global.CLR_White; clr.a = 0f; imgLock.color = clr; imgUnlock.color = clr; txtAbility.text = LocalizationText.GetText("efc0"); txtAbility.color = Global.CLR_RarityBack[0]; txtNumber.color = txtAbility.color; tglLock.SetIsOnWithoutNotify(false); return; } bEmpty = false; dExtraAbility ability = DataHandler.GetExtraAbility(key); imgLock.color = Global.CLR_White; imgUnlock.color = Global.CLR_White; txtAbility.text = FormatString.TextEffectTitleValue(ability.abilityType, ability.abilityValue); txtAbility.color = Global.CLR_RarityBack[ability.rarity]; txtNumber.color = txtAbility.color; } // 효과 설정. public void SetEffect(eEffectType abilitytype, long abilityvalue) { if (abilitytype == eEffectType.None) { bEmpty = true; Color clr = Global.CLR_White; clr.a = 0f; imgLock.color = clr; imgUnlock.color = clr; txtAbility.text = LocalizationText.GetText("efc0"); txtAbility.color = Global.CLR_RarityBack[0]; txtNumber.color = txtAbility.color; tglLock.SetIsOnWithoutNotify(false); return; } bEmpty = false; imgLock.color = Global.CLR_White; imgUnlock.color = Global.CLR_White; txtAbility.text = FormatString.TextEffectTitleValue(abilitytype, abilityvalue); txtAbility.color = Global.CLR_White; txtNumber.color = txtAbility.color; } public void ToggleLock(bool btoggle) { SoundMgr.Instance.PlaySfx(SoundName.BtnPress); imgLock.gameObject.SetActive(btoggle); imgUnlock.gameObject.SetActive(!btoggle); if (iType == cGoods.TBag) BagMgr.SSetEfcAddCost(); else if (iType == cGoods.TPet) PetMgr.SSetEfcAddCost(); else GuardianMgr.SSetEfcAddCost(); } }