// Use this for initialization void Start() { highScoreStorage = GameObject.Find("HighScoreStorage"); if (highScoreStorage == null) { highScoreStorage = Instantiate <GameObject>(highScoreStoragePrefab); highScoreStorage.name = "HighScoreStorage"; } highScoreScript = highScoreStorage.GetComponent <HighScoreStorage>(); UpdateScoreText(); }
/** * Called every frame update */ void Update() { if (Input.GetKeyDown(KeyCode.Escape) == true) { Application.Quit(); } if (this.levelController.isTimeOut()) { float highScore = HighScoreStorage.GetHighScore(); if (pickupScore >= highScore) { winText.text = "Congratulations! High score: " + pickupScore; if (pickupScore != highScore) { HighScoreStorage.SetHighScore(pickupScore); } } else { winText.text = "Out of Time! Your score was: " + pickupScore; } } }
// Use this for initialization void Start() { text = gameObject.GetComponent <Text>(); text.text = HighScoreStorage.GetHighScore().ToString(); }