In my game, there are various level scenes with an average completion time of 25-50 seconds. I would like to implement a scoring system that awards players 30 points for completing a level in 5-10 seconds, 20 points for completing a level in 10-25 seconds, and 5 points for completing a level in 50 seconds or more. How can I set up this scoring system in my game?
1 Answer
1It can be done through a static class
public static class ScoringSystem
{
public static int GetScore(float time)
{
if (time > 50) return 5;
if (time > 25) return 10; // 20 - 50 seconds
if (time > 10) return 20; // 10 - 25 seconds
if (time > 5) return 30; // 5-10 seconds
// 0 - 5 seconds
return 50;
}
}
Implementation:
float timeItTook;
int score = ScoringSystem.GetScore(timeItTook);