Skip to content

Instantly share code, notes, and snippets.

@ScottLilly
Created May 18, 2016 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ScottLilly/946defd4ddc9f4759f2fcc467d9ad38c to your computer and use it in GitHub Desktop.
Save ScottLilly/946defd4ddc9f4759f2fcc467d9ad38c to your computer and use it in GitHub Desktop.
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