Esempio n. 1
0
    public IEnumerator UpdateStat(string name, int value)
    {
        //GameManager.SetDebugOutput("stats", "stat updates disabled");
        //yield break;

        // Don't spam if client is not logged in (offline). Some score might also be posted before login completes and the SDK throws then.
        if (!PlayFabClientAPI.IsClientLoggedIn())
        {
            yield break;
        }

        UpdatePlayerStatisticsRequest req = new UpdatePlayerStatisticsRequest();
        StatisticUpdate stat = new StatisticUpdate
        {
            Version       = stats.ContainsKey(name) ? (uint?)stats[name].Version : null,
            StatisticName = name,
            Value         = value,
        };

        req.Statistics = new List <StatisticUpdate> {
            stat
        };

        Action <Action <UpdatePlayerStatisticsResult>, Action <PlayFabError> > apiCall = (onsuccess, onError) =>
        {
            PlayFabClientAPI.UpdatePlayerStatistics(req, onsuccess, onError);
        };

        yield return(ExecuteApiCallWithRetry(apiCall, busyIndicatorAfterSec: 0.0f, messageBoxAfterSec: 4.0f));
    }
Esempio n. 2
0
    public void UpdatePlayerLevelsLeaderoard(int level)
    {
        if (PlayFabClientAPI.IsClientLoggedIn())
        {
            if (string.IsNullOrEmpty(_levelsCountLeaderboardId))
            {
                Debug.LogWarning("PlayFabManager: LevelsCountLeaderboardId is not assigned! Please assign it.");
                return;
            }

            if (level > 0)
            {
                var statistic = new StatisticUpdate()
                {
                    StatisticName = _levelsCountLeaderboardId,
                    Value         = level
                };
                List <StatisticUpdate> statistics = new List <StatisticUpdate>();
                statistics.Add(statistic);

                UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest()
                {
                    Statistics = statistics
                };

                PlayFabClientAPI.UpdatePlayerStatistics(request, OnPlayersLevelStatisticsUpdated,
                                                        PlayerStatisticUpdateErrorCallback);
            }
        }
    }
Esempio n. 3
0
    void SendScoreRaw(string ID, ScoreCompare playerScore, Action <ScoreCompare[]> onSuccess, Action <PlayFabError> errorAction)
    {
        var item = new StatisticUpdate();

        item.Value         = playerScore.value;
        item.StatisticName = "Worldwide Scores";

        var request = new UpdatePlayerStatisticsRequest();

        request.Statistics = new List <StatisticUpdate>()
        {
            item
        };
        PlayFabClientAPI.UpdatePlayerStatistics(request,
                                                result =>
        {
            var r        = new PlayFab.ServerModels.UpdateUserDataRequest();
            r.Permission = PlayFab.ServerModels.UserDataPermission.Public;
            r.PlayFabId  = uniqueID;
            r.Data       = new Dictionary <string, string>()
            {
                { "SkinID", ((int)playerScore.usedSkin).ToString() },
                { "Location", playerScore.location }
            };

            PlayFabServerAPI.UpdateUserData(r, sucess => GetScores(onSuccess, errorAction),
                                            failure => { Debug.Log("Fail: " + failure.ErrorMessage); });
        },
                                                failure => { });
    }
Esempio n. 4
0
    public void UpdatePlayerLevelScoresLeaderboard(int level, int score)
    {
        if (PlayFabClientAPI.IsClientLoggedIn())
        {
            if (string.IsNullOrEmpty(_levelScoresLeaderboardId))
            {
                Debug.LogWarning("PlayFabManager: LevelScoresLeaderboardId is not assigned!Please assign it.");
                return;
            }

            if (level > 0 && score > 0)
            {
                string statisticName = string.Format(_levelScoresLeaderboardId, level);

                var statistic = new StatisticUpdate()
                {
                    StatisticName = statisticName,
                    Value         = score
                };
                List <StatisticUpdate> statistics = new List <StatisticUpdate>();
                statistics.Add(statistic);

                UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest()
                {
                    Statistics = statistics
                };

                PlayFabClientAPI.UpdatePlayerStatistics(request, OnPlayerLevelScoresStatisticsUpdatedResultCallback,
                                                        PlayerStatisticUpdateErrorCallback);
            }
        }
    }
