示例#1
0
    public void FilterResult(ExecuteCloudScriptResult result)
    {
        ClaimedRewards.Clear();
        JSONNode jsonResultPF = PlayFabSimpleJson.SerializeObject(result.FunctionResult);

        jsonResult = JSON.Parse(result.FunctionResult.ToString());

        Debug.Log("json result playfab " + jsonResultPF.ToString());
        Debug.Log("json result " + jsonResult.ToString());
        if ((jsonResult.Value.Equals("null") || result.Error != null))
        {
            status = FMRewardStatus.error;
            return;
        }

        /*{ "status":"success",
         * "rewards":
         * [{"achievement_key":"stages_created","reward_Key":"default_co_200","reward_type":"coins","amount":200}]
         * }
         */
        Debug.Log("function result  size" + jsonResult["rewards"].AsArray.Count);
        for (int i = 0; i < jsonResult["rewards"].AsArray.Count; i++)
        {
            string rewardKey  = jsonResult["rewards"].AsArray[i]["reward_Key"];
            string rewardType = jsonResult["rewards"].AsArray[i]["reward_type"];

            FMRewardType rewadType   = rewardType.Equals("item") ? FMRewardType.Item : FMRewardType.Currency;
            int          rewardValue = rewadType == FMRewardType.Currency ? jsonResult["rewards"].AsArray[i]["amount"].AsInt : 0;
            string       itemKey     = rewadType == FMRewardType.Item ? jsonResult["rewards"].AsArray[i]["item_key"].Value : "";

            //var ri = new FMRewardItem(rewardKey, rewardType, rewardValue, rewardValue);
            //ClaimedRewards.Add(ri);
        }
    }
示例#2
0
 private void OnCloudUpdateScript(ExecuteCloudScriptResult result)
 {
     // Cloud Script returns arbitrary results, so you have to evaluate them one step and one parameter at a time
     Debug.Log("OnCloudUpdateScript: Fired appropriately");
     requestSuccess  = true;
     requestReturned = true;
 }
        private void OnCloudScriptSubmit(ExecuteCloudScriptResult result)
        {
            if (postResultsToCloudscript && result != null)
            {
                string msg;
                if (result.Error == null)
                {
                    msg = "Results posted to Cloud Script successfully: " + PlayFabSettings.BuildIdentifier + ", " + clientInstance.authenticationContext.PlayFabId;
                }
                else
                {
                    msg = "Cloud Script returned, but got error:" + result.Error.Message;
                }

                textDisplay.text += "\n" + msg;
                Debug.Log(msg);
                if (result.Logs != null)
                {
                    foreach (var eachLog in result.Logs)
                    {
                        Debug.Log("Cloud Log: " + eachLog.Message);
                    }
                }
            }
            QuitTesting();
        }
示例#4
0
        void ResultCallback(ExecuteCloudScriptResult result)
        {
            if (result.FunctionResult == null)
            {
                var error = new PlayFabError()
                {
                    ErrorMessage = "Error with New Player Reward"
                };

                ErrorCallback(error);
            }
            else
            {
                var json = result.FunctionResult.ToString();

                var instance = JsonConvert.DeserializeObject <ResultData>(json);

                if (OnResult != null)
                {
                    OnResult(instance);
                }

                Respond(instance, null);
            }
        }
示例#5
0
    void OnCheckInCallback(ExecuteCloudScriptResult result)
    {
        // output any errors that happend within cloud script
        if (result.Error != null)
        {
            Debug.LogError(string.Format("{0} -- {1}", result.Error, result.Error.Message));
            return;
        }

        Debug.Log("CheckIn Results:");
        List <ItemInstance> grantedItems;

        if (result.FunctionResult != null)
        {
            var serializer = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer);
            grantedItems = serializer.DeserializeObject <List <ItemInstance> >(result.FunctionResult.ToString());

            Debug.Log(string.Format("You were granted {0} items:", grantedItems.Count));

            string output = string.Empty;
            foreach (var item in grantedItems)
            {
                output += string.Format("{0}: {1}\n", item.ItemId, item.Annotation);
            }
            Debug.Log(output);
        }
        else
        {
            Debug.Log("CheckIn Successful! No items granted.");
            foreach (var statement in result.Logs)
            {
                Debug.Log(statement.Message);
            }
        }
    }
