Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public void UpdatePlayerExpAndLevel(int gainedExp)
{
double newNeededExp = this.ExperiencePoints;
double newMaximumHitpoints = this.MaximumHitPoints;
double multiplier;
this.ExperiencePoints += gainedExp;
if (this.ExperiencePoints >= this.NeededExperiencePoints)
{
this.Level += 1;
if (this.Level <= 3)
{
multiplier = 1.35;
}
else if (this.Level <= 6)
{
multiplier = 1.25;
}
else
{
multiplier = 1.15;
}
this.ExperiencePoints -= this.NeededExperiencePoints;
newNeededExp *= 1.15;
this.NeededExperiencePoints = (int)newNeededExp;
newMaximumHitpoints *= multiplier;
this.MaximumHitPoints = (int)newMaximumHitpoints;
this.CurrentHitPoints = this.MaximumHitPoints;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment