public IEnumerator TestCanAddNewHighScore() { // Create a HighScoreManager GameObject highScoreManagerGO = new GameObject("HighScoreManager"); HighScoreManager highScoreManager = highScoreManagerGO.AddComponent <HighScoreManager>(); highScoreManager.runInEditMode = true; yield return(null); // Ensure we have no high scores highScoreManager.HighScores.Clear(); // Add a high score highScoreManager.AddHighScore(1000, "Test Player 1", false); // Check we have one high score Assert.AreEqual(highScoreManager.HighScores.Count, 1); // Add a new high score highScoreManager.AddHighScore(1001, "Test Player 2", false); // Check we have two high scores Assert.AreEqual(highScoreManager.HighScores.Count, 2); }
public IEnumerator TestCanGetCurrentHighScore() { // Create a HighScoreManager GameObject highScoreManagerGO = new GameObject("HighScoreManager"); HighScoreManager highScoreManager = highScoreManagerGO.AddComponent <HighScoreManager>(); highScoreManager.runInEditMode = true; yield return(null); // Ensure we have no high scores highScoreManager.HighScores.Clear(); // Add 3 high scores highScoreManager.AddHighScore(1000, "Test Player 1", false); // Add a new high score highScoreManager.AddHighScore(1001, "Test Player 2", false); // Add a new high score highScoreManager.AddHighScore(1002, "Test Player 3", false); // Check we have 3 high scores Assert.AreEqual(highScoreManager.HighScores.Count, 3); // Get the current high score float currentHighScore = highScoreManager.CurrentHighScore; // Make sure the current high score is correct Assert.AreEqual(1002, currentHighScore); }
/********************************************************************************************/ /**************************************** BEHAVIOURS ****************************************/ /********************************************************************************************/ /// <summary> /// Submit the HighScore to the HighScoreManager. /// </summary> public void EnterHighScore() { string name = nameField.text; if (name == "") { name = "Noob"; } HighScoreManager.AddHighScore(new HighScore(name, PlayerControl.Instance.Score)); gameObject.SetActive(false); }
public void AddScore(string name, int points) { ScoreManager.AddHighScore(new KeyValuePair <string, int>(name, points)); }
private void SaveScore(string name) { highScoreManager.AddHighScore(name, score, time); highScoreManager.SaveHighScores(); }