143 lines
4.7 KiB
C#
143 lines
4.7 KiB
C#
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class PCJobUI_OpenCondition : MonoBehaviour
|
|
{
|
|
public PCJobDetailUI m_PCJobDetailUI;
|
|
public TextMeshProUGUI[] texts; // 0 전직 조건, 1 버튼명, 2 전직 비용
|
|
public GameObject[] gos; // 0 전직 전, 1 전직 후, 2 전직 비용
|
|
|
|
ObscuredInt m_ClassId;
|
|
ClassOpenConditionTableData m_Data;
|
|
|
|
public void Set(int classid)
|
|
{
|
|
m_ClassId = classid;
|
|
m_ClassId.RandomizeCryptoKey();
|
|
Set_UI();
|
|
}
|
|
|
|
void Set_UI()
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
var moneyid = table_GlobalValue.Ins.Get_Int("n_JobMaterialID");
|
|
texts[2].text = $"{sdata.Get_ItemAmount(moneyid)}/1";
|
|
|
|
m_Data = table_classopencondition.Ins.Get_Data_orNull(m_ClassId);
|
|
string condition = table_localtext.Ins.Get_Text(243);
|
|
if (m_Data.n_RequireAbility > 0)
|
|
{
|
|
var abData = table_abilityconfig.Ins.Get_Data_orNull(m_Data.n_RequireAbility);
|
|
condition = DSUtil.Format(242, abData.Get_Name());
|
|
}
|
|
if (m_Data.e_RequireAwakenType1 != eStat.None)
|
|
condition += $"\n각성 {m_Data.e_RequireAwakenType1}, {m_Data.n_RequireAwakenStep1} 필요";
|
|
if (m_Data.e_RequireAwakenType2 != eStat.None)
|
|
condition += $"\n각성 {m_Data.e_RequireAwakenType2}, {m_Data.n_RequireAwakenStep2} 필요";
|
|
texts[0].text = condition;
|
|
if (sdata.IsObtainItem(m_ClassId))
|
|
{ // 전직 함
|
|
texts[1].text = sdata.Get_EqiupmentEquip(eItem.PC) == m_ClassId ?
|
|
table_localtext.Ins.Get_Text(244) : table_localtext.Ins.Get_Text(245);
|
|
gos[0].SetActive(false);
|
|
gos[1].SetActive(true);
|
|
gos[2].SetActive(false);
|
|
}
|
|
else
|
|
{ // 전직 안함
|
|
texts[1].text = table_localtext.Ins.Get_Text(246);
|
|
gos[0].SetActive(true);
|
|
gos[1].SetActive(false);
|
|
gos[2].SetActive(true);
|
|
}
|
|
}
|
|
|
|
bool CanJobBuy(bool showtoast)
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
if (sdata.PC.IsObtainPC(m_ClassId)) return false;
|
|
|
|
// linkedId1 확인
|
|
if (m_Data.n_linkedClass1 > 0 && !sdata.IsObtainItem(m_Data.n_linkedClass1))
|
|
{
|
|
if (showtoast) ToastUI.Ins.Set(254);
|
|
return false;
|
|
}
|
|
|
|
// linkedId2 확인
|
|
if (m_Data.n_linkedClass2 > 0 && !sdata.IsObtainItem(m_Data.n_linkedClass2))
|
|
{
|
|
if (showtoast) ToastUI.Ins.Set(254);
|
|
return false;
|
|
}
|
|
|
|
// 특성 확인
|
|
if (m_Data.n_RequireAbility > 0)
|
|
{
|
|
if (sdata.Get_AbilityLv(m_Data.n_RequireAbility) < 1)
|
|
{
|
|
if (showtoast)
|
|
ToastUI.Ins.Set(242, table_itemlist.Ins.Get_ItemName(m_Data.n_RequireAbility));
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// 각성 확인 1
|
|
if (m_Data.e_RequireAwakenType1 != eStat.None && sdata.Get_AwakenLv(m_Data.e_RequireAwakenType1) < m_Data.n_RequireAwakenStep1)
|
|
{
|
|
if (showtoast) ToastUI.Ins.Set(230);
|
|
return false;
|
|
}
|
|
|
|
// 각성 확인 2
|
|
if (m_Data.e_RequireAwakenType2 != eStat.None && sdata.Get_AwakenLv(m_Data.e_RequireAwakenType2) < m_Data.n_RequireAwakenStep2)
|
|
{
|
|
if (showtoast) ToastUI.Ins.Set(230);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public void OnClick_JobChange()
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
|
|
if (sdata.IsObtainItem(m_ClassId))
|
|
{ // 착용 여부
|
|
if (sdata.Get_EqiupmentEquip(eItem.PC) != m_ClassId)
|
|
{ // 착용하기
|
|
ServerInfo.Ins.Save_PC_EquipJob(m_ClassId, () =>
|
|
{
|
|
sdata.Equip.Set_Equip(eItem.PC, m_ClassId);
|
|
Set_UI();
|
|
PCJobUI.Ins.Set();
|
|
MyValue.Get_ActorStatInfoorNull(eRole.PC);
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{ // 전직
|
|
if (CanJobBuy(true))
|
|
{
|
|
var moneyid = table_GlobalValue.Ins.Get_Int("n_JobMaterialID");
|
|
if (sdata.Check_ItemAmount(moneyid, m_Data.n_NeedGoodsCount))
|
|
{
|
|
ServerInfo.Ins.Save_PC_BuyJob(m_Data.n_ClassID, () =>
|
|
{
|
|
sdata.Use_Item(moneyid, m_Data.n_NeedGoodsCount);
|
|
sdata.PC.Add_PC(m_ClassId);
|
|
Set_UI();
|
|
MyValue.Get_ActorStatInfoorNull(eRole.PC);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnClick_StatInfo()
|
|
{
|
|
m_PCJobDetailUI.Set();
|
|
}
|
|
} |