From d2a08dea19dc017444aad307cf68a789d0ce5e68 Mon Sep 17 00:00:00 2001 From: Gregory Campbell Date: Sat, 8 Feb 2020 20:06:38 -0500 Subject: [PATCH] Reverted back to using time as a secondary score for infinity runner as well as fixing a bug that would send you to infinity runner on retry --- Assets/Scripts/HighScore.cs | 2 +- Assets/Scripts/InfinityRunner.cs | 5 ++-- Assets/Scripts/PauseMenu.cs | 43 ++++++++++++++++---------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Assets/Scripts/HighScore.cs b/Assets/Scripts/HighScore.cs index 4731de9..8bc5756 100644 --- a/Assets/Scripts/HighScore.cs +++ b/Assets/Scripts/HighScore.cs @@ -27,7 +27,7 @@ public class HighScore : MonoBehaviour InfinityScoreText.text = "HIGH SCORE: " + "\n" + PlayerPrefs.GetInt("RunnerHighFloor") + "-" + PlayerPrefs.GetInt("RunnerHighLevel"); - InfinityTimeText.text = "HIGH SCORE DISTANCE: " + "\n" + Mathf.Round(PlayerPrefs.GetFloat("RunnerHighDistance")); + InfinityTimeText.text = "HIGH SCORE TIME: " + "\n" + Mathf.Round(PlayerPrefs.GetFloat("RunnerHighTime")); } } diff --git a/Assets/Scripts/InfinityRunner.cs b/Assets/Scripts/InfinityRunner.cs index 4e3211b..1d37bf6 100644 --- a/Assets/Scripts/InfinityRunner.cs +++ b/Assets/Scripts/InfinityRunner.cs @@ -12,7 +12,7 @@ public class InfinityRunner : MonoBehaviour public static int escalation = 1; public static int level = 1; public static float fullTime; - public static float distance; + public float distance; public GameObject player; public PlayerController script; public GameObject[] obstacleList; @@ -35,7 +35,8 @@ public class InfinityRunner : MonoBehaviour // Start is called before the first frame update void Start() { - fullTime = Time.time; + + fullTime = Time.time; spawnTime = Time.time; gameOver = false; script = player.GetComponent(); diff --git a/Assets/Scripts/PauseMenu.cs b/Assets/Scripts/PauseMenu.cs index 37db5ff..7d7376a 100644 --- a/Assets/Scripts/PauseMenu.cs +++ b/Assets/Scripts/PauseMenu.cs @@ -17,7 +17,6 @@ public class PauseMenu : MonoBehaviour public TextMeshProUGUI ScoreText; public TextMeshProUGUI TimeText; public TextMeshProUGUI LivesText; - public TextMeshProUGUI MiddleText; public TextMeshProUGUI HighScoreText; public TextMeshProUGUI HighTimeText; @@ -51,7 +50,6 @@ public class PauseMenu : MonoBehaviour { ScoreText.text = "LEVEL: " + InfinityRunner.escalation + "-" + InfinityRunner.level; LivesText.text = "LIVES: " + PlayerController.shownLives; - MiddleText.text = "DISTANCE: " + Mathf.Round(InfinityRunner.distance); } if(Input.GetButtonDown("Pause")) @@ -148,9 +146,7 @@ public class PauseMenu : MonoBehaviour HighScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("ObstacleHighFloor") + "-" + PlayerPrefs.GetInt("ObstacleHighLevel"); HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("ObstacleHighTime")); - } - - if(WaypointRace.gameOver == true) + } else if(WaypointRace.gameOver == true) { ScoreText.text = "LEVEL: " + (WaypointRace.size - 1) + "-" + WaypointRace.level; TimeText.text = "TIME: " + Mathf.Round(WaypointRace.fullTime); @@ -185,26 +181,24 @@ public class PauseMenu : MonoBehaviour + "-" + PlayerPrefs.GetInt("WaypointHighFloor"); HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("WaypointHighTime")); - } - - if(InfinityRunner.gameOver == true) + } else if(InfinityRunner.gameOver == true) { ScoreText.text = "LEVEL: " + InfinityRunner.escalation + "-" + InfinityRunner.level; - TimeText.text = "DISTANCE: " + Mathf.Round(InfinityRunner.distance); + TimeText.text = "TIME: " + Mathf.Round(InfinityRunner.fullTime); if(InfinityRunner.escalation > PlayerPrefs.GetInt("RunnerHighFloor") || (InfinityRunner.escalation == PlayerPrefs.GetInt("RunnerHighFloor") && - InfinityRunner.level >= PlayerPrefs.GetInt("RunnerHighLevel"))) + InfinityRunner.level >= PlayerPrefs.GetInt("RunnerHighTime"))) { if(InfinityRunner.escalation > PlayerPrefs.GetInt("RunnerHighFloor") || InfinityRunner.level > PlayerPrefs.GetInt("RunnerHighLevel") || (InfinityRunner.level == PlayerPrefs.GetInt("RunnerHighLevel") && - Mathf.Round(InfinityRunner.distance) > PlayerPrefs.GetFloat("RunnerHighDistance"))) + Mathf.Round(InfinityRunner.fullTime) < PlayerPrefs.GetFloat("RunnerHighTime"))) { PlayerPrefs.SetInt("RunnerHighFloor", InfinityRunner.escalation); PlayerPrefs.SetInt("RunnerHighLevel", InfinityRunner.level); - PlayerPrefs.SetFloat("RunnerHighDistance", Mathf.Round(InfinityRunner.distance)); + PlayerPrefs.SetFloat("RunnerHighTime", Mathf.Round(InfinityRunner.fullTime)); highscore = true; } @@ -220,7 +214,7 @@ public class PauseMenu : MonoBehaviour HighScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("RunnerHighFloor") + "-" + PlayerPrefs.GetInt("RunnerHighLevel"); - HighTimeText.text = "HIGH SCORE DISTANCE: " + Mathf.Round(PlayerPrefs.GetFloat("RunnerHighDistance")); + HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("RunnerHighTime")); } } @@ -232,6 +226,9 @@ public class PauseMenu : MonoBehaviour SceneManager.LoadScene("Hub World", LoadSceneMode.Single); Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; + FloorLevel.gameOver = false; + WaypointRace.gameOver = false; + InfinityRunner.gameOver = false; } public void LoadMenu() @@ -253,17 +250,19 @@ public class PauseMenu : MonoBehaviour if(FloorLevel.gameOver == true) { FloorLevel.gameOver = false; - SceneManager.LoadScene("Floor Level", LoadSceneMode.Single); - } - - if(WaypointRace.gameOver == true) - { WaypointRace.gameOver = false; - SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single); - } - - if(InfinityRunner.gameOver == true) + InfinityRunner.gameOver = false; + SceneManager.LoadScene("Floor Level", LoadSceneMode.Single); + } else if(WaypointRace.gameOver == true) { + FloorLevel.gameOver = false; + WaypointRace.gameOver = false; + InfinityRunner.gameOver = false; + SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single); + } else if(InfinityRunner.gameOver == true) + { + FloorLevel.gameOver = false; + WaypointRace.gameOver = false; InfinityRunner.gameOver = false; SceneManager.LoadScene("Infinity Runner", LoadSceneMode.Single); }