Ejemplo n.º 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 (Exception ex)
            {
            }
            finally
            {
                this.game.RefreshScores();
            }
        }
Ejemplo n.º 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 { }
        }
Ejemplo n.º 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 { }
        }