From 23e10ab5703d8ad53875acc0c041a57d382e12c8 Mon Sep 17 00:00:00 2001 From: Ny Bruker <robinhs@stud.ntnu.no> Date: Thu, 10 Nov 2022 16:31:23 +0100 Subject: [PATCH] Added skill points on level up. - Also added debug constants to control leveling speed. --- MrBigsock/Assets/Code/PlayerController.cs | 27 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/MrBigsock/Assets/Code/PlayerController.cs b/MrBigsock/Assets/Code/PlayerController.cs index 6fd71277..9607dd73 100644 --- a/MrBigsock/Assets/Code/PlayerController.cs +++ b/MrBigsock/Assets/Code/PlayerController.cs @@ -16,6 +16,11 @@ namespace BigSock { public partial class PlayerController : Character { + public const int SKILL_POINTS_PR_LVL = 3; // Skill points to gain pr level up. + public const int SKILL_POINTS_START = 5; // Skill points to start with. + public const float XP_SCALE_RATE = 3.0f; // Multiplier for xp gain, helps test system while game is tiny. + + public UtilBar utilBar; @@ -280,21 +285,31 @@ namespace BigSock { utilBar?.WithHealth(Convert.ToInt32(HP)); } - public void GainXp(float xp){ - GiveXp(xp); + public void GainXp(float xp) { + GiveXp(xp * XP_SCALE_RATE); CheckXp(); utilBar?.WithXP((int)this.xp); } - private void CheckXp(){ - if(xp > maxXp){ + + /* + Checks for, and handles, level-ups. + */ + private void CheckXp() { + // If the character has leveled up. + if(xp > maxXp) { level += 1; xp -= maxXp; maxXp = (level + 1) * 100; utilBar?.WithXP(maxValue: (int)maxXp); - + SkillPoints += SKILL_POINTS_PR_LVL; } + /* + To-do: + - Maybe not flat skill points pr level. + - Scale differently. (Separate function for getting xp requirement pr level) + */ } } @@ -308,7 +323,7 @@ namespace BigSock { /* The number of skill points the user has at their disposal. */ - public int SkillPoints { get; set; } + public int SkillPoints { get; set; } = SKILL_POINTS_START; /* The amount of points the user has currently spent on each skill. -- GitLab