93 lines
2.6 KiB
C#
93 lines
2.6 KiB
C#
using CodeStage.AntiCheat.ObscuredTypes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using TMPro;
|
|
|
|
public class PCInfoStatMgrUI : uScrollViewMgr
|
|
{
|
|
public static PCInfoStatMgrUI Ins;
|
|
|
|
public StatResetUI m_StatResetUI;
|
|
public TextMeshProUGUI[] texts; // 0 스탯 포인트
|
|
|
|
List<eStat> list_stat = new List<eStat> { eStat.STR, eStat.DEX, eStat.INT, eStat.LUK };
|
|
Dictionary<eStat, ObscuredInt> dic_SaveStat = new Dictionary<eStat, ObscuredInt>();
|
|
bool bInit = false;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
Ins = this;
|
|
}
|
|
|
|
void Init_StatValue()
|
|
{
|
|
if (!bInit)
|
|
{
|
|
bInit = true;
|
|
for (int i = 0; i < list_stat.Count; i++)
|
|
dic_SaveStat.Add(list_stat[i], 0);
|
|
}
|
|
|
|
foreach (var key in dic_SaveStat.Keys.ToList()) // Keys 컬렉션을 리스트로 복사하여 사용
|
|
{
|
|
dic_SaveStat[key] = 0; // 값을 0으로 설정
|
|
dic_SaveStat[key].RandomizeCryptoKey(); // RandomizeCryptoKey 호출
|
|
}
|
|
}
|
|
|
|
public override void Set()
|
|
{
|
|
gameObject.SetActive(true);
|
|
Set_UI();
|
|
}
|
|
public override void Set_UI()
|
|
{
|
|
Init_StatValue();
|
|
Set_ScrollView(list_stat);
|
|
Set_Point();
|
|
}
|
|
|
|
int Get_Point() { return ServerInfo.Ins.m_ServerData.PC.Get_Point() - dic_SaveStat.Values.Select(stat => (int)stat).Sum(); }
|
|
void Set_Point() { texts[0].text = Get_Point().ToString(); }
|
|
|
|
public int Get_Stat(eStat stat) { return dic_SaveStat[stat]; }
|
|
public void Set_Stat(eStat stat, int add, Action actDetail)
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
bool success = false;
|
|
if (add > 0) success = Get_Point() >= add;
|
|
else if (add < 0) success = Get_Stat(stat) > 0;
|
|
if (success)
|
|
{
|
|
dic_SaveStat[stat] += add;
|
|
dic_SaveStat[stat].RandomizeCryptoKey();
|
|
Set_Point();
|
|
actDetail();
|
|
}
|
|
}
|
|
|
|
public void OnClick_Save()
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
foreach (var item in dic_SaveStat)
|
|
{
|
|
sdata.PC.Add_StatPoint(item.Key, item.Value);
|
|
sdata.Add_MissionCount(ePurpose.HERO_STAT_UPGRADE_ACC, 0, item.Value);
|
|
}
|
|
Set_UI();
|
|
MyValue.Get_ActorStatInfoorNull(eRole.PC);
|
|
}
|
|
|
|
public void OnClick_Reset()
|
|
{
|
|
m_StatResetUI.Set(() =>
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
sdata.PC.Reset_Stat();
|
|
Set_UI();
|
|
MyValue.Get_ActorStatInfoorNull(eRole.PC);
|
|
});
|
|
}
|
|
} |