示例#6
0
        /* IEnumerator TimerStack()
         * {
         *   while (true)
         *   {
         *       yield return new WaitForSeconds(3f);
         *       TimerProcessStacks_Elapsed();
         *   }
         * }*/


        private void onStackCallback(ExecuteCloudScriptResult result)
        {
            isWorking = false;
            bool success = false;
            CloudScriptResponse jsonResponse = null;

            if (result.Error == null && result.FunctionResult != null)
            {
                try
                {
                    jsonResponse = JsonConvert.DeserializeObject <CloudScriptResponse>(result.FunctionResult.ToString());
                    if (jsonResponse.ResponseCode == ResponseCode.Success)
                    {
                        success = true;
                    }
                }
                catch (Exception e)
                {
                    UnityEngine.Debug.Log("CloudScript Serialisation error:" + e.Message);
                }
            }

            if (!success)
            {
                if (OnDataMissMatchDetected != null)
                {
                    OnDataMissMatchDetected();
                }
            }
        }
示例#7
0
    /// <summary>
    /// updates the client array of user achievements
    /// </summary>
    public void UpdateUserAchievements(ExecuteCloudScriptResult result)
    {
        var       js        = JSON.Parse(result.FunctionResult.ToString());
        JSONArray jsonachvs = js["userAchievements"].AsArray;

        if (jsonachvs == null || jsonachvs.Count == 0)
        {
            return;
        }

        for (int i = 0; i < jsonachvs.Count; i++)
        {
            string            achName  = GetUserAchievementName(jsonachvs[i]);
            FMUserAchievement userAchv = Items.Find(x => x.Key.Equals(achName));
            for (int j = 0; j < jsonachvs[i][achName].AsArray.Count; j++)
            {
                if (userAchv.States[j] != (FMAchievementState)jsonachvs[i][achName][j].AsInt)
                {
                    userAchv.States[j] = (FMAchievementState)jsonachvs[i][achName][j].AsInt;
                    //update the json as well
                    UAjson[i][userAchv.Key][j].Value = ((int)userAchv.States[j]).ToString();
                }
            }
        }
    }
    void OnRedeemReferralCodeCallback(ExecuteCloudScriptResult result)
    {
        // output any errors that happend within cloud script
        if (result.Error != null)
        {
            Debug.LogError(string.Format("{0} -- {1}", result.Error, result.Error.Message));
            return;
        }

        List <ItemInstance> grantedItems = PlayFab.Json.JsonWrapper.DeserializeObject <List <ItemInstance> >(result.FunctionResult.ToString());

        if (grantedItems != null)
        {
            Debug.Log("SUCCESS!...\nYou Just Recieved:");
            string output = string.Empty;
            foreach (var itemInstance in grantedItems)
            {
                output += string.Format("\t {0} \n", itemInstance.DisplayName);
            }

            this.inventory.AddRange(grantedItems);
            SearchForReferralBadge();
            ShowReferredGroup();
            Debug.Log(output);
            foreach (var statement in result.Logs)
            {
                Debug.Log(statement.Message);
            }
        }
        else
        {
            Debug.LogError("An error occured when attemtpting to deserialize the granted items.");
        }
    }
示例#9
0
    //Gets the results of checkBattle cloudscript (UNIX time in millis until battle)
    void OnGetAttackTime(ExecuteCloudScriptResult result)
    {
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object     timeOfAttackObject;

        jsonResult.TryGetValue("timeOfAttack", out timeOfAttackObject);

        Debug.Log(timeOfAttack);

        if (timeOfAttackObject.ToString() == "noBattle")
        {
            Debug.Log("Work it");
            return;
        }

        if (timeOfAttackObject.ToString() == "cancelled")
        {
            timerPanel.SetActive(true);
            timeLeftTxt.text = "Attack cancelled";
            StopCoroutine("updateTime");
        }
        else
        {
            timerPanel.SetActive(true);
            //Convert object to long
            timeOfAttack = System.Convert.ToInt64(timeOfAttackObject);
            StartCoroutine("updateTime");
        }
    }
示例#10
0
 private void OutputCloudscriptError(ExecuteCloudScriptResult i_result)
 {
     if (i_result.Error != null)
     {
         string output = i_result.Error + ": " + i_result.Error.Message + " -> " + i_result.Error.StackTrace;
         MyMessenger.Instance.Send <LogTypes, string, string>(MyLogger.LOG_EVENT, LogTypes.Error, output, PLAYFAB);
     }
 }
