Beispiel #1
0
    public static string GetString(this IJSonObject json, string key)
    {
        IJSonObject _json = json.Get(key);

        if (!_json.IsEmpty() || !_json.ToString().IsNull())
        {
            return(_json.ToString());
        }

        Error("GetString", ERROR_KEY_NOT_FOUND, key);

        return("");
    }
    protected void handleGetAdList(string error, WWW conn)
    {
        // Reseta as listas
        resetLists();

        IJSonObject data = "{}".ToJSon();

        if (!conn.text.IsEmpty())
        {
            data = conn.text.ToJSon();
        }

        if (error != null || conn.error != null || data.IsEmpty() || data.IsError())
        {
            defaultList();
            return;
        }

        Save.Set("__ads:arr", data.ToString());

        // Salva as preferencias de cada ad
        banner       = fromJson(data[ADS_TYPE_BANNER], default_banner.value);
        interstitial = fromJson(data[ADS_TYPE_INTERSTITIAL], default_interstitial.value);
        popup        = fromJson(data[ADS_TYPE_POPUP], default_popup.value);
        video        = fromJson(data[ADS_TYPE_VIDEO], default_video.value);
        widget       = fromJson(data[ADS_TYPE_WIDGET], default_widget.value);
    }
Beispiel #3
0
    public static char GetChar(this IJSonObject json, string key)
    {
        IJSonObject _json = json.Get(key);

        if (!_json.IsEmpty())
        {
            return(_json.ToString().ToChar());
        }

        Error("GetChar", ERROR_KEY_NOT_FOUND, key);

        return(default(char));
    }
Beispiel #4
0
    public static Quaternion GetQuaternion(this IJSonObject json, string key)
    {
        IJSonObject _json = json.Get(key);

        if (!_json.IsEmpty())
        {
            return(_json.ToString().ToQuaternion());
        }

        Error("GetQuarternion", ERROR_KEY_NOT_FOUND, key);

        return(default(Quaternion));
    }
Beispiel #5
0
    public static Vector4 GetVector4(this IJSonObject json, string key)
    {
        IJSonObject _json = json.Get(key);

        if (!_json.IsEmpty())
        {
            return(_json.ToString().ToVector4());
        }

        Error("GetVector4", ERROR_KEY_NOT_FOUND, key);

        return(default(Vector4));
    }
Beispiel #6
0
    public static bool GetBool(this IJSonObject json, string key)
    {
        IJSonObject _json = json.Get(key);

        if (!_json.IsEmpty())
        {
            return(_json.ToString().ToBool());
        }

        Error("GetBool", ERROR_KEY_NOT_FOUND, key);

        return(default(bool));
    }
Beispiel #7
0
    public static int GetInt(this IJSonObject json, string key)
    {
        IJSonObject _json = json.Get(key);

        if (!_json.IsEmpty())
        {
            return(_json.ToString().ToInt32());
        }

        Error("GetInt", ERROR_KEY_NOT_FOUND, key);

        return(default(int));
    }
Beispiel #8
0
    public static double GetDouble(this IJSonObject json, string key)
    {
        IJSonObject _json = json.Get(key);

        if (!_json.IsEmpty())
        {
            return(_json.ToString().ToDouble());
        }

        Error("GetDouble", ERROR_KEY_NOT_FOUND, key);

        return(default(float));
    }
Beispiel #9
0
    public static System.DateTime ToDateTime(this IJSonObject json)
    {
        System.DateTime date = default(System.DateTime);
        try
        {
            date = json.DateTimeValue;
        }
        catch
        {
            Error("ToDateTime", ERROR_INVALID_DATETIME, json.ToString());
        }

        return(date);
    }
Beispiel #10
0
    // Callback chamado ao receber as informacoes da versao atual, comparando com a ultima versao do jogo
    void OnCheckVersion(string error, IJSonObject data)
    {
        // Se o usuario ja estiver com a ultima versao do jogo, retornar
        if (isUpdatedVersion)
        {
            return;
        }

        // Se houver algum erro, tentar novamente e retornar
        if (error != null || data == null || data.IsEmpty() || data.IsError() || data.ToString() == "Version check failed!")
        {
            CheckVersion();
            return;
        }

        // Pega a ultima versao obrigatoria (force update) e a ultima versao em geral
        float last   = data.Get("last").GetFloat("version");
        float update = data.Get("update").GetFloat("version");

        // Se a versao do usuario for menor que a versao obrigatoria, força usuario a atualizar
        if (appVersion < update)
        {
            string description = data.Get("update").GetString("description");
            // Up Top Fix Me
            //game_native.showMessage(appName, description, BUTTON_UPDATE_YES);
            return;
        }
        else
        {
            isUpdatedVersion = true;
        }
        // Se a versao do usuario for menor que a ultima versao, apenas perguntar se o usuario deseja atualizar
        if (appVersion < last)
        {
            string description = data.Get("update").GetString("description");

            // Up Top Fix Me
            Flow.game_native.showMessageOkCancel(this, "ConfirmCheck", NativeCallback, "", appName, (description != null && description != "") ? description: MESSAGE_VERSION_OLD, BUTTON_UPDATE_YES, BUTTON_UPDATE_NO);
        }
    }
