private void UpdateContent() { int nScores = (Top10 == null ? 0 : Top10.Count); if (nScores == 0) { namesLabel.Hide(); scoresLabel.Hide(); messagesLabel.Show(); } else { namesLabel.Show(); scoresLabel.Show(); messagesLabel.Hide(); } namesContentLabel.Text = String.Empty; scoresContentLabel.Text = String.Empty; for (int i = 0; i < nScores; i++) { GameState.PlayerState currentScore = Top10[i]; AddPlayer((i + 1), currentScore.Name); AddPlayerScore(currentScore.HighScore); } }
public static void AddScoreData(GameState.PlayerState data) { dataContainer.scores.Add(data); // Ensure that are sorted and do not exeed the limit List <GameState.PlayerState> scores = dataContainer.scores; scores = scores.OrderByDescending(o => o.HighScore).ToList(); int existingItems = scores.Count; if (existingItems > DataContainer.MAX_SCORES) { scores.RemoveRange(DataContainer.MAX_SCORES - 1, existingItems - DataContainer.MAX_SCORES); } }