protected void UpdatePercentage(LeaderboardScore score) { // find new percentage LeaderboardPercentage percentage = null; foreach (var item in cachedPercentages) { if (percentage.lowerBorder < score.score) { score.percentage = item; } } }
public void SubmitScore(Reference <CoflnetUser> user, int score) { if (!scores.ContainsKey(user)) { scores[user] = new LeaderboardScore(user); } scores[user].score = score; // check if next percentage is reached if (scores[user].percentage.upperBorder < score) { UpdatePercentage(scores[user]); } }
public void AddScoreForFriend(LeaderboardScore score) { scores.Add(score); }
/// <summary> /// Points remaining the till next percentage mark is reached. /// </summary> /// <returns>The points till next percentage.</returns> /// <param name="user">User.</param> public int PointsTillNextPercentage(Reference <CoflnetUser> user) { LeaderboardScore score = scores[user]; return(score.percentage.upperBorder - score.score); }