I’ve three kinds of scores in my game (levelScores, bonusScores, totalScores )and at the end of my game I want to show all three scores one by one …
Suppose first levelScores fades in then bonusScores and then totalScores fades in …
I 've a script with the help of which I 'm just able to show one score(say levelScore)…
How can I be able to Show all there scores???
private int bonusScore = 400;
private int bonusScore = 3000;
private int totalScore = bonusScore + levelScore;
IEnumerator Start ()
{
yield return StartCoroutine (Fade (0f, 1f, fadeDuration));
yield return new WaitForSeconds (1.5f);
yield return StartCoroutine (ScoreCounter (scoreToCount));
// fading GUI texts by changing the gui font material alpha
private IEnumerator Fade (float startLevel, float endLevel, float time)
{
float speed = 1.0f / time;
for (float t = 0.0f; t < 1.0; t += Time.deltaTime*speed) {
float a = Mathf.Lerp (startLevel, endLevel, t);
guiText.font.material.color = new Color (guiText.font.material.color.r,
guiText.font.material.color.g,
guiText.font.material.color.b, a);
yield return null;
}
}
IEnumerator ScoreCounter (int target)
{
//float speed = 1.0f/time;
int start = 0;
for (float timer = 0.0f; timer < duration; timer += Time.deltaTime) {
float progress = timer / 0.5f;
newScore = (int)Mathf.Lerp (start, target, progress);
yield return 0;
}
}
void OnGUI ()
{
switch (showText) {
case ShowText.LevelScore:
guiText.text = "level Score " + newScore;
break;
case ShowText.BonusScore:
guiText.text = "Bonus Score " + bonusScore;
break;
case ShowText.TotalScore:
guiText.text = "total score " + totalScore;
break;
}
}
}
P.S. I know this script got some errors…
… Any help is much Appreciated.