public HighScores() { Entries = new HighScoresEntry[3]; for (int i = 0; i < 3; ++i) { Entries[i] = new HighScoresEntry(); } }
private void OnDestroy() { HighScores highScores = HighScores.LoadHighScores(); if (NewHighScoreGameObject.activeSelf) { HighScoresEntry newEntry = new HighScoresEntry { EngineerName = EngineerNameText.text, GunnerName = GunnerNameText.text, RunnerName = RunnerNameText.text, TeamScore = Scoring.TeamScore }; highScores.Insert(newEntry); HighScores.SaveHighScores(highScores); } }
public bool Insert(HighScoresEntry newEntry) { if (newEntry.TeamScore > Entries[2].TeamScore) { // insert high score Entries[2] = newEntry; int i = 1; while (i >= 0 && Entries[i].TeamScore < Entries[i + 1].TeamScore) { HighScoresEntry tmp = Entries[i]; Entries[i] = Entries[i + 1]; Entries[i + 1] = tmp; i--; } return(true); } else { return(false); } }
private void Start() { Entry = new HighScoresEntry(); }