public static int CompareByEffectLayer(HighScoreData score1, HighScoreData score2) { if (score1.GetScoreValue() == score2.GetScoreValue()) { return(score1.GetScoreValue().CompareTo(score2.GetScoreValue())); } else { return(score2.GetScoreValue() - score1.GetScoreValue()); } }
void ApplyHighScore(HighScoreData scoreData) { if (SaveLoad.highScores.Count < HIGH_SCORE_LIMIT) { SaveLoad.SaveHighScore(scoreData); } else { SaveLoad.highScores.Sort(CompareByEffectLayer); if (SaveLoad.highScores[SaveLoad.highScores.Count - 1].GetScoreValue() < scoreData.GetScoreValue()) { SaveLoad.highScores.RemoveAt(SaveLoad.highScores.Count - 1); SaveLoad.SaveHighScore(scoreData); } } DisplayHighScores(); }