diff --git a/endTrigger.cs b/endTrigger.cs index ee45976..7993ed9 100644 --- a/endTrigger.cs +++ b/endTrigger.cs @@ -10,7 +10,6 @@ public class endTrigger : MonoBehaviour if (other.gameObject.CompareTag("Player")) { SceneManager.LoadScene("end"); - SceneManager.UnloadSceneAsync("game"); } } } diff --git a/highScoreCheck.cs b/highScoreCheck.cs index 8eb1174..89806f3 100644 --- a/highScoreCheck.cs +++ b/highScoreCheck.cs @@ -6,18 +6,16 @@ using TMPro; public class highScoreCheck : MonoBehaviour { TextMeshProUGUI textBox; - public float highScore = 0; - + public float lowestTime; void Start() { - highScore = PlayerPrefs.GetFloat("highScore"); - if (highScore > PlayerPrefs.GetFloat("timeScore")) + + if (PlayerPrefs.GetFloat("lowestTime") > PlayerPrefs.GetFloat("timeScore")) { - PlayerPrefs.SetFloat("highScore",PlayerPrefs.GetFloat("timeScore")); - highScore = PlayerPrefs.GetFloat("timeScore"); + PlayerPrefs.SetFloat("lowestTime",PlayerPrefs.GetFloat("timeScore")); } textBox = GetComponent(); - textBox.SetText("Shortest Time: {0}s", highScore); + textBox.SetText("Shortest Time: {0}s", PlayerPrefs.GetFloat("lowestTime")); } } diff --git a/levelLoader.cs b/levelLoader.cs index 9ba2030..64a22e7 100644 --- a/levelLoader.cs +++ b/levelLoader.cs @@ -7,6 +7,10 @@ public class levelLoader : MonoBehaviour { public void NextLevel() { + if (SceneManager.GetActiveScene().name == "menu") + { + PlayerPrefs.SetFloat("lowestTime",9999f); + } SceneManager.LoadScene("game"); } } diff --git a/scoreReset.cs b/scoreReset.cs new file mode 100644 index 0000000..caccf98 --- /dev/null +++ b/scoreReset.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.SceneManagement; + +public class scoreReset : MonoBehaviour +{ + public void SendBack() + { + SceneManager.LoadScene("menu"); + } +}