void intializeRanks() { for (int i = 0; i < scoresUI.Length; i++) { scoreProfiles[i] = new ScoreProfile(scoresUI[i].nameText.text, scoresUI[i].getTime()); } }
//Takes a new score profile and inserts it at rank, shuffling all the highscore under it down 1 void insertNewRank(ScoreProfile newHighScore, int rank) { for (int i = scoreProfiles.Length - 1; i > rank; i--) { scoreProfiles[i] = scoreProfiles[i - 1]; } scoreProfiles[rank] = newHighScore; }
public IEnumerator setupHighScorePanel(float time) { int rank = checkIfHighScore(time); if (rank != -1) { inputPanel.gameObject.SetActive(true); yield return(new WaitUntil(() => inputPanel.isFinishedInput())); //Get the name of the profile and then remove the input panel string name = inputPanel.inputField.text; inputPanel.disable(); ScoreProfile newProfile = new ScoreProfile(name, time); insertNewRank(newProfile, rank); //Save the new highscore table GameData.saveData <ScoreProfile>(scoreProfiles); updateUI(); } }