void Update() { switch (currentState) { case endMenuStates.coinCount: valueForCoins = Mathf.Lerp(valueForCoins, toreachCoins, 0.05f); finalCoins.text = "" + Mathf.RoundToInt(valueForCoins); if (toreachCoins - valueForCoins < 1) { finalCoins.text = "" + Mathf.RoundToInt(toreachCoins); currentState = endMenuStates.DistanceCount; } break; case endMenuStates.DistanceCount: valueForDistance = Mathf.Lerp(valueForDistance, toreachDistance, 0.05f); finalDistance.text = "" + Mathf.RoundToInt(valueForDistance); if (toreachDistance - valueForDistance < 1) { currentState = endMenuStates.EnemiesCount; } break; case endMenuStates.EnemiesCount: valueForEnemies = Mathf.Lerp(valueForEnemies, toReachEnemies, 0.05f); finalEnemiesDefeated.text = "" + Mathf.RoundToInt(valueForEnemies); if (toReachEnemies - valueForEnemies < 1) { currentState = endMenuStates.universalMulti; } break; case endMenuStates.universalMulti: universalMultiplier.text = PlayerPrefs.GetInt("UniversalMultiplier", 1).ToString(); currentState = endMenuStates.ScoreCount; break; case endMenuStates.ScoreCount: ValueForScore = Mathf.Lerp(ValueForScore, toreachScore, 0.05f); finalScore.text = "" + Mathf.RoundToInt(ValueForScore); if (toreachScore - ValueForScore < 1) { finalScore.text = "" + Mathf.RoundToInt(ValueForScore); currentState = endMenuStates.showButtons; } break; case endMenuStates.showButtons: // wiggle facebook button CheckNewHighScore(); showButtons(); currentState = endMenuStates.none; break; } }
void Update() { switch (currentState) { //for coins collected state case endMenuStates.coinCount: valueForCoins = Mathf.Lerp(valueForCoins, toreachCoins, 0.3f); //value for coins finalCoins.text = "" + Mathf.RoundToInt(valueForCoins); if (Mathf.RoundToInt(valueForCoins) == toreachCoins) { currentState = endMenuStates.ScoreCount; } break; //for score count state case endMenuStates.ScoreCount: valueForScore = Mathf.Lerp(valueForScore, toreachScore, 0.3f); //value for score finalScore.text = "" + Mathf.RoundToInt(valueForScore); if (Mathf.RoundToInt(valueForScore) == toreachScore) { currentState = endMenuStates.DistanceCount; } break; //for distance take state case endMenuStates.DistanceCount: valueForDistance = Mathf.Lerp(valueForDistance, toreachDistance, 0.3f); //value for distance finalDistance.text = "" + Mathf.RoundToInt(valueForDistance); if (Mathf.RoundToInt(valueForDistance) == toreachDistance) { currentState = endMenuStates.BestDistanceCount; } break; //for best distance state case endMenuStates.BestDistanceCount: ValueForBestDistance = Mathf.Lerp(ValueForBestDistance, toreachBestDistance, 0.3f); //value for best distance bestDistance.text = "" + Mathf.RoundToInt(ValueForBestDistance); if (Mathf.RoundToInt(ValueForBestDistance) == toreachBestDistance) { currentState = endMenuStates.showButtons; } break; //for buttons show state case endMenuStates.showButtons: showButtons(); //to show buttons currentState = endMenuStates.nothing; break; } }
void Start() { newHighscore.SetActive(false); FinalCoins(); FinalDistanceCount(); FinalEnemiesCount(); FinalScore(); buttonGroup.SetActive(false); currentState = endMenuStates.coinCount; finalCoins.text = "0"; finalDistance.text = "0"; finalEnemiesDefeated.text = "0"; finalScore.text = "0"; GameObject[] Obj = GameObject.FindGameObjectsWithTag("Destroy"); for (int i = 0; i <= Obj.Length - 1; i++) { Destroy(Obj [i], 1.0f); } }