From 77331d6447106d4cdc7ee978c3f396cab43fefb9 Mon Sep 17 00:00:00 2001 From: "aube.lee" Date: Fri, 7 Feb 2025 00:58:49 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BA=90=EB=A6=AD=ED=84=B0=20=EA=B2=BD?= =?UTF-8?q?=ED=97=98=EC=B9=98=20=EB=B0=8F=20=EB=A0=88=EB=B2=A8=EC=97=85=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=201=EC=B0=A8=20?= =?UTF-8?q?=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Character/CharacterBase.cs | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) 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()