Exemple #1
0
    public void ConfirmModifyCurrency(bool add)
    {
        if (!string.IsNullOrEmpty(currencyType.text) && !string.IsNullOrEmpty(currencyNewValue.text))
        {
            int newCurrencyValue = int.Parse(currencyNewValue.text);

            if (add)
            {
                PlayFabAdminAPI.AddUserVirtualCurrency(new AddUserVirtualCurrencyRequest {
                    PlayFabId       = lastPlayerIdentifier.playerID,
                    VirtualCurrency = currencyType.text,
                    Amount          = newCurrencyValue
                },
                                                       result => {
                    Debug.Log("ADD CURRENCY OK: " + result.ToJson().ToString());
                    Inform(string.Format("Modified Currency for {0}\n\nLast Value: {1}\n\nNew Value: {2}",
                                         lastPlayerIdentifier.displayName, lastPlayerIdentifier.currencies,
                                         result.Balance + " " + currencyType.text));
                },
                                                       error => {
                    Debug.LogError("ADD CURRENCY FAILURE: " + error.ToString());
                    Inform("Add Currency Failed! " + error.ErrorMessage);
                });
            }
            else
            {
                PlayFabAdminAPI.SubtractUserVirtualCurrency(new SubtractUserVirtualCurrencyRequest {
                    PlayFabId       = lastPlayerIdentifier.playerID,
                    VirtualCurrency = currencyType.text,
                    Amount          = newCurrencyValue
                },
                                                            result => {
                    Debug.Log("REMOVE CURRENCY OK: " + result.ToJson().ToString());
                    Inform(string.Format("Modified Currency for {0}\n\nLast Value: {1}\n\nNew Value: {2}",
                                         lastPlayerIdentifier.displayName, lastPlayerIdentifier.currencies,
                                         result.Balance + " " + currencyType.text));
                },
                                                            error => {
                    Debug.LogError("REMOVE CURRENCY FAILURE: " + error.ToString());
                    Inform("REMOVE Currency Failed! " + error.ErrorMessage);
                });
            }
        }
        else
        {
            Inform("Fields cannot be empty!");
        }
    }