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.
202 lines
5.2 KiB
202 lines
5.2 KiB
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public class AwakenEffectItem : MonoBehaviour
|
|
{
|
|
int index;
|
|
|
|
GameObject awakenUnlock;
|
|
GameObject awakenLock;
|
|
Toggle abilityLock;
|
|
TextMeshProUGUI txtAbility;
|
|
TextMeshProUGUI txtNumber;
|
|
GameObject btnLock;
|
|
[SerializeField]
|
|
Image imgUnlock,imgLock;
|
|
|
|
TextMeshProUGUI txtUnlockCondition;
|
|
|
|
bool isAbilityLock;
|
|
bool isUnlock;
|
|
|
|
public bool IsUnlock()
|
|
{
|
|
return isUnlock;
|
|
}
|
|
|
|
public void SetIsUnlock(bool isunlock)
|
|
{
|
|
abilityLock.isOn = !isunlock;
|
|
}
|
|
|
|
public void UnlockAbilitySlot()
|
|
{
|
|
isUnlock = true;
|
|
}
|
|
|
|
public bool GetIsAbilityLock()
|
|
{
|
|
return isAbilityLock;
|
|
}
|
|
|
|
public void SetIndex(int idx)
|
|
{
|
|
index = idx;
|
|
|
|
awakenUnlock = transform.Find("AwakenUnlock").gameObject;
|
|
awakenLock = transform.Find("AwakenLock").gameObject;
|
|
abilityLock = awakenUnlock.transform.Find("btnLock").GetComponent<Toggle>();
|
|
txtAbility = awakenUnlock.transform.Find("txtEffect").GetComponent<TextMeshProUGUI>();
|
|
txtNumber = awakenUnlock.transform.Find("txtNumber").GetComponent<TextMeshProUGUI>();
|
|
txtUnlockCondition = awakenLock.transform.Find("txtUnlockCondition").GetComponent<TextMeshProUGUI>();
|
|
btnLock = awakenUnlock.transform.Find("btnLock").gameObject;
|
|
|
|
txtAbility.text = "";
|
|
|
|
isUnlock = index < DataHandler.PlayAwaken.awaken;
|
|
isAbilityLock = false;
|
|
|
|
if (!isUnlock)
|
|
{
|
|
awakenUnlock.SetActive(false);
|
|
awakenLock.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
awakenUnlock.SetActive(true);
|
|
awakenLock.SetActive(false);
|
|
|
|
if (DataHandler.PlayAwaken.extras[DataHandler.PlayAwaken.usePreset][index] < 0)
|
|
{
|
|
abilityLock.SetIsOnWithoutNotify(true);
|
|
}
|
|
|
|
ShowAbility();
|
|
}
|
|
|
|
txtUnlockCondition.text = FormatString.StringFormat(LocalizationText.GetText("awaken_unlock_slot_condition"), index + 1);
|
|
|
|
if (abilityLock.isOn == true)
|
|
{
|
|
//잠금
|
|
abilityLock.isOn = true;
|
|
isAbilityLock = true;
|
|
}
|
|
}
|
|
|
|
public void Localize()
|
|
{
|
|
txtUnlockCondition.text = FormatString.StringFormat(LocalizationText.GetText("awaken_unlock_slot_condition"), index + 1);
|
|
ShowAbility();
|
|
}
|
|
|
|
public void AwakenLockButton()
|
|
{
|
|
bool isToggled = abilityLock.isOn;
|
|
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
|
|
if (EnhanceMgr.Instance.GetAutoReroll())
|
|
{
|
|
if (isToggled == true)
|
|
{
|
|
//잠금
|
|
abilityLock.SetIsOnWithoutNotify(false);
|
|
}
|
|
else
|
|
{
|
|
//열림
|
|
abilityLock.SetIsOnWithoutNotify(true);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
imgUnlock.gameObject.SetActive(!isToggled);
|
|
imgLock.gameObject.SetActive(isToggled);
|
|
if (isToggled == true)
|
|
{
|
|
//잠금
|
|
abilityLock.isOn = true;
|
|
isAbilityLock = true;
|
|
EnhanceMgr.Instance.RecalculateRerollCost();
|
|
DataHandler.PlayAwaken.awakenUnlock[DataHandler.PlayAwaken.usePreset][index] = false;
|
|
DataHandler.PlayAwaken.Save();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
//열림
|
|
abilityLock.isOn = false;
|
|
isAbilityLock = false;
|
|
EnhanceMgr.Instance.RecalculateRerollCost();
|
|
DataHandler.PlayAwaken.awakenUnlock[DataHandler.PlayAwaken.usePreset][index] = true;
|
|
DataHandler.PlayAwaken.Save();
|
|
return;
|
|
}
|
|
}
|
|
|
|
public void RefreshView()
|
|
{
|
|
ShowAbility();
|
|
}
|
|
|
|
public void UnlockSlot()
|
|
{
|
|
if (!isUnlock)
|
|
{
|
|
isUnlock = true;
|
|
|
|
awakenUnlock.SetActive(true);
|
|
awakenLock.SetActive(false);
|
|
ShowAbility();
|
|
}
|
|
}
|
|
|
|
public void RefreshLockState()
|
|
{
|
|
if (isUnlock) return;
|
|
|
|
bool newState = index < DataHandler.PlayAwaken.awaken;
|
|
if (newState)
|
|
{
|
|
isUnlock = true;
|
|
|
|
awakenUnlock.SetActive(true);
|
|
awakenLock.SetActive(false);
|
|
ShowAbility();
|
|
}
|
|
}
|
|
|
|
private void ShowAbility()
|
|
{
|
|
abilityLock.gameObject.SetActive(true);
|
|
|
|
if (DataHandler.PlayAwaken.extras[DataHandler.PlayAwaken.usePreset][index] < 0)
|
|
{
|
|
txtAbility.text = LocalizationText.GetText("efc0");
|
|
txtAbility.color = Global.CLR_RarityBack[0];
|
|
txtNumber.color = txtAbility.color;
|
|
abilityLock.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
IVDataFormat.dExtraAbility ability = DataHandler.GetExtraAbility(DataHandler.PlayAwaken.extras[DataHandler.PlayAwaken.usePreset][index]);
|
|
txtAbility.text = FormatString.TextEffectTitleValue(ability.abilityType, ability.abilityValue);
|
|
txtAbility.color = Global.CLR_RarityBack[ability.rarity];
|
|
txtNumber.color = txtAbility.color;
|
|
}
|
|
|
|
public void UnlockLockButton()
|
|
{
|
|
if (btnLock.activeSelf || !isUnlock)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
btnLock.SetActive(true);
|
|
}
|
|
}
|
|
}
|