Added the keeping and displaying of highscores for endless and challenge mode

This commit is contained in:
Gregory Campbell
2020-08-08 11:59:05 -04:00
parent 4713656e0e
commit 07a35d79b7
7 changed files with 463 additions and 2 deletions
+19
View File
@@ -360,6 +360,7 @@ public class GMScript : MonoBehaviour
}
noRepeat = true;
//CHECK IF GAME OBJECT EXISTS BEFORE DOING THIS TO PREVENT ERRORS
EnemyHealthText.text = enemyHealth.ToString();
PartyHealthText.text = partyHealth.ToString();
@@ -424,6 +425,13 @@ public class GMScript : MonoBehaviour
//print("The Super Robo Squad has been destroyed! Try again!");
if(PlayerPrefs.GetInt("GameMode") == 1 && level > PlayerPrefs.GetInt("EndlessHighScore"))
{
PlayerPrefs.SetInt("EndlessHighScore", level-1);
}else if(PlayerPrefs.GetInt("GameMode") == 2 && level > PlayerPrefs.GetInt("ChallengeHighScore")){
PlayerPrefs.SetInt("ChallengeHighScore", level-1);
}
gameover = true;
cursorLock = false;
@@ -449,6 +457,9 @@ public class GMScript : MonoBehaviour
if(PlayerPrefs.GetInt("Level") >= maxLevel)
{
if(PlayerPrefs.GetInt("GameMode") == 2) PlayerPrefs.SetInt("ChallengeHighScore", 10);
PlayerPrefs.SetInt("TutorialComplete", 1);
StartCoroutine(BackToModeSelect());
}
@@ -471,6 +482,14 @@ public class GMScript : MonoBehaviour
if(hit.collider.gameObject.tag == "Back")
{
if(PlayerPrefs.GetInt("GameMode") == 1 && level > PlayerPrefs.GetInt("EndlessHighScore"))
{
PlayerPrefs.SetInt("EndlessHighScore", level-1);
}else if(PlayerPrefs.GetInt("GameMode") == 2 && level > PlayerPrefs.GetInt("ChallengeHighScore")){
PlayerPrefs.SetInt("ChallengeHighScore", level-1);
}
audioPlayer.PlayOneShot(SoundEffects[1]);
SceneManager.LoadScene("Mode Select Scene");
}