Esempio n. 5
0
    public void SubmitScore(int scoreValue, UnityAction <bool> callback = null)
    {
        var update = new StatisticUpdate {
            StatisticName = Globals.PLAYFAB_SCORE_KEY,
            Value         = scoreValue
        };
        var list = new List <StatisticUpdate>();

        list.Add(update);
        var req = new UpdatePlayerStatisticsRequest();

        req.Statistics = list;
        PlayFabClientAPI.UpdatePlayerStatistics(req, result => {
            if (callback != null)
            {
                callback(true);
            }
        }, failure => {
            OnNetworkOperationFailure(failure);
            if (callback != null)
            {
                callback(false);
            }
        });
    }
Esempio n. 6
0
    private void addStat(List <StatisticUpdate> statList, string name, int value)
    {
        StatisticUpdate item = new StatisticUpdate();

        item.StatisticName = name;
        item.Value         = value;
        statList.Add(item);
    }
Esempio n. 7
0
    public void GetScore(Leaderboard board, Action <GetPlayerStatisticsResult> cb, Action <PlayFabError> errorCb)
    {
        StatisticUpdate statisticUpdate = new StatisticUpdate();

        statisticUpdate.StatisticName = PlayFabLeaderboard.GetBoardName(board, false);
        GetPlayerStatisticsRequest request = new GetPlayerStatisticsRequest
        {
            StatisticNames = new List <string>
            {
                board.ToString()
            }
        };

        PlayFabClientAPI.GetPlayerStatistics(request, cb, errorCb, null, null);
    }
        public UpdatePlayerStatisticsRequestBuilder WithStatsIncrease(string name)
        {
            if (_product.Statistics == null)
            {
                _product.Statistics = new List <StatisticUpdate>();
            }

            var stats = new StatisticUpdate()
            {
                StatisticName = name,
                Value         = 1
            };

            _product.Statistics.Add(stats);
            return(this);
        }
    public void UpdateStatistics()
    {
        List <StatisticUpdate> stat = new List <StatisticUpdate>();
        StatisticUpdate        item = new StatisticUpdate();

        item.StatisticName = "Kills";
        item.Value         = kills;
        stat.Add(item);

        var request = new UpdatePlayerStatisticsRequest {
            Statistics = stat
        };

        PlayFab.PlayFabClientAPI.UpdatePlayerStatistics(request, StatResult, OnPlayFabError);
        killsOld = kills;
    }
Esempio n. 10
0
    public void AddScore(Leaderboard board, int score, Action <UpdatePlayerStatisticsResult> cb, Action <PlayFabError> errorCb)
    {
        StatisticUpdate item = new StatisticUpdate
        {
            StatisticName = PlayFabLeaderboard.GetBoardName(board, false),
            Value         = score
        };
        UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest
        {
            Statistics = new List <StatisticUpdate>
            {
                item
            }
        };

        PlayFabClientAPI.UpdatePlayerStatistics(request, cb, errorCb, null, null);
    }
Esempio n. 11
0
    public void SaveStats()
    {
        // Create new request
        var request = new UpdatePlayerStatisticsRequest();

        // Statistics List
        request.Statistics = new List <StatisticUpdate>();
        // Create new value for statistics
        var stat = new StatisticUpdate {
            StatisticName = "Coins", Value = 5
        };

        // Add entry
        request.Statistics.Add(stat);
        // Send request to PlayfabAPI
        PlayFabClientAPI.UpdatePlayerStatistics(request, OnSetStatsSuccess, OnPlayFabError);
    }
Esempio n. 12
0
    public void storeScore()
    {
        List <StatisticUpdate> stats = new List <StatisticUpdate>();
        StatisticUpdate        score = new StatisticUpdate();

        score.StatisticName = "score";
        score.Value         = player_score;

        stats.Add(score);

        UpdatePlayerStatisticsRequest req = new UpdatePlayerStatisticsRequest();

        req.AuthenticationContext = authContext;
        req.Statistics            = stats;

        PlayFabClientAPI.UpdatePlayerStatistics(req, statsSuccessCallback, statsErrorCallback);
    }
