- Home /
What is the best way to create this Scoresystem ?
Hi, i am currently trying to create a Gamewide System which gets the highest score from Google Play Games and then create Stages based on that Score. For example :
Highscore = 1000
Stage 1 0 - 100 Score
Stage 2 100-200 Score
Stage 3 200 -300 Score
and so on. I want to calculate the Stages in my GameManager script and then. based on the current Stage, change some variables in other scripts such as Enemy Spawnrate and so on. I as a beginner can only think of a switch statement at this point.
What would be the cleanest solution for this ? Thanks in advance !
Answer by AconitumNapellum · Nov 06, 2019 at 12:17 PM
Highscore = 999
Calculate stage:
int stage = Mathf.Floor(highscore / 100);
In this case you would get 9 (999/100 = 9.99, Mathf.Floor returns 9)
After calculating stage, multiply spawnrate, speed, etc... by stage number to get incrementing values each time you get on a new stage.
Okay i think i didnt make it clear what i am trying to achieve, sorry. I want to set the stages based on the current Highscore.
So if the Highscore is 1000 i want the Stages to range from :
Stage 1 : 0-100 ((Highscore/10) 1) - ((Highscore/10) 1,9)
Stage 2 : 100-200((Highscore/10) 2) - ((Highscore/10) 2,9)
Stage 3 : 200-300(Highscore/10 3) - ((Highscore/10) 3,9)
and so on. So like i said i want to calculate this in my Gamemanager and inform every other script which stage the player currently is in. $$anonymous$$y question is : How do i set the current stage in the Gamemanager and change the values in other scripts based on the stage ? I can only think of a switch statement for the enemyspawn script for example something like :
void Update (){ switch Stage { case 1 : spawnrate 10% case 2 : spawnrate 20% }
but i don't know how to impelemt this properly or if this is even the right way to do this. I have to make an enum for this to work right ?
Thanks for your answer !
I still don't get how you're calculating your stages, but you should use a simple math algorithm made by yourself to change behaviours on scene based on the stage you're currently on. Using a switch statement limits you to a set number of cases, and that's not ideal. You should really use a value given by highscore to calculate spawnrate, speed, etc.
If you're thinking of checking your stage number with a switch case why not just multiplying stage number by 10? That gives you 10% spawnrate for stage number 1, 20% for stage number 2, etc..
Yeah i am not explaining it too well, am i. :D
Lets say my goal is to create 5 Stages with a variable starting and ending-score. So the higher the highscore gets, the longer the player will be in each stage.
How i calculate them, doesnt matter at the moment. $$anonymous$$y question revolves around how to efficiently inform other scripts about what stage i am in.
Your answer
![](https://koobas.hobune.stream/wayback/20220612214419im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
About Simple Score System 2 Answers
Combined Total of Different Variable Values 2 Answers
How do I code time based score unity3d 3 Answers
Score System - Problem found - Need help with solution 2 Answers
Add score when enemy is killed? 2 Answers