I have a most time survived scoring system but there is something wrong with my timer. When i reach a new high time it shows like ss:ss instead of mm:ss (like 29:29 instead of 00:29) and things getting more interesting, after i restart the game timer works properly(shows like 00:29). Please help me guys. There is my code:
private void Start()
{
startTime = Time.time;
float gameTimer = Time.time - startTime;
string minutes = Mathf.Floor(gameTimer / 60).ToString("00");
string seconds = (gameTimer % 60).ToString("00");
mostTimeSurvived.text = PlayerPrefs.GetFloat("HighTime").ToString(string.Format("{0:00}:{1:00}", minutes, seconds));
}
public void Finish()
{
finished = true;
float gameTimer = Time.time - startTime;
string minutes = Mathf.Floor(gameTimer / 60).ToString("00");
string seconds = (gameTimer % 60).ToString("00");
if (PlayerPrefs.GetFloat("HighTime") < gameTimer)
{
PlayerPrefs.SetFloat("HighTime", gameTimer);
mostTimeSurvived.text = gameTimer.ToString(string.Format("{0:00}:{1:00}", minutes, seconds));
}
}