public void CardUsed(int coinsUsed) { int newCoins = playerDataSaver.GetCoinsAvailable() - coinsUsed; playerDataSaver.SetCoinsAvailable(newCoins); EnableCards(); PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() { FunctionName = "UpdatePlayerCoins", FunctionParameter = new { cloudCoinsAvailable = newCoins }, GeneratePlayStreamEvent = true, }, result => Debug.Log("Sent " + playerDataSaver.GetCoinsAvailable() + " coins to cloudscript"), error => Debug.Log(error.GenerateErrorReport())); OnValuesAdjusted(newCoins); }
public void ReductionUsed() { int newCoins = playerDataSaver.GetCoinsAvailable() - sliderController.coinsUsed; playerDataSaver.SetCoinsAvailable(newCoins); PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() { FunctionName = "UpdatePlayerCoins", FunctionParameter = new { cloudCoinsAvailable = newCoins }, GeneratePlayStreamEvent = true, }, result => Debug.Log("Sent " + newCoins + " coins to cloudscript"), error => Debug.Log(error.GenerateErrorReport())); OnValuesAdjusted(newCoins); sliderController.ResetSlider(); }
private void OnRegisterSuccess(RegisterPlayFabUserResult result) { playerDataSaver.SetUsername(username); playerDataSaver.SetEmail(email); playerDataSaver.SetPassword(password); playerDataSaver.SetCountry(countryDropdown.selectedText.text); playerDataSaver.SetAvatar(avatarDropdown.selectedText.text); playerDataSaver.SetIsGuest(0); playerDataSaver.SetProgressLevel(1); playerDataSaver.SetWasteCollected(0); playerDataSaver.SetRecycleCollected(0); playerDataSaver.SetCoinsAvailable(0); SetInitialPlayerStats(); SetPlayerData(); myID = result.PlayFabId; if (currentBuildLevel == 0) { StartCoroutine(LoggingProcessSucceeded()); } }
public void GetPlayerStats() { PlayFabClientAPI.GetPlayerStatistics( new GetPlayerStatisticsRequest(), result => { foreach (var eachStat in result.Statistics) { switch (eachStat.StatisticName) { case "ProgressLevel": progressLevel = eachStat.Value; playerInfo.PlayerCurrentLevel = progressLevel; playerDataSaver.SetProgressLevel(progressLevel); break; case "WasteCollected": wasteCollected = eachStat.Value; playerInfo.PlayerWaste = wasteCollected; playerDataSaver.SetWasteCollected(wasteCollected); break; case "RecycleCollected": recycleCollected = eachStat.Value; playerInfo.PlayerRecycle = recycleCollected; playerDataSaver.SetRecycleCollected(recycleCollected); break; case "RubbishCollected": rubbishCollected = eachStat.Value; playerInfo.PlayerRubbish = rubbishCollected; playerDataSaver.SetRubbishCollected(rubbishCollected); break; case "CoinsAvailable": coinsAvailable = eachStat.Value; playerInfo.PlayerCoins = coinsAvailable; playerDataSaver.SetCoinsAvailable(coinsAvailable); break; default: break; } if (playerInfo.RubbishPlace != null) { if (eachStat.StatisticName == (playerInfo.RubbishPlace + " isPlace")) { rubbishInPlace = eachStat.Value; playerInfo.RubbishInPlace = eachStat.Value; } else if (eachStat.StatisticName == playerInfo.RubbishDistrict + " isDistrict") { rubbishInDistrict = eachStat.Value; playerInfo.RubbishInDistrict = eachStat.Value; } else if (eachStat.StatisticName == playerInfo.RubbishRegion + " isRegion") { rubbishInRegion = eachStat.Value; playerInfo.RubbishInRegion = eachStat.Value; } else if (eachStat.StatisticName == (playerInfo.RubbishCountry) + " isCountry") { rubbishInCountry = eachStat.Value; playerInfo.RubbishInCountry = eachStat.Value; } } else { GetLocationDataOfRubbish(); GetPlayerStats(); } } }, error => Debug.LogError(error.GenerateErrorReport())); }