- Home /
Experience system for multiple skills
Hello,
I'm currently working on a demo for an RPG.
We will have a lot of skills (Could be up to 100). I have the basic functionality of 1 skill (checking if your exp is high enough to level, etc.)
Now, how do I go about implementing this for a lot of skills?
- Just making a script for every skills that inherits from the base script?
- Give the player the variables for every skill and call the other scripts to check for level-ups?
- Something else?
What I have now is:
public class BaseSkills{
private int _baseLevel; //Level of the skill private int _curExp; //Current exp private int _expToLevel; //Total experience for the next level private int _levelModifier; //Determines the experience needed for the next level
public BaseSkills() { _baseLevel = 1; _expToLevel = 100; _levelModifier = 1; }
region Setters and Getters
/Setters and getters public int BaseLevel { get{ return _baseLevel; } set{ _baseLevel = value; } }
public int CurExp { get{ return _curExp;} set{ _curExp = value;} }
public int ExpToLevel { get{ return _expToLevel; } set{ _expToLevel = value; } }
public int LevelModifier { get{ return _levelModifier; } set{ _levelModifier = value; } } #endregion
private int CalculateExpToLevel() { #region Experience if-statements //These if-statements calculate how much //experience needs to be added to if (ExpToLevel < 1000) //ExpToLevel. { LevelModifier = 100; } if (ExpToLevel < 6000) { LevelModifier = 500; } if (ExpToLevel < 16000) { LevelModifier = 1000; } if (ExpToLevel < 36000) { LevelModifier = 2000; } if (ExpToLevel < 66000) { LevelModifier = 3000; } if (ExpToLevel < 106000) { LevelModifier = 4000; } if (ExpToLevel < 156000) { LevelModifier = 5000; } if (ExpToLevel < 256000) { LevelModifier = 10000; } if (ExpToLevel < 406000) { LevelModifier = 15000; } if (ExpToLevel < 606000) { LevelModifier = 20000; } #endregion
return _expToLevel + _levelModifier;
}
public void LevelUp() { if (CurExp > ExpToLevel); BaseLevel++; }
}
Thanks in advance! Regards,
Simon.
P.S. I'm using C# in MonoDevelop.
This question doesn't make sense to me? What are you asking. Posting script examples will help. I don't understand why "checking if your exp is high enough to level" is a skill...
The "checking if your exp is high enough to level, etc." was a comment to "basic functionality". Look up in a $$anonymous$$ute to see my script.
This script is the base for my other skills. they will inherit it from this script. The skills are things related to combat, but also things like $$anonymous$$ing, etc. I just need to know what the best way is to do the inheritance for a lot of skills.
Answer by GesterX · May 13, 2011 at 09:45 PM
I understand now. You basically answered your own question. I would have your skills inherit from the base skill class in order to use the common functions.
This seems like the most sensible way to do it.
Ok, thank you. But do I need to do a new script for every single skill? Or is there a way to do this in one script?
You could have scripts for generic skills (melee, spell, ranged, etc), Then you could dynamically change the variables that need to change (animation, particle effects, damage).
Your answer
![](https://koobas.hobune.stream/wayback/20220613134105im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Experience System 1 Answer
How can i make it give u a certain xp everytime u kill someone? 1 Answer
Using static members vs normal ones for exp,lvl, health ect.. 1 Answer
Xp Calculation Bar 1 Answer
Level Joining Issue 1 Answer