Ejemplo n.º 1
0
 public void GetCurrencyBalance(string key, Action <bool, float> callBack)
 {
     StartCoroutine(
         SendRequest(
             null,
             Method.GET,
             $"contracts/currency/balances",
             new Dictionary <string, string> {
         { "key", key }
     },
             null,
             (string json, bool callCompleted) =>
     {
         if (callCompleted)
         {
             try
             {
                 if (json.Contains("_fixed_"))
                 {
                     callBack?.Invoke(true, CurrencyBalanceFloatData.GetValue(json));
                 }
                 else
                 {
                     callBack?.Invoke(true, CurrencyBalanceIntData.GetValue(json));
                 }
             }
             catch (Exception ex)
             {
                 Debug.LogError($"GetCurrencyBalance: Failed json string: {json}, ex: {ex.Message}");
                 callBack?.Invoke(false, -1);
             }
         }
         else
         {
             callBack?.Invoke(false, -1);
         };
     }));
 }
        public static float GetValue(string json)
        {
            CurrencyBalanceIntData currencyBalance = JsonUtility.FromJson <CurrencyBalanceIntData>(json);

            return(currencyBalance.value);
        }