Only randomize title if high score > 0
This commit is contained in:
parent
8e0d1874dc
commit
87189cd124
@ -522,6 +522,9 @@ MonoBehaviour:
|
||||
- The Count's Last Feast
|
||||
- Vampire Arena
|
||||
- Out of Blood
|
||||
- Bloody Colosseum
|
||||
- Delay the Blood Rumblies
|
||||
- Vampire Snack
|
||||
startButton: {fileID: 4394421821813469848}
|
||||
--- !u!223 &4394421820928219483
|
||||
Canvas:
|
||||
|
||||
@ -25,12 +25,12 @@ public class GameTimer : MonoBehaviour {
|
||||
}
|
||||
|
||||
bool showHighScore;
|
||||
const string HighScoreKey = "High Score";
|
||||
public const string HIGH_SCORE_KEY = "High Score";
|
||||
|
||||
void Awake() {
|
||||
label = GetComponent<TMP_Text>();
|
||||
timer = 0f;
|
||||
highScore = PlayerPrefs.GetFloat(HighScoreKey);
|
||||
highScore = PlayerPrefs.GetFloat(HIGH_SCORE_KEY);
|
||||
Stopped = true;
|
||||
}
|
||||
|
||||
@ -55,12 +55,12 @@ public class GameTimer : MonoBehaviour {
|
||||
if (timer <= highScore)
|
||||
return;
|
||||
|
||||
PlayerPrefs.SetFloat(HighScoreKey, timer);
|
||||
PlayerPrefs.SetFloat(HIGH_SCORE_KEY, timer);
|
||||
highScore = timer;
|
||||
}
|
||||
|
||||
public void ResetHighScore() {
|
||||
PlayerPrefs.DeleteKey(HighScoreKey);
|
||||
PlayerPrefs.DeleteKey(HIGH_SCORE_KEY);
|
||||
highScore = 0f;
|
||||
}
|
||||
}
|
||||
@ -19,8 +19,15 @@ public class MainMenuManager : MonoBehaviour {
|
||||
void Awake() => mode = MenuMode.MainMenu;
|
||||
|
||||
void Start() {
|
||||
if (titleOptions.Length > 0)
|
||||
if (titleOptions.Length == 0) {
|
||||
Debug.LogWarning("No titles listed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerPrefs.HasKey(GameTimer.HIGH_SCORE_KEY) && PlayerPrefs.GetFloat(GameTimer.HIGH_SCORE_KEY) > 0f)
|
||||
titleLable.text = titleOptions[Random.Range(0, titleOptions.Length)];
|
||||
else
|
||||
titleLable.text = titleOptions[0];
|
||||
}
|
||||
|
||||
public void SetMenuMode(MenuMode mode) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user