Esempio n. 1
0
        public void AddEntry(ScoreboardEntryData scoreboardEntryData)
        {
            ScoreboardSavedData saved_scores = GetSavedScores();

            bool score_added = false;

            for (int i = 0; i < saved_scores.high_scores.Count; i++)
            {
                if (scoreboardEntryData.entry_score > saved_scores.high_scores[i].entry_score) //if score trying to add is greater than current score checking
                {
                    saved_scores.high_scores.Insert(i, scoreboardEntryData);                   //put into list at i
                    score_added = true;
                    break;
                }
            }
            if (!score_added && saved_scores.high_scores.Count < max_scoreboard_entries)                                               // still space left
            {
                saved_scores.high_scores.Add(scoreboardEntryData);                                                                     //put new score in list
            }
            if (saved_scores.high_scores.Count > max_scoreboard_entries)                                                               //too many entries
            {
                saved_scores.high_scores.RemoveRange(max_scoreboard_entries, saved_scores.high_scores.Count - max_scoreboard_entries); //remove entries from max to count of scores
            }

            UpdateUI(saved_scores);

            SaveScores(saved_scores);
        }
 //This method links the usernames and scores to the GUI interface for display to screen
 public void Initialize(ScoreboardEntryData scoreboardEntryData)
 {
     entry_name_text.text  = scoreboardEntryData.entry_name;
     entry_score_text.text = scoreboardEntryData.entry_score.ToString();
 }