- Home /
Any good ideas on how to implement a one time reward system?
So I have if statements that represent your level for example
if (xp >= 100) { display.text = " Level 5 Novice"; }
I need it to show up at the end of the match if it adds up past the level for the first time and save that you have received it, also if you happen to level up twice have it give you both? Any good ways for this? (could also completely scratch my level display system doesn't matter I just did it this way since it works)
Thanks <33
Why dont you simply use a bool like this:
if(xp>=100 && alreadyLevelUp != true) ..//do stuff, set alreadyLevelUp = true
Of course you would still have to check which level the player actually is, in order to know which level he reached.
Answer by haruna9x · Sep 28, 2017 at 12:55 AM
If you only look at the player's xp. It's easy to do it as a high score. Use highXP to see if the player has passed it.
Could you elaborate a little more I'm not quite sure what you mean. If I use highXP to see if the player has passed it wouldnt it just reward it every time it checks?
private int xp;
private int highXP; // need save it
public int Xp
{
get { return xp; }
set
{
xp = value;
if (xp > highXP)
{
highXP = xp;
CheckBonus();
}
}
}
void CheckBonus()
{
// check
if (highXP > 100)
Debug.Log("Bonus at: " + 100);
}
// Save load
void OnAwake()
{
highXP = PlayerPrefs.GetInt("HighXP", 0);
}
void OnDestroy()
{
PlayerPrefs.SetInt("HighXP", highXP);
}
Your answer
Follow this Question
Related Questions
My XP System Refuses To Work... Help Please 1 Answer
Script plays only once [Android] 0 Answers
How to instantiate everything inside an Array? 1 Answer
Play sound only once 2 Answers
Leveling up in RPG 1 Answer