Пример #1
0
        /// <summary>
        /// Add a new score to the local DB
        /// </summary>
        /// <param name="score">Score.</param>
        public int AddLocalScore(LocalScore score)
        {
            lock (mLocker) {
                mDb.Insert (score);
            }
            // Rank?
            List<LocalScore> modeScore = mDb.Table<LocalScore> ().Where (s => (s.Mode == score.Mode) && (s.Difficulty == score.Difficulty))
                .OrderByDescending (s => s.Score).Take (999).ToList ();

            int rank = modeScore.IndexOf (score);

            if (rank >= 0) {
                return rank;
            }

            return 999;
        }
        /// <summary>
        /// Updates local scores.
        /// </summary>
        /// <param name="locals">List of local scores.</param>
        private void UpdateLocals(LocalScore[] locals)
        {
            // Reveal field depending on the available scores.
              if (locals.Length > 0)
            UpdateLocalRank(LabelRank1, LabelRank1Score, locals[0].Score);

              if (locals.Length > 1)
            UpdateLocalRank(LabelRank2, LabelRank2Score, locals[1].Score);

              if (locals.Length > 2)
            UpdateLocalRank(LabelRank3, LabelRank3Score, locals[2].Score);

              if (locals.Length > 3)
            UpdateLocalRank(LabelRank4, LabelRank4Score, locals[3].Score);

              if (locals.Length > 4)
            UpdateLocalRank(LabelRank5, LabelRank5Score, locals[4].Score);
        }