| | | 1 | | using System.Collections; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using UnityEngine; |
| | | 4 | | using UnityEngine.UI; |
| | | 5 | | using TMPro; |
| | | 6 | | using UnityEngine.SceneManagement; |
| | | 7 | | |
| | | 8 | | public class BestTime : MonoBehaviour |
| | | 9 | | { |
| | | 10 | | public static float bestTime = 0; |
| | | 11 | | public TextMeshPro bestTimeText; |
| | | 12 | | |
| | | 13 | | private void Start() |
| | 8 | 14 | | { |
| | 8 | 15 | | Scene scene = SceneManager.GetActiveScene(); |
| | 8 | 16 | | if(scene.name == "Hub") |
| | 1 | 17 | | { |
| | 1 | 18 | | TimeDisplay(bestTime); |
| | 1 | 19 | | } |
| | 8 | 20 | | } |
| | | 21 | | |
| | | 22 | | |
| | | 23 | | public void checkTime(float newTime) |
| | 3 | 24 | | { |
| | 3 | 25 | | if (newTime < bestTime || bestTime == 0) |
| | 3 | 26 | | { |
| | 3 | 27 | | bestTime = newTime; |
| | 3 | 28 | | } |
| | 3 | 29 | | } |
| | | 30 | | |
| | | 31 | | void TimeDisplay(float timeToDisplay) |
| | 1 | 32 | | { |
| | 1 | 33 | | if (timeToDisplay < 0) |
| | 0 | 34 | | { |
| | 0 | 35 | | timeToDisplay = 0; |
| | 0 | 36 | | } |
| | | 37 | | |
| | 1 | 38 | | float minutes = Mathf.FloorToInt(timeToDisplay / 60); |
| | 1 | 39 | | float seconds = Mathf.FloorToInt(timeToDisplay % 60); |
| | 1 | 40 | | bestTimeText.text = string.Format("{0:00}:{1:00}", minutes, seconds); |
| | 1 | 41 | | } |
| | | 42 | | } |
| | | 43 | | |