Skip to content
Snippets Groups Projects
Commit 23e10ab5 authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Added skill points on level up.

- Also added debug constants to control leveling speed.
parent a0cfb748
No related branches found
No related tags found
1 merge request!60Upgrades people.
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment