예제 #1
0
        private async void InitializeOnlineScoreManager()
        {
            try
            {
                await OnlineScoreManager.Initialize("monokrome");

                string userName = this.dataStorageManager.GetDataOrDefault("PlayerName", string.Empty);
                await OnlineScoreManager.SetUser(userName);

                if (userName.Equals(string.Empty))
                {
                    this.dataStorageManager.AddOrUpdateData("PlayerName", OnlineScoreManager.Player.Name);
                }

                await this.UpdatesOnlineScores();

                this.game.RefreshScores();
                await this.RetrieveHighscores();
            }
            catch { }
            finally
            {
                this.game.RefreshScores();
            }
        }
예제 #2
0
        private async Task RetrieveHighscores()
        {
            try
            {
                var normalScores = await OnlineScoreManager.GetTopScores(5, OnlineScoreManager.GameVariants.First(x => x.Name.Equals("Normal")));

                this.game.NormalHighscores = normalScores.ToList();
                var hardScores = await OnlineScoreManager.GetTopScores(5, OnlineScoreManager.GameVariants.First(x => x.Name.Equals("Hard")));

                this.game.HardHighscores = hardScores.ToList();
            }
            catch { }
        }
예제 #3
0
        private async Task UpdatesOnlineScores()
        {
            try
            {
                int   normalLocalScore  = int.Parse(this.dataStorageManager.GetDataOrDefault("NormalMaxScore", "0"));
                int   hardLocalScore    = int.Parse(this.dataStorageManager.GetDataOrDefault("HardMaxScore", "0"));
                Score normalOnlineScore = await OnlineScoreManager.GetScore(OnlineScoreManager.GameVariants.First(x => x.Name.Equals("Normal")));

                Score hardOnlineScore = await OnlineScoreManager.GetScore(OnlineScoreManager.GameVariants.First(x => x.Name.Equals("Hard")));

                if (normalOnlineScore == null)
                {
                    OnlineScoreManager.PublishScore(OnlineScoreManager.GameVariants.First(x => x.Name.Equals("Normal")), normalLocalScore.ToString());
                }
                else if (normalLocalScore > int.Parse(normalOnlineScore.Value))
                {
                    normalOnlineScore.Value = normalLocalScore.ToString();
                    OnlineScoreManager.UpdateScore(normalOnlineScore);
                }
                else
                {
                    this.dataStorageManager.AddOrUpdateData("NormalMaxScore", normalOnlineScore.Value);
                }

                if (hardOnlineScore == null)
                {
                    OnlineScoreManager.PublishScore(OnlineScoreManager.GameVariants.First(x => x.Name.Equals("Hard")), hardLocalScore.ToString());
                }
                else if (hardLocalScore > int.Parse(hardOnlineScore.Value))
                {
                    hardOnlineScore.Value = hardLocalScore.ToString();
                    OnlineScoreManager.UpdateScore(hardOnlineScore);
                }
                else
                {
                    this.dataStorageManager.AddOrUpdateData("HardMaxScore", hardOnlineScore.Value);
                }
            }
            catch { }
        }
예제 #4
0
 private async Task <IEnumerable <Score> > RetrieveHighscores(string dificultyName)
 {
     return(await OnlineScoreManager.GetTopScores(5, OnlineScoreManager.GameVariants.First(x => x.Name.Equals(dificultyName))));
 }