コード例 #1
0
            public void UpdateScore(string uuid, int score)
            {
                // 個人毎の情報更新.
                if (!userHiScores.TryGetValue(uuid, out var hiScores))
                {
                    hiScores = new List <HiScoreRecord>();
                    userHiScores.Add(uuid, hiScores);
                }

                var hiScore = new HiScoreRecord {
                    Uuid  = uuid,
                    Score = score,
                    Date  = DateTime.Now,
                };

                userHiScores[uuid] = AddHiScore(hiScores, hiScore, MaxHiScoreCount);

                // 最終更新保存.
                if (!userLastHiScores.TryGetValue(uuid, out var _))
                {
                    userLastHiScores.Add(uuid, hiScore);
                }
                else
                {
                    userLastHiScores[uuid] = hiScore;
                }

                // 全体の情報更新.
                allUserScores = AddHiScore(allUserScores, hiScore, MaxHiScoreCountPerUser);
            }
コード例 #2
0
 public HiScore Translate(HiScoreRecord record)
 {
     return(new HiScore {
         Uuid = record.Uuid,
         Score = record.Score,
         Date = record.Date,
     });
 }
コード例 #3
0
 private static List <HiScoreRecord> AddHiScore(List <HiScoreRecord> list, HiScoreRecord newScore, int maxCount)
 {
     list.Add(newScore);
     return(list
            .OrderByDescending(score => score.Score)
            .ThenBy(score => score.Date)
            .Take(maxCount)
            .ToList());
 }