diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs b/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs index 736d915e..72d1b621 100644 --- a/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs +++ b/Gameton-06/Assets/Gameton/Scripts/Character/CharacterBase.cs @@ -47,9 +47,35 @@ namespace TON currentSP = maxSP = playerData.mp; } - public void UpdateExpericenPoint(float point) - { + public int level = 1; // 현재 레벨 + public int exp = 0; // 현재 경험치 + public int expVariable = 10; // 경험치 변수 (조정 가능) + + // 현재 레벨에서 다음 레벨까지 필요한 경험치 계산 + private int GetRequiredExp(int currentLevel) + { + return (6 * currentLevel * currentLevel) + (currentLevel * expVariable); + } + + // 경험치 추가 및 레벨업 처리 + public void AddExp(int amount) + { + exp += amount; // 경험치 추가 + bool leveledUp = false; // 레벨업 여부 체크 + + while (exp >= GetRequiredExp(level)) // 경험치가 충분하면 반복해서 레벨업 + { + exp -= GetRequiredExp(level); // 초과 경험치 유지 + level++; // 레벨 증가 + leveledUp = true; + } + + if (leveledUp) + { + // 경험치와 레벨 데이터를 파일에 업데이트 한다. + Debug.Log($"레벨업! 현재 레벨: {level}, 남은 경험치: {exp}"); + } } public void FixedUpdate()