Beispiel #11
0
    public static System.DateTime GetDateTime(this IJSonObject json, string key)
    {
        IJSonObject _json = json.Get(key);

        if (!_json.IsEmpty())
        {
            System.DateTime date = default(System.DateTime);
            try
            {
                date = _json.DateTimeValue;
            }
            catch
            {
                Error("GetDateTime", ERROR_INVALID_DATETIME, json.ToString());
            }

            return(date);
        }

        Error("GetDateTime", ERROR_KEY_NOT_FOUND, key);

        return(default(System.DateTime));
    }
	void OnReceiveSettings(string error, IJSonObject data)
	{
		//Debug.Log(error);
		//Debug.Log(data);
		if (error != null || data.IsEmpty() || data.IsError())
			return;
		
		for (int i = 0; i < data.Count; i++)
		{
			string key = (data[i].Contains("setting")) ? (pre + data[i].GetString("setting")) : default(string);
			string value = (data[i].Contains("value")) ? data[i].GetString("value") : default(string);
			string type = (data[i].Contains("type")) ? data[i].GetString("type") : default(string);
			
			if (!key.IsEmpty() && data != null && data.ToString() != "")
			{
				if (type == "string") Save.Set(key, value);
				else if (type == "int") Save.Set(key, value.ToInt32());
				else if (type == "float") Save.Set(key, value.ToFloat());
				else if (type == "double") Save.Set(key, value.ToDouble());
				else if (type == "bool") Save.Set(key, value.ToBool());
				else if (type == "Vector2") Save.Set(key, value.ToVector2());
				else if (type == "Vector3") Save.Set(key, value.ToVector3());
				else if (type == "Vector4") Save.Set(key, value.ToVector4());
				else if (type == "Quaternion") Save.Set(key, value.ToQuaternion());
				
				else if (type == "string (array)") Save.Set(key, value);
				else if (type == "int (array)") Save.Set(key, value.ToArrayInt32());
				else if (type == "float (array)") Save.Set(key, value.ToArrayFloat());
				else if (type == "double (array)") Save.Set(key, value.ToArrayDouble());
				else if (type == "bool (array)") Save.Set(key, value.ToArrayBool());
				else if (type == "Vector2 (array)") Save.Set(key, value.ToArrayVector2());
				else if (type == "Vector3 (array)") Save.Set(key, value.ToArrayVector3());
				else if (type == "Vector4 (array)") Save.Set(key, value.ToArrayVector4());
				else if (type == "Quaternion (array)") Save.Set(key, value.ToArrayQuaternion());
			}
		}
	}
Beispiel #13
0
 public static bool ToBool(this IJSonObject json)
 {
     return(json.ToString().ToBool());
 }
Beispiel #14
0
	// Callback chamado ao receber as informacoes da versao atual, comparando com a ultima versao do jogo
	void OnCheckVersion(string error, IJSonObject data)
    {
		// Se o usuario ja estiver com a ultima versao do jogo, retornar
		if (isUpdatedVersion)
            return;
		
		// Se houver algum erro, tentar novamente e retornar
		if (error != null || data == null || data.IsEmpty() || data.IsError() || data.ToString() == "Version check failed!")
		{
			CheckVersion();
			return;
		}
		
		// Pega a ultima versao obrigatoria (force update) e a ultima versao em geral
		float last = data.Get("last").GetFloat("version");
		float update = data.Get("update").GetFloat("version");
		
		// Se a versao do usuario for menor que a versao obrigatoria, força usuario a atualizar
		if (appVersion < update)
		{
			string description = data.Get("update").GetString("description");
			// Up Top Fix Me
			//game_native.showMessage(appName, description, BUTTON_UPDATE_YES);
			return;
		}
		else
		{
			isUpdatedVersion = true;
		}
		// Se a versao do usuario for menor que a ultima versao, apenas perguntar se o usuario deseja atualizar
		if (appVersion < last)
		{
			string description = data.Get("update").GetString("description");
			
			// Up Top Fix Me
			Flow.game_native.showMessageOkCancel(this, "ConfirmCheck", NativeCallback, "", appName,(description != null && description != "") ? description: MESSAGE_VERSION_OLD,BUTTON_UPDATE_YES, BUTTON_UPDATE_NO);
		}
	}
