Example #1
0
        private void RequestPlayerInfoFromServer()
        {
            Debug.Log(TitleDescriptionButtonLinkData.LinkID);
            PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
            {
                FunctionName      = "GetPlayerStats",
                FunctionParameter = new
                {
                    playerId = TitleDescriptionButtonLinkData.LinkID
                },
                GeneratePlayStreamEvent = true,
            },
                                                result =>
            {
                // get Json object representing the Game State out of FunctionResult
                JsonObject jsonResult = (JsonObject)result.FunctionResult;

                // check if data exists
                if (jsonResult == null)
                {
                    Debug.Log("server failed to return data");
                }
                else
                {
                    string statsJSON = RPSCommon.InterpretCloudScriptData(jsonResult, "Stats");
                    PlayerStatsFromServer playerStatsFromServer = PlayerStatsFromServer.CreateFromJSON(statsJSON);
                    PlayerStats playerStats = new PlayerStats(playerStatsFromServer, TitleDescriptionButtonLinkData.Label);
                    UpdatePlayerUI(playerStats);
                }
            },
                                                error => Debug.LogError(error.GenerateErrorReport())
                                                );
        }
Example #2
0
 public PlayerStats(PlayerStatsFromServer serverData, string name)
 {
     playerName       = name;
     data.Rating      = serverData.Rating;
     data.TotalWLD    = new WinLoseDrawStats(serverData.Wins, serverData.Losses, serverData.Draws);
     data.RockWLD     = new WinLoseDrawStats(serverData.RockWins, serverData.RockLosses, serverData.RockDraws);
     data.PaperWLD    = new WinLoseDrawStats(serverData.PaperWins, serverData.PaperLosses, serverData.PaperDraws);
     data.ScissorsWLD = new WinLoseDrawStats(serverData.ScissorsWins, serverData.ScissorsLosses, serverData.ScissorsDraws);
 }