示例#11
0
 /// <summary>
 /// make sure to set the action BEFORE calling Login()
 /// </summary>
 /// <param name="result"></param>
 public void OnUserAchievement(ExecuteCloudScriptResult result)
 {
     if (OnGetAchievement != null)
     {
         FMPlayfabUserAchievementResult fmAchievementResult = new FMPlayfabUserAchievementResult(result);
         OnGetAchievement(fmAchievementResult);
     }
 }
示例#12
0
 public static bool VerifyErrorFreeCloudScriptResult(ExecuteCloudScriptResult result)
 {
     if (result.Error != null)
     {
         OnPlayFabCallbackError(string.Format("{0}: ERROR: [{1}] -- {2}", result.FunctionName, result.Error.Error, result.Error.Message), PlayFabAPIMethods.ExecuteCloudScript, MessageDisplayStyle.error);
     }
     return(result.Error == null);
 }
示例#13
0
 void OnLoginBonus(ExecuteCloudScriptResult result)
 {
     if (OnResult != null)
     {
         FMPlayfabLoginBonusResult bonusResult = new FMPlayfabLoginBonusResult(result);
         OnResult(bonusResult);
     }
 }
示例#14
0
    private static void OnCloudUpdateStats(ExecuteCloudScriptResult result)
    {
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object     messageValue;

        jsonResult.TryGetValue("messageValue", out messageValue);
        Debug.Log((string)messageValue);
    }
示例#15
0
        private void CloudScriptGenericHwCallback(ExecuteCloudScriptResult result)
        {
            var testContext = (UUnitTestContext)result.CustomData;
            var hwResult    = result.FunctionResult as HelloWorldWrapper;

            testContext.NotNull(hwResult);
            testContext.StringEquals("Hello " + PlayFabId + "!", hwResult.messageValue);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#16
0
        private void CloudScriptErrorCallback(ExecuteCloudScriptResult result)
        {
            var testContext = (UUnitTestContext)result.CustomData;

            testContext.IsNull(result.FunctionResult, "The result should be null because the function did not return properly.");
            testContext.NotNull(result.Error, "The error should be defined because the function throws an error.");
            testContext.StringEquals(result.Error.Error, "JavascriptException", result.Error.Error);
            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
示例#17
0
    private void OnCloudCheckRewards(ExecuteCloudScriptResult result)
    {
        Debug.Log("Rewards checked" + result.FunctionResult + " error:" + result.Error
                  + " log:" + result.Logs);

        Rewards = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <String, UserDataRecord> >(PlayFab.Json.JsonWrapper.SerializeObject(result.FunctionResult));
        Debug.Log("Rewards checked data:" + Rewards);
        RewardsReady = true;
    }
示例#18
0
    public void OnCloudUpdateStats(ExecuteCloudScriptResult result)
    {
        // Cloud Script returns arbitrary results, so you have to evaluate them one step and one parameter at a time
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object messageValue;
        jsonResult.TryGetValue("messageValue", out messageValue); // Note how "messageValue" directly corresponds to the JSON values set in Cloud Script

        osTrackController.UploadStatsComplete();
    }
    // OnCloudHelloWorld defined in the next code block

    private static void OnCloudUpdatePlayerScore(ExecuteCloudScriptResult result)
    {
        // CloudScript returns arbitrary results, so you have to evaluate them one step and one parameter at a time
        //Debug.Log(JsonWrapper.SerializeObject(result.FunctionResult));
        //JsonObject jsonResult = (JsonObject)result.FunctionResult;
        //object messageValue;
        //jsonResult.TryGetValue("messageValue", out messageValue); // note how "messageValue" directly corresponds to the JSON values set in CloudScript
        //Debug.Log((string)messageValue);
    }
示例#20
0
    private static void OnCloudUpdatePlayerStats(ExecuteCloudScriptResult result)
    {
        Debug.Log(PlayFab.PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).SerializeObject(result.FunctionResult));
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object     messageValue;

        jsonResult.TryGetValue("messageValue", out messageValue);
        Debug.Log((string)messageValue);
    }
示例#21
0
    private static void OnCloudUpdateStats(ExecuteCloudScriptResult result)
    {
        // CloudScript returns arbitrary results, so you have to evaluate them one step and one parameter at a time
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object     messageValue;

        jsonResult.TryGetValue("messageValue", out messageValue); // note how "messageValue" directly corresponds to the JSON values set in CloudScript
        Debug.Log((string)messageValue);
    }
示例#22
0
    private static void OnUpdateCharacterStatisticsSuccess(ExecuteCloudScriptResult result)
    {
        if (!PF_Bridge.VerifyErrorFreeCloudScriptResult(result))
        {
            return;
        }

        PF_Bridge.RaiseCallbackSuccess("", PlayFabAPIMethods.UpdateCharacterStatistics, MessageDisplayStyle.none);
    }
示例#23
0
    /// <summary>
    /// Callback after
    /// </summary>
    /// <param name="result">Result.</param>
    private static void OnSavePlayerDataSuccess(ExecuteCloudScriptResult result)
    {
        if (!PF_Bridge.VerifyErrorFreeCloudScriptResult(result))
        {
            return;
        }

        PF_Bridge.RaiseCallbackSuccess("Player Info Saved", PlayFabAPIMethods.SavePlayerInfo, MessageDisplayStyle.none);
    }
    private void OnCloudHelloWorld(ExecuteCloudScriptResult result)
    {
        // CloudScript returns arbitrary results, so you have to evaluate them one step and one parameter at a time
        Debug.Log(PlayFabSimpleJson.SerializeObject(result.FunctionResult));
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object     messageValue;

        jsonResult.TryGetValue("messageValue", out messageValue); // note how "messageValue" directly corresponds to the JSON values set in CloudScript
        Debug.Log((string)messageValue);
    }
示例#25
0
    // OnCloudHelloWorld defined in the next code block
    private static void OnCloudUpdateStats(ExecuteCloudScriptResult result)
    {
        // Cloud Script returns arbitrary results, so you have to evaluate them one step and one parameter at a time
        Debug.Log(PlayFab.PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).SerializeObject(result.FunctionResult));
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object     messageValue;

        jsonResult.TryGetValue("messageValue", out messageValue); // note how "messageValue" directly corresponds to the JSON values set in Cloud Script
        Debug.Log((string)messageValue);
    }
