/// <summary> /// Stops the timers and disables control of all racers, also saves the historical records. /// </summary> public void StopRace() { m_IsRaceRunning = false; foreach (KeyValuePair <IRacer, Checkpoint> racerNextCheckpoint in m_RacerNextCheckpoints) { racerNextCheckpoint.Key.DisableControl(); racerNextCheckpoint.Key.PauseTimer(); } TrackRecord.Save(m_HistoricalBestLap); TrackRecord.Save(m_HistoricalBestRace); // displays game over menu and sets score gameOverCanvas.gameObject.SetActive(true); gameOverCanvas.SetScore(m_SessionBestLap.time, m_HistoricalBestLap.time); // adds coins to total number of coins CoinManager coinManager = FindObjectOfType <CoinManager>(); if (coinManager == null) { Debug.LogError("Coin Manager missing in scene"); } coinManager.SetCoinsNumber(); }
/// <summary> /// Stops the timers and disables control of all racers, also saves the historical records. /// </summary> public void StopRace() { m_IsRaceRunning = false; foreach (KeyValuePair <IRacer, Checkpoint> racerNextCheckpoint in m_RacerNextCheckpoints) { racerNextCheckpoint.Key.DisableControl(); racerNextCheckpoint.Key.PauseTimer(); } TrackRecord.Save(m_HistoricalBestLap); TrackRecord.Save(m_HistoricalBestRace); }
/// <summary> /// Stops the timers and disables control of all racers, also saves the historical records. /// </summary> public void StopRace() { m_IsRaceRunning = false; foreach (KeyValuePair <IRacer, Checkpoint> racerNextCheckpoint in m_RacerNextCheckpoints) { racerNextCheckpoint.Key.DisableControl(); racerNextCheckpoint.Key.PauseTimer(); } TrackRecord.Save(m_HistoricalBestLap); TrackRecord.Save(m_HistoricalBestRace); //show main manu at end of race controller.ToggleMainMenu(true); }
/// <summary> /// Stops the timers and disables control of all racers, also saves the historical records. /// </summary> public void StopRace() { m_IsRaceRunning = false; foreach (KeyValuePair <IRacer, Checkpoint> racerNextCheckpoint in m_RacerNextCheckpoints) { racerNextCheckpoint.Key.DisableControl(); racerNextCheckpoint.Key.PauseTimer(); } TrackRecord.Save(m_HistoricalBestLap); TrackRecord.Save(m_HistoricalBestRace); BestTime = SessionBestLap; //Obtengo el valor de mejor vuelta. BestTime = Mathf.Round(SessionBestLap * 100f) / 100f; //Redondeo para tener solo 2 decimales. PlayerPrefs.SetString("Best time", BestTime.ToString()); //Convierto el número flotante a texto. PlayerPrefs.Save(); //Guardo el valor como texto. }