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

This commit is contained in:
Gregory Campbell
2020-02-08 20:06:38 -05:00
parent 374fcf2334
commit d2a08dea19
3 changed files with 25 additions and 25 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ public class HighScore : MonoBehaviour
InfinityScoreText.text = "HIGH SCORE: " + "\n" + PlayerPrefs.GetInt("RunnerHighFloor") InfinityScoreText.text = "HIGH SCORE: " + "\n" + PlayerPrefs.GetInt("RunnerHighFloor")
+ "-" + PlayerPrefs.GetInt("RunnerHighLevel"); + "-" + 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"));
} }
} }
+2 -1
View File
@@ -12,7 +12,7 @@ public class InfinityRunner : MonoBehaviour
public static int escalation = 1; public static int escalation = 1;
public static int level = 1; public static int level = 1;
public static float fullTime; public static float fullTime;
public static float distance; public float distance;
public GameObject player; public GameObject player;
public PlayerController script; public PlayerController script;
public GameObject[] obstacleList; public GameObject[] obstacleList;
@@ -35,6 +35,7 @@ public class InfinityRunner : MonoBehaviour
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
fullTime = Time.time; fullTime = Time.time;
spawnTime = Time.time; spawnTime = Time.time;
gameOver = false; gameOver = false;
+21 -22
View File
@@ -17,7 +17,6 @@ public class PauseMenu : MonoBehaviour
public TextMeshProUGUI ScoreText; public TextMeshProUGUI ScoreText;
public TextMeshProUGUI TimeText; public TextMeshProUGUI TimeText;
public TextMeshProUGUI LivesText; public TextMeshProUGUI LivesText;
public TextMeshProUGUI MiddleText;
public TextMeshProUGUI HighScoreText; public TextMeshProUGUI HighScoreText;
public TextMeshProUGUI HighTimeText; public TextMeshProUGUI HighTimeText;
@@ -51,7 +50,6 @@ public class PauseMenu : MonoBehaviour
{ {
ScoreText.text = "LEVEL: " + InfinityRunner.escalation + "-" + InfinityRunner.level; ScoreText.text = "LEVEL: " + InfinityRunner.escalation + "-" + InfinityRunner.level;
LivesText.text = "LIVES: " + PlayerController.shownLives; LivesText.text = "LIVES: " + PlayerController.shownLives;
MiddleText.text = "DISTANCE: " + Mathf.Round(InfinityRunner.distance);
} }
if(Input.GetButtonDown("Pause")) if(Input.GetButtonDown("Pause"))
@@ -148,9 +146,7 @@ public class PauseMenu : MonoBehaviour
HighScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("ObstacleHighFloor") HighScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("ObstacleHighFloor")
+ "-" + PlayerPrefs.GetInt("ObstacleHighLevel"); + "-" + PlayerPrefs.GetInt("ObstacleHighLevel");
HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("ObstacleHighTime")); HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("ObstacleHighTime"));
} } else if(WaypointRace.gameOver == true)
if(WaypointRace.gameOver == true)
{ {
ScoreText.text = "LEVEL: " + (WaypointRace.size - 1) + "-" + WaypointRace.level; ScoreText.text = "LEVEL: " + (WaypointRace.size - 1) + "-" + WaypointRace.level;
TimeText.text = "TIME: " + Mathf.Round(WaypointRace.fullTime); TimeText.text = "TIME: " + Mathf.Round(WaypointRace.fullTime);
@@ -185,26 +181,24 @@ public class PauseMenu : MonoBehaviour
+ "-" + PlayerPrefs.GetInt("WaypointHighFloor"); + "-" + PlayerPrefs.GetInt("WaypointHighFloor");
HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("WaypointHighTime")); HighTimeText.text = "HIGH SCORE TIME: " + Mathf.Round(PlayerPrefs.GetFloat("WaypointHighTime"));
} } else if(InfinityRunner.gameOver == true)
if(InfinityRunner.gameOver == true)
{ {
ScoreText.text = "LEVEL: " + InfinityRunner.escalation + "-" + InfinityRunner.level; 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") || if(InfinityRunner.escalation > PlayerPrefs.GetInt("RunnerHighFloor") ||
(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") || if(InfinityRunner.escalation > PlayerPrefs.GetInt("RunnerHighFloor") ||
InfinityRunner.level > PlayerPrefs.GetInt("RunnerHighLevel") || InfinityRunner.level > PlayerPrefs.GetInt("RunnerHighLevel") ||
(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("RunnerHighFloor", InfinityRunner.escalation);
PlayerPrefs.SetInt("RunnerHighLevel", InfinityRunner.level); PlayerPrefs.SetInt("RunnerHighLevel", InfinityRunner.level);
PlayerPrefs.SetFloat("RunnerHighDistance", Mathf.Round(InfinityRunner.distance)); PlayerPrefs.SetFloat("RunnerHighTime", Mathf.Round(InfinityRunner.fullTime));
highscore = true; highscore = true;
} }
@@ -220,7 +214,7 @@ public class PauseMenu : MonoBehaviour
HighScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("RunnerHighFloor") HighScoreText.text = "HIGH SCORE: " + PlayerPrefs.GetInt("RunnerHighFloor")
+ "-" + PlayerPrefs.GetInt("RunnerHighLevel"); + "-" + 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); SceneManager.LoadScene("Hub World", LoadSceneMode.Single);
Cursor.visible = false; Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked; Cursor.lockState = CursorLockMode.Locked;
FloorLevel.gameOver = false;
WaypointRace.gameOver = false;
InfinityRunner.gameOver = false;
} }
public void LoadMenu() public void LoadMenu()
@@ -253,17 +250,19 @@ public class PauseMenu : MonoBehaviour
if(FloorLevel.gameOver == true) if(FloorLevel.gameOver == true)
{ {
FloorLevel.gameOver = false; FloorLevel.gameOver = false;
SceneManager.LoadScene("Floor Level", LoadSceneMode.Single);
}
if(WaypointRace.gameOver == true)
{
WaypointRace.gameOver = false; WaypointRace.gameOver = false;
SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single); InfinityRunner.gameOver = false;
} SceneManager.LoadScene("Floor Level", LoadSceneMode.Single);
} else if(WaypointRace.gameOver == true)
if(InfinityRunner.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; InfinityRunner.gameOver = false;
SceneManager.LoadScene("Infinity Runner", LoadSceneMode.Single); SceneManager.LoadScene("Infinity Runner", LoadSceneMode.Single);
} }