Beispiel #15
0
    private void OnReceiveTotal(string error, IJSonObject data, object state)
    {
        CoinsConnection connection = (CoinsConnection)state;

        if (connection.callback != null)
        {
            connection.callback(connection.userId, (!data.IsNull() && !data.IsError()) ? data.ToString().ToInt32() : 0);
        }
    }
Beispiel #16
0
 public static int ToInt32(this IJSonObject json)
 {
     return(json.ToString().ToInt32());
 }
    void OnReceiveSettings(string error, IJSonObject data)
    {
        //Debug.Log(error);
        //Debug.Log(data);
        if (error != null || data.IsEmpty() || data.IsError())
        {
            return;
        }

        for (int i = 0; i < data.Count; i++)
        {
            string key   = (data[i].Contains("setting")) ? (pre + data[i].GetString("setting")) : default(string);
            string value = (data[i].Contains("value")) ? data[i].GetString("value") : default(string);
            string type  = (data[i].Contains("type")) ? data[i].GetString("type") : default(string);

            if (!key.IsEmpty() && data != null && data.ToString() != "")
            {
                if (type == "string")
                {
                    Save.Set(key, value);
                }
                else if (type == "int")
                {
                    Save.Set(key, value.ToInt32());
                }
                else if (type == "float")
                {
                    Save.Set(key, value.ToFloat());
                }
                else if (type == "double")
                {
                    Save.Set(key, value.ToDouble());
                }
                else if (type == "bool")
                {
                    Save.Set(key, value.ToBool());
                }
                else if (type == "Vector2")
                {
                    Save.Set(key, value.ToVector2());
                }
                else if (type == "Vector3")
                {
                    Save.Set(key, value.ToVector3());
                }
                else if (type == "Vector4")
                {
                    Save.Set(key, value.ToVector4());
                }
                else if (type == "Quaternion")
                {
                    Save.Set(key, value.ToQuaternion());
                }

                else if (type == "string (array)")
                {
                    Save.Set(key, value);
                }
                else if (type == "int (array)")
                {
                    Save.Set(key, value.ToArrayInt32());
                }
                else if (type == "float (array)")
                {
                    Save.Set(key, value.ToArrayFloat());
                }
                else if (type == "double (array)")
                {
                    Save.Set(key, value.ToArrayDouble());
                }
                else if (type == "bool (array)")
                {
                    Save.Set(key, value.ToArrayBool());
                }
                else if (type == "Vector2 (array)")
                {
                    Save.Set(key, value.ToArrayVector2());
                }
                else if (type == "Vector3 (array)")
                {
                    Save.Set(key, value.ToArrayVector3());
                }
                else if (type == "Vector4 (array)")
                {
                    Save.Set(key, value.ToArrayVector4());
                }
                else if (type == "Quaternion (array)")
                {
                    Save.Set(key, value.ToArrayQuaternion());
                }
            }
        }
    }
Beispiel #18
0
 public static bool IsError(this IJSonObject json)
 {
     return(json.ToString() == ERROR_INVALID_JSON);
 }
Beispiel #19
0
 public static bool IsEmpty(this IJSonObject json)
 {
     return(json == null || json.IsNull() | json.ToString() == ERROR_EMPTY_JSON || json.ToString().IsEmpty());
 }
Beispiel #20
0
 public static float ToFloat(this IJSonObject json)
 {
     return(json.ToString().ToFloat());
 }
Beispiel #21
0
 public static char ToChar(this IJSonObject json)
 {
     return(json.ToString().ToChar());
 }
Beispiel #22
0
 public static Color ToColor(this IJSonObject json)
 {
     return(json.ToString().ToColor());
 }
Beispiel #23
0
 public static Quaternion ToQuaternion(this IJSonObject json)
 {
     return(json.ToString().ToQuaternion());
 }
Beispiel #24
0
 public static Vector4 ToVector4(this IJSonObject json)
 {
     return(json.ToString().ToVector4());
 }
Beispiel #25
0
	private void OnReceiveTotal(string error, IJSonObject data, object state)
	{
		CoinsConnection connection = (CoinsConnection)state;
		if (connection.callback != null)
			connection.callback(connection.userId, (!data.IsNull() && !data.IsError()) ? data.ToString().ToInt32() : 0);
	}
Beispiel #26
0
 public static double ToDouble(this IJSonObject json)
 {
     return(json.ToString().ToDouble());
 }