private void GetUserStatsCallback(GetUserStatisticsResult result) { lastReceivedMessage = "User Stats Received"; if (!result.UserStatistics.TryGetValue(TEST_STAT_NAME, out testStatReturn)) { testStatReturn = TEST_STAT_BASE; } }
/// <summary> /// Callback used when user statistics load scceeds. /// </summary> /// <param name="result">User statistics info.</param> void OnUserStatisticsLoaded(GetUserStatisticsResult result) { int kills; result.UserStatistics.TryGetValue(GameConstants.killsStatsKey, out kills); int wins; result.UserStatistics.TryGetValue(GameConstants.winsStatsKey, out wins); AccountManager.instance.UpdateUserStatistics(kills, wins); }
private static void GetUserStatisticsCallback(GetUserStatisticsResult result) { string playFabId = ((GetUserStatisticsRequest)result.Request).PlayFabId; UserModel userModel; if (PfSharedModelEx.serverUsers.TryGetValue(playFabId, out userModel)) { userModel.userStatistics = result.UserStatistics; } }
private void GetUserStatsCallback2(GetUserStatisticsResult result) { var testContext = (UUnitTestContext)result.CustomData; int actualValue; if (!result.UserStatistics.TryGetValue(TEST_DATA_KEY, out actualValue)) { actualValue = 0; // Default if the data isn't present } testContext.IntEquals(_testInteger, actualValue); testContext.EndTest(UUnitFinishState.PASSED, null); }
// private void OnPlayFabGetUserInfo(GetUserCombinedInfoResult result) // { // Debug.Log ("Received Player Info"); // // // Get player's XP // UserDataRecord xp = null; // result.Data.TryGetValue ("XP", out xp); // // // If player has no XP value, initialize it to 0 // if (xp == null) { // UpdatePlayerXP (0); // userData.xp = 0; // } else { // userData.xp = int.Parse (xp.Value); // } // Debug.Log ("User XP = " + userData.xp); // } private void OnPlayFabGetUserStatistics(GetUserStatisticsResult result) { Debug.Log("Received Player Stats"); int xp; if (!result.UserStatistics.TryGetValue("XP", out xp)) { xp = 0; UpdatePlayerXP(xp); } userData.xp = xp; Debug.Log("User XP = " + userData.xp); }
private void GetUserStatsCallback1(GetUserStatisticsResult result) { var testContext = (UUnitTestContext)result.CustomData; if (!result.UserStatistics.TryGetValue(TEST_DATA_KEY, out _testInteger)) { _testInteger = 0; // Default if the data isn't present } _testInteger = (_testInteger + 1) % 100; // This test is about the Expected value changing - but not testing more complicated issues like bounds var updateRequest = new UpdateUserStatisticsRequest { UserStatistics = new Dictionary <string, int> { { TEST_DATA_KEY, _testInteger } } }; PlayFabClientAPI.UpdateUserStatistics(updateRequest, PlayFabUUnitUtils.ApiActionWrapper <UpdateUserStatisticsResult>(testContext, UpdateUserStatsCallback), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext); }
// callback on successful GetUserStats request void OnGetUserStatsSuccess(GetUserStatisticsResult result) { // some logic for determineing if the player's team changed. if (result.UserStatistics.ContainsKey("BluTeamJoinedCount") && this.userStats.ContainsKey("BluTeamJoinedCount")) { if (result.UserStatistics["BluTeamJoinedCount"] > this.userStats["BluTeamJoinedCount"]) { this.team = "Blu"; Debug.Log(result.UserStatistics["BluTeamJoinedCount"] + " : " + this.userStats["BluTeamJoinedCount"]); } } else if (result.UserStatistics.ContainsKey("BluTeamJoinedCount") && !this.userStats.ContainsKey("BluTeamJoinedCount")) { if (this.userStats.Count != 0) { this.team = "Blu"; Debug.Log(result.UserStatistics["BluTeamJoinedCount"] + " : blue"); } } if (result.UserStatistics.ContainsKey("RedTeamJoinedCount") && this.userStats.ContainsKey("RedTeamJoinedCount")) { if (result.UserStatistics["RedTeamJoinedCount"] > this.userStats["RedTeamJoinedCount"]) { this.team = "Red"; Debug.Log(result.UserStatistics["RedTeamJoinedCount"] + " : " + this.userStats["RedTeamJoinedCount"]); } } else if (result.UserStatistics.ContainsKey("RedTeamJoinedCount") && !this.userStats.ContainsKey("RedTeamJoinedCount")) { if (this.userStats.Count != 0) { this.team = "Red"; Debug.Log(result.UserStatistics["RedTeamJoinedCount"] + " : red"); } } // save user stats for game useage this.userStats = result.UserStatistics; }
private static void GetUserStatisticsCallback(GetUserStatisticsResult result) { PfSharedModelEx.globalClientUser.userStatistics = result.UserStatistics; }