示例#26
0
    void AddCoinsCallback(ExecuteCloudScriptResult result)
    {
        if (result.Error != null)
        {
            Debug.LogError(string.Format("{0} -- {1}", result.Error, result.Error.Message));
            return;
        }

        GetCurrencyValues();
    }
示例#27
0
    private static void OnUpdateUserStatisticsSuccess(ExecuteCloudScriptResult result)
    {
        if (!PF_Bridge.VerifyErrorFreeCloudScriptResult(result))
        {
            return;
        }

        PF_Bridge.RaiseCallbackSuccess("User Statistics Uploaded", PlayFabAPIMethods.UpdateUserStatistics, MessageDisplayStyle.none);
        GetCharacterStatistics(); // Refresh stats that we just updated
    }
示例#28
0
    // OnCloudHelloWorld defined in the next code block

    private static void OnCloudUpdateStats(ExecuteCloudScriptResult result)
    {
        // CloudScript returns arbitrary results, so you have to evaluate them one step and one parameter at a time
        Debug.Log(result.FunctionResult.ToString() as string);  // original line follows :  Debug.Log(JsonWrapper.SerializeObject(result.FunctionResult));
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object     messageValue;

        jsonResult.TryGetValue("messageValue", out messageValue); // note how "messageValue" directly corresponds to the JSON values set in CloudScript
        Debug.Log((string)messageValue);
    }
示例#29
0
    //Gets the result of the battle and displays it on screen
    void OnGetResult(ExecuteCloudScriptResult result)
    {
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        object     resultOfBattle;

        jsonResult.TryGetValue("result", out resultOfBattle);

        timerPanel.SetActive(true);
        timeLeftTxt.text = resultOfBattle.ToString();
    }
示例#30
0
 public void OnRewardsClaimed(ExecuteCloudScriptResult result)
 {
     //update client user achievements
     if (OnClaimReward != null)
     {
         FMPlayfabRewardsResult res = new FMPlayfabRewardsResult(result);
         OnClaimReward(res);
         UpdateAchievementsAfterPlayfabCall();
     }
 }