Esempio n. 13
0
    // 점수 업데이트 함수
    public void SaveStats(int score)
    {
        // 새로운 request 생성
        var request = new UpdatePlayerStatisticsRequest();

        // statistics 리스트 생성
        request.Statistics = new List <StatisticUpdate>();
        // 점수 입력
        var stat = new StatisticUpdate {
            StatisticName = "score", Value = score
        };

        // request에 추가
        request.Statistics.Add(stat);
        // PlayFab API 호출
        PlayFabClientAPI.UpdatePlayerStatistics(request, OnSetStatsSuccess, OnPlayFabError);
    }
Esempio n. 14
0
    public void UpdateRankingScore()
    {
        var statisticUpdate = new StatisticUpdate
        {
            // ランキングの統計情報名
            StatisticName = "テストランキング",

            //スコア(int)
            Value = int.Parse(_scoreText.text),
        };

        var request = new UpdatePlayerStatisticsRequest {
            Statistics = new List <StatisticUpdate> {
                statisticUpdate
            },
        };

        Debug.Log($"スコアの更新開始, score:{int.Parse( _scoreText.text)}");
        PlayFabClientAPI.UpdatePlayerStatistics(request, OnUpdatePlayerStatisticsSuccess, OnUpdatePlayerStatisticsFailure);
    }
Esempio n. 15
0
    void SendScoreToRanking(int score, string sequenceName)
    {
        StatisticUpdate update = new StatisticUpdate {
            StatisticName = "test" + sequenceName,
            Value         = score
        };
        var request = new UpdatePlayerStatisticsRequest {
            Statistics = new List <StatisticUpdate> {
                update
            }
        };

        PlayFabClientAPI.UpdatePlayerStatistics(
            request,
            result => {
            OnSuccess();
        },
            OnError
            );
    }
Esempio n. 16
0
    public void SetPlayerLevel(int level)
    {
        NetworkDataManager.LatestReachedLevel = level;        //1.3.3
        List <StatisticUpdate> stUpdateList = new List <StatisticUpdate> ();
        StatisticUpdate        stUpd        = new StatisticUpdate();

        stUpd.StatisticName = "Level";
        stUpd.Value         = level;
        stUpdateList.Add(stUpd);

        UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest()
        {
            Statistics = stUpdateList
        };

        PlayFabClientAPI.UpdatePlayerStatistics(request, (result) => {
            Debug.Log("Successfully updated user level");
        }, (error) => {
            Debug.Log(error.ErrorDetails);
        });
    }
Esempio n. 17
0
        public void SetHighScore(int value)
        {
            List <StatisticUpdate> stUpdateList = new List <StatisticUpdate> ();
            StatisticUpdate        stUpd        = new StatisticUpdate();

            stUpd.StatisticName = "HighScore";
            stUpd.Value         = value;
            stUpdateList.Add(stUpd);

            UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest()
            {
                Statistics = stUpdateList
            };

            PlayFabClientAPI.UpdatePlayerStatistics(request, (result) =>
            {
                PlayerPrefs.SetInt("HighScore", value);
                Debug.Log("Successfully updated user score");
            }, (error) => {
                Debug.Log(error.ErrorDetails);
            });
        }
Esempio n. 18
0
    //	public static void SetPlayerScoreTotal () {//1.3.3
    //		int latestLevel = LevelsMap._instance.GetLastestReachedLevel ();
    //		for (int i = 1; i <= latestLevel; i++) {
    //			SetPlayerScore (i, PlayerPrefs.GetInt ("Score" + i, 0));//TODO sync Level_
    //		}
    //	}

    public void SetPlayerScore(int level, int score)
    {
        UpdatePlayerScoreFoLeadboard(score);

        List <StatisticUpdate> stUpdateList = new List <StatisticUpdate> ();
        StatisticUpdate        stUpd        = new StatisticUpdate();

        stUpd.StatisticName = "Level_" + level;
        stUpd.Value         = score;
        stUpdateList.Add(stUpd);

        UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest()
        {
            Statistics = stUpdateList
        };

        PlayFabClientAPI.UpdatePlayerStatistics(request, (result) => {
            Debug.Log("Successfully updated user score");
        }, (error) => {
            Debug.Log(error.ErrorDetails);
        });
    }
Esempio n. 19
0
    public void updateLeaderboardValue(int value)
    {
        List <StatisticUpdate> list  = new List <StatisticUpdate> ();
        StatisticUpdate        stats = new StatisticUpdate();

        //stats.StatisticName = "Players Level";
        stats.Value = value;
        list.Add(stats);

        UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest()
        {
            Statistics = list
        };

        PlayFabClientAPI.UpdatePlayerStatistics(request, (result) => {
            Debug.Log("update leaderboard succes!!");
        },
                                                (error) => {
            Debug.Log("Error updating leaderboard value:");
            Debug.Log(error.ErrorMessage);
            Debug.Log(error.ErrorDetails);
        });
    }
Esempio n. 20
0
    public void UploadScore(Action onSuccess, Action onFailure, int score)
    {
        Debug.Log("Try to UpLoading Score");

        List <StatisticUpdate> userStatistics = new List <StatisticUpdate>();
        StatisticUpdate        scoreInfo      = new StatisticUpdate()
        {
            StatisticName = "HighScore",
            Version       = null,
            Value         = score,
        };

        userStatistics.Add(scoreInfo);
        UpdatePlayerStatisticsRequest request = new UpdatePlayerStatisticsRequest()
        {
            Statistics = userStatistics
        };

        PlayFabClientAPI.UpdatePlayerStatistics(request,
                                                (result) => { UploadSuccess(onSuccess, result); },
                                                (error) => { UploadFail(onFailure, error); }
                                                );
    }
    public void UpdateScore(int score)
    {
        //Verifica se o usuário está logado no PlayFab, pois só é possível alterar o score caso ele esteja logado.
        if (FacebookAndPlayFabInfo.isLoggedOnPlayFab)
        {
            //Usado para passar o valor para o PlayFab. O nome do campo Score deve ser identico ao usado no Leadeboard
            //no site do PlayFab. Caso quisesssem armazenar o nome do jogador poderiam criar um Dictionary<string, string>

            if (stats == null)
            {
                stats = new StatisticUpdate();
                stats.StatisticName = "Score";
                stats.Value         = score;
            }
            else
            {
                stats.Value = stats.Value + score;
            }

            //Ao adicionar o valor para o servidor sempre é preciso definir uma chave ( nesse caso "Score") para identificar
            //o que é o dado que você está passando e o outro parâmetro é o valor.


            statsList.Add(stats);

            //Configura a chamada para atualizar o score no servidor.
            PlayFab.ClientModels.UpdatePlayerStatisticsRequest request = new PlayFab.ClientModels.UpdatePlayerStatisticsRequest();
            request.Statistics = statsList;

            //Utiliza o SDK do PlayFab para atualizar os dados. Informando a chamada e a função de callback de sucesso e erro.
            PlayFabClientAPI.UpdatePlayerStatistics(request, UpdateUserStatisticsSucessCallback, PlayFabErrorCallBack);
        }
        else
        {
            Debug.Log("Não é possível alterar o Score sem estar logado.");
        }
    }
    /// <summary>
    /// Sets up the info to sent to the MatchResultScreen
    /// </summary>
    /// <param name="p"></param>
    private void SetUpInfo(PlayerData p)
    {
        PlayerPanel pp = Instantiate(PlayerPanelClass);

        pp.GetComponent <PlayerPanel>().playerName.text = p.Name;
        pp.GetComponent <PlayerPanel>().crownImg.sprite = GetRightImg(p.place);

        pp.GetComponent <PlayerPanel>().firstWord.text  = (p.BestWords.ElementAtOrDefault(0) != null) ? p.BestWords[0].ToUpper() : "";
        pp.GetComponent <PlayerPanel>().secondWord.text = (p.BestWords.ElementAtOrDefault(1) != null) ? p.BestWords[1].ToUpper() : "";;
        pp.GetComponent <PlayerPanel>().thirdWord.text  = (p.BestWords.ElementAtOrDefault(2) != null) ? p.BestWords[2].ToUpper() : "";;

        pp.transform.SetParent(PlayerPanelHolder.transform, false);

        if (GameInstance.instance.IsMultiplayer && !p.localPlayer && !AccountManager.instance.AlreadyFriends(p.playfabId))
        {
            Button addFriend = pp.GetComponent <PlayerPanel>().addFriend;
            addFriend.gameObject.SetActive(true);
            addFriend.GetComponent <AddFriendBtnScript>().OnAddFriendBtnTouched = () =>
            {
                AccountManager.instance.AddFriend(p.playfabId);
                addFriend.GetComponentInChildren <Text>().text = I2.Loc.LocalizationManager.GetTranslation("friend_added_friend");
                addFriend.interactable = false;
            };
        }
        else if (AccountManager.instance.AlreadyFriends(p.playfabId))
        {
            pp.GetComponent <PlayerPanel>().alreadyFriendsImg.gameObject.SetActive(true);
        }

        StartCoroutine(AddTimeToPlayerScore(p, pp));

        if (p.localPlayer)
        {
            PlayFabClientAPI.WritePlayerEvent(new WriteClientPlayerEventRequest()
            {
                Body = new Dictionary <string, object>()
                {
                    { "PlayerScore", p.Points },
                    { "PlayerPlace", p.place },
                    { "PlayerPlacedWordCount", p.WordCount }
                },
                EventName = "player_finished_game"
            },
                                              result => Debug.Log("Success saving scores"),
                                              error => Debug.LogError(error.GenerateErrorReport()));

            #region statistics
            // Check if there are statistics present. If so, set previousScore & statisticsPresent to true
            int  previousScore              = 0;
            int? previousWins               = 0;
            int? gamesPlayed                = 0;
            int? totalScore                 = 0;
            int? wordCount                  = 0;
            int? AmountOfWordsPerMin        = 0;
            int? AmountOfWordLenghtOfTwelve = 0;
            bool statisticsPresent          = false;
            if (AccountManager.CurrentPlayer.Statistics.Count > 0)
            {
                statisticsPresent = true;
                if (GameInstance.instance.difficulty == Difficulty.Easy && AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "easy_score") != null)
                {
                    previousScore = AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "easy_score")
                                    .Value;
                }
                else if (GameInstance.instance.difficulty == Difficulty.Medium && AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "medium_score") != null)
                {
                    previousScore = AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "medium_score")
                                    .Value;
                }
                else if (GameInstance.instance.difficulty == Difficulty.Hard && AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "hard_score") != null)
                {
                    previousScore = AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "hard_score")
                                    .Value;
                }
                previousWins               = AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "Wins")?.Value;
                gamesPlayed                = AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "GamesPlayed")?.Value;
                totalScore                 = AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "TotalScore")?.Value;
                wordCount                  = AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "WordCount")?.Value;
                AmountOfWordsPerMin        = AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "AmountOfWordsPerMin")?.Value;
                AmountOfWordLenghtOfTwelve = AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "WordLengthOfTwelve")?.Value;
            }

            var updateStatisticsRequest = new UpdatePlayerStatisticsRequest();
            var statistics = new List <StatisticUpdate>();
            var statistic  = new StatisticUpdate();

            // if new points are more than other points, put the new points
            if (p.Points > previousScore || p.Points == previousScore || previousScore == 0)
            {
                if (GameInstance.instance.difficulty == Difficulty.Easy)
                {
                    statistic = new StatisticUpdate {
                        StatisticName = "easy_score", Value = (int)p.Points
                    };
                    statistics.Add(statistic);
                    if (previousScore == 0)
                    {
                        AccountManager.CurrentPlayer.Statistics = new List <StatisticModel>
                        {
                            new StatisticModel
                            {
                                Value = (int)p.Points,
                                Name  = "easy_score"
                            }
                        };
                    }
                    else
                    {
                        // If they are present, make sure the new score is added to currentPlayer
                        AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "easy_score").Value =
                            (int)p.Points;
                    }
                }
                else if (GameInstance.instance.difficulty == Difficulty.Medium)
                {
                    statistic = new StatisticUpdate {
                        StatisticName = "medium_score", Value = (int)p.Points
                    };
                    statistics.Add(statistic);
                    if (previousScore == 0)
                    {
                        AccountManager.CurrentPlayer.Statistics = new List <StatisticModel>
                        {
                            new StatisticModel
                            {
                                Value = (int)p.Points,
                                Name  = "medium_score"
                            }
                        };
                    }
                    else
                    {
                        // If they are present, make sure the new score is added to currentPlayer
                        AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "medium_score").Value =
                            (int)p.Points;
                    }
                }
                else if (GameInstance.instance.difficulty == Difficulty.Hard)
                {
                    statistic = new StatisticUpdate {
                        StatisticName = "hard_score", Value = (int)p.Points
                    };
                    statistics.Add(statistic);
                    if (previousScore == 0)
                    {
                        AccountManager.CurrentPlayer.Statistics = new List <StatisticModel>
                        {
                            new StatisticModel
                            {
                                Value = (int)p.Points,
                                Name  = "hard_score"
                            }
                        };
                    }
                    else
                    {
                        // If they are present, make sure the new score is added to currentPlayer
                        AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "hard_score").Value =
                            (int)p.Points;
                    }
                }
            }

            if (p.place == 1)
            {
                StatisticModel newModel = new StatisticModel();
                // if previousWins is not null, put previousWins + 1, else put 1
                statistic = new StatisticUpdate {
                    Value = previousWins + 1 ?? 1, StatisticName = "Wins"
                };
                statistics.Add(statistic);
                if (AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "Wins") != null)
                {
                    AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "Wins").Value++;
                }
                else
                {
                    AccountManager.CurrentPlayer.Statistics.Add(
                        new StatisticModel
                    {
                        Value = 1,
                        Name  = "Wins"
                    }
                        );
                }
            }

            statistic = new StatisticUpdate {
                Value = gamesPlayed + 1 ?? 1, StatisticName = "GamesPlayed"
            };
            statistics.Add(statistic);
            if (AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "GamesPlayed") != null)
            {
                AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "GamesPlayed").Value++;
            }
            else
            {
                AccountManager.CurrentPlayer.Statistics.Add(
                    new StatisticModel
                {
                    Value = 1,
                    Name  = "GamesPlayed"
                }
                    );
            }

            statistic = new StatisticUpdate
            {
                Value = totalScore + (int)p.Points ?? (int)p.Points, StatisticName = "TotalScore"
            };
            statistics.Add(statistic);
            if (AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "TotalScore") == null)
            {
                AccountManager.CurrentPlayer.Statistics.Add(
                    new StatisticModel
                {
                    Value = (int)p.Points,
                    Name  = "TotalScore"
                }
                    );
            }

            statistic = new StatisticUpdate
            {
                Value = wordCount + p.WordCount ?? p.WordCount, StatisticName = "WordCount"
            };
            statistics.Add(statistic);
            if (AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "WordCount") != null)
            {
                AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "WordCount").Value += p.WordCount;
            }
            else
            {
                AccountManager.CurrentPlayer.Statistics.Add(
                    new StatisticModel
                {
                    Value = p.WordCount,
                    Name  = "WordCount"
                }
                    );
            }


            statistic = new StatisticUpdate {
                StatisticName = "WordLengthOfTwelve", Value = p.WordCountTwelveLetters + (AmountOfWordLenghtOfTwelve ?? 0)
            };
            statistics.Add(statistic);

            // When statistics aren't present, set these to currentPlayer
            if (!statisticsPresent || AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "WordLengthOfTwelve") == null)
            {
                AccountManager.CurrentPlayer.Statistics = new List <StatisticModel>
                {
                    new StatisticModel
                    {
                        Value = p.WordCountTwelveLetters + (AmountOfWordLenghtOfTwelve ?? 0),
                        Name  = "WordLengthOfTwelve"
                    }
                };
            }
            else
            {
                // If they are present, make sure the new score is added to currentPlayer
                AccountManager.CurrentPlayer.Statistics.Find(model => model.Name == "WordLengthOfTwelve").Value = p.WordCountTwelveLetters + (AmountOfWordLenghtOfTwelve ?? 0);
            }

            int finalAmount;
            if (p.FinalWordCountPerMinute > AmountOfWordsPerMin)
            {
                finalAmount = p.FinalWordCountPerMinute;
            }
            else
            {
                finalAmount = AmountOfWordsPerMin ?? 0;
            }
            statistic = new StatisticUpdate {
                StatisticName = "AmountOfWordsPerMin", Value = finalAmount
            };
            statistics.Add(statistic);

            // When statistics aren't present, set these to currentPlayer
            if (!statisticsPresent)
            {
                AccountManager.CurrentPlayer.Statistics = new List <StatisticModel>
                {
                    new StatisticModel
                    {
                        Value = p.FinalWordCountPerMinute,
                        Name  = "AmountOfWordsPerMin"
                    }
                };
            }


            if (statistics.Count <= 0)
            {
                return;
            }
            updateStatisticsRequest.Statistics = statistics;
            PlayFabClientAPI.UpdatePlayerStatistics(updateStatisticsRequest, OnSuccess, OnFailure);
            #endregion
        }
    }