// Verifica se a conexao foi bem sucedida
    private static void handleConnection(string error, IJSonObject data, System.Object state)
    {
        string id = state.ToString();

        // Obtem a conexao retornada
        PConn conn = null;

        lock (connections)
        {
            if (connections.ContainsKey(id))
            {
                conn = connections[id];
            }
        }

        // Se nao ha conexao, termina
        if (conn == null)
        {
            return;
        }

        // Se houve erro, libera a conexao e termina
        if (error != null)
        {
            conn.release();
            return;
        }

        // Remove e libera a conexao
        removeConnection(id);
        conn.release();
    }
    public void OnShareStage(string error, IJSonObject data)
    {
        if (error != null)
        {
            Debug.Log(error);

            Flow.game_native.showMessage("Error", "Please check your internet connection then try again", "Ok");
            scroll.transform.gameObject.SetActive(false);
            EraseFriendsList();
        }
        else
        {
            Debug.Log(data);
            Debug.Log("dupliquei o estopedo");

            currentCustomStage.id = data.Int32Value;
            Flow.UpdateXML();

            //currentCustomStage.id = data["stageID"].Int32Value;

            Flow.game_native.showMessage("Stage Sent", "You can check the online ranking of your stage on the 'Challenges' Menu", "Ok");
            scroll.transform.gameObject.SetActive(false);
            EraseFriendsList();

            UIPanelManager.instance.BringIn("ChallengesScenePanel", UIPanelManager.MENU_DIRECTION.Backwards);
        }
    }
        private void LoadJsonData()
        {
            var jsonReader = new JSonReader();

            _jsonAccountData = jsonReader.ReadAsJSonObject(File.ReadAllText(@"Resources\accounts.json"));
            _jsonBalanceData = jsonReader.ReadAsJSonObject(File.ReadAllText(@"Resources\accountbalances.json"));
        }
Example #4
0
    void HandleUserLogoutConnection(string error, IJSonObject data)
    {
        Flow.game_native.stopLoading();
        if (error != null)
        {
            Flow.game_native.showMessage("Error", error);
        }
        else
        {
            Flow.OnLogoutFromServer();

            firstNameField.Text = firstNamePlaceholder;
            lastNameField.Text  = lastNamePlaceholder;
            countryField.Text   = locationPlaceholder;
            maleFemaleToggle.SetState(0);
            emailField.Text     = "Email";
            dayField.Text       = dayPlaceholder;
            monthField.Text     = monthPlaceholder;
            yearField.Text      = yearPlaceholder;
            facebookButton.Text = "Login with Facebook";

            gamesScroll.ClearList(true);

            UIPanelManager.instance.BringIn("MenuScenePanel", UIPanelManager.MENU_DIRECTION.Backwards);
        }
    }
Example #5
0
 private void sendToCallback(string error, IJSonObject data)
 {
     if (callback != null)
     {
         callback(error, data);
     }
 }
Example #6
0
    void CreateContainer(IJSonObject item)
    {
        containerCounter++;
        GameObject g = scroll.CreateItem(rankingsPrefab).gameObject;

        g.transform.FindChild("Name").GetComponent <SpriteText>().Text = item["name"].StringValue;
        g.transform.FindChild("Time").GetComponent <SpriteText>().Text = "Time: " + item["time"].StringValue;
        //g.transform.FindChild("Deaths").GetComponent<SpriteText>().Text = "Deaths: " + item["deaths"].StringValue;
        g.transform.FindChild("Matches").GetComponent <SpriteText>().Text = "Tries: " + item["tries"].StringValue;
        g.transform.FindChild("Ranking").GetComponent <SpriteText>().Text = containerCounter.ToString();
        if (!item["deaths"].IsNull)
        {
            switch (item["deaths"].Int32Value)
            {
            case 0:
                g.transform.FindChild("Star1").gameObject.SetActive(true);
                g.transform.FindChild("Star2").gameObject.SetActive(true);
                g.transform.FindChild("Star3").gameObject.SetActive(true);
                break;

            case 1:
                g.transform.FindChild("Star1").gameObject.SetActive(true);
                g.transform.FindChild("Star2").gameObject.SetActive(true);
                break;

            case 2:
                g.transform.FindChild("Star1").gameObject.SetActive(true);
                break;
            }
        }
    }
        /// <summary>
        /// Gets the 'channel' field of the bayeux message or null if not invalid format.
        /// </summary>
        internal static string GetChannel(IJSonObject o)
        {
            if (o == null)
            {
                return(null);
            }

            if (!o.IsEnumerable)
            {
                return(null);
            }

            if (o.IsArray)
            {
                foreach (var item in o.ArrayItems)
                {
                    if (item.IsEnumerable && !item.IsArray)
                    {
                        return(item["channel", (string)null].StringValue);
                    }
                }

                // an empty array or no JSON objects items of this array...
                return(null);
            }

            return(o["channel", (string)null].StringValue);
        }
Example #8
0
	void HandleEndGame(string error, IJSonObject data)
	{
		Flow.game_native.stopLoading();
		
		if(error!=null)
		{
			Flow.game_native.showMessage("Error", error);
			return;
		}
		
		Debug.Log(data);
		//Application.LoadLevel("GamePlay");
		
		//Flow.currentGame.id = data["gameID"].Int32Value;
		
		foreach(IJSonObject score in data.ArrayItems)
			Flow.currentGame.myTotalScore += score.Int32Value;
		
		Debug.Log( Flow.currentGame.myTotalScore);
		
		if(Flow.currentMode == GameMode.SinglePlayer)
		{
			Flow.nextPanel = PanelToLoad.WinLose;
		}
		else
		{
			Flow.nextPanel = PanelToLoad.BattleStatus;
		}
		
		Application.LoadLevel("Mainmenu");
	}
Example #9
0
    void OnGetRanking(string error, IJSonObject data)
    {
        if (error != null)
        {
            Debug.Log(error);
        }
        else
        {
            Debug.Log(data);
            foreach (IJSonObject item in data.ArrayItems)
            {
                if (containerCounter < maximumContainers)
                {
                    CreateContainer(item);
                }
            }
        }

        if (containerCounter == 0)
        {
            noChallengers.Text = "No Challengers Yet";
        }
        else
        {
            noChallengers.Text = "";
        }
    }
Example #10
0
    // Checa se o usuario tem a versao atual do jogo
    IEnumerator CheckVersion()
    {
        if (!isUpdatedVersion)
        {
#if UNITY_IPHONE
            //string platform = (Mobile.IsMobile()) ? Mobile.GetOS().ToString() : "";
            string platform = "Apple";
#elif UNITY_ANDROID
            string platform = "Android";
#else
            string platform = "";
#endif

            if (platform != "")
            {
                checkingVersion = true;
                WWW data = new WWW(Flow.URL_BASE + "login/version.php", new WWWForm().Add("platform", platform).Add("app_id", appId));
                yield return(data);

                if (!Info.HasConnection() || data.error == null || data.text != "Version check failed!")
                {
                    IJSonObject json = data.text.ToJSon();
                    OnCheckVersion(null, json);
                }
                else
                {
                    StartCoroutine(CheckVersion());
                }
            }
        }
        yield return(true);
    }
Example #11
0
 /// <summary>
 /// Init constructor.
 /// </summary>
 public BayeuxException(string message, BayeuxRequest request, BayeuxResponse response, IJSonObject responseObject)
     : base(message)
 {
     Request      = request;
     Response     = response;
     JSonResponse = responseObject;
 }
 /// <summary>
 /// Init constructor.
 /// </summary>
 public BayeuxException(string message, BayeuxRequest request, BayeuxResponse response, IJSonObject responseObject)
     : base(message)
 {
     Request = request;
     Response = response;
     JSonResponse = responseObject;
 }
    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);
    }
        protected override void ReadOptionalFields(IJSonObject input)
        {
            // reset field values:
            SupportedConnectionTypes = BayeuxConnectionTypes.None;

            // read additional data:
            if (input.Contains("supportedConnectionTypes"))
            {
                IJSonObject supportedTypes = input["supportedConnectionTypes"];

                if (supportedTypes == null)
                {
                    throw new MissingMemberException("Missing 'supportedConnectionTypes' field");
                }

                if (!supportedTypes.IsArray)
                {
                    throw new FormatException("Expected supportedConnectionTypes to be an array");
                }

                BayeuxConnectionTypes types = BayeuxConnectionTypes.None;

                foreach (IJSonObject connectionType in supportedTypes.ArrayItems)
                {
                    types |= BayeuxConnectionTypesHelper.Parse(connectionType.StringValue);
                }
            }
        }
Example #15
0
    void OnGetCustomGames(string error, IJSonObject data)
    {
        if (error != null)
        {
            Debug.Log(error);
        }
        else
        {
            Debug.Log(data);

            newPanel.transform.FindChild("NewScroll").GetComponent <UIScrollList>().ClearList(true);
            oldPanel.transform.FindChild("OldScroll").GetComponent <UIScrollList>().ClearList(true);

            Flow.customGames = new List <CustomStage>();
            foreach (IJSonObject item in data.ArrayItems)
            {
                CreateChallengeContainerImproved(item, data);
            }

            if (swapToRanking)
            {
                RealQuickSwapToRanking();
            }
        }
    }
Example #16
0
    /*void ClearText(UITextField field)
     * {
     *      Debug.Log("vaaaaaai");
     *      field.Text = "";
     * }*/

    GameObject CreateFriendContainer(IJSonObject friend)
    {
        GameObject t = GameObject.Instantiate(friendPrefab) as GameObject;

        t.GetComponent <Friend>().SetFriend(
            friend["user_id"].ToString(),
            friend["facebook_id"].ToString(),
            friend["name"].ToString(),
            friend["from_facebook"].BooleanValue? FriendshipStatus.FACEBOOK: FriendshipStatus.STANDALONE,
            friend["is_playing"].BooleanValue
            //null,
            );

        t.transform.FindChild("Name").GetComponent <SpriteText>().Text = friend["name"].ToString();

        if (t.GetComponent <Friend>().status == FriendshipStatus.FACEBOOK)
        {
            t.transform.FindChild("FacebookIcon").gameObject.SetActive(true);
        }
        else
        {
            t.transform.FindChild("StandaloneIcon").gameObject.SetActive(true);
        }

        return(t);
    }
Example #17
0
 public void Read(IJSonObject input)
 {
     ID     = input["ID"].GuidValue;
     Name   = input["Name"].StringValue;
     Age    = input["Age"].Int32Value;
     Salary = input["Salary"].DoubleValue;
 }
Example #18
0
 void HandleChangePassword(string error, IJSonObject data)
 {
     Debug.Log(error);
     Debug.Log(data);
     if (error != null)
     {
         changePasswordMessage.Text = error;
         if (error == "Please inform your password." || error == "Your current password is incorrect.")
         {
             changePasswordOldPassword.SetColor(new Color(135f / 255f, 70f / 255f, 70f / 255f, 1));
         }
         else if (error == "Please inform a new password." || error == "Your new password is too short.")
         {
             changePasswordNewPassword.SetColor(new Color(135f / 255f, 70f / 255f, 70f / 255f, 1));
         }
         else if (error == "Your passwords are different.")
         {
             changePasswordNewPassword.SetColor(new Color(135f / 255f, 70f / 255f, 70f / 255f, 1));
             changePasswordConfirmPassword.SetColor(new Color(135f / 255f, 70f / 255f, 70f / 255f, 1));
         }
     }
     else
     {
         Save.Set(PlayerPrefsKeys.PASSWORD.ToString(), changePasswordNewPassword.Text, true);
         CloseChangePasswordDialog();
         Flow.game_native.showMessage("Success", "Your password has been changed! We've sent you a confirmation e-mail.");
     }
 }
Example #19
0
        public static void CheckResponseError(IJSonObject e)
        {
            if (e == null)
            {
                return;
            }

            if (e.Contains("message"))
            {
                if (e["message"].StringValue.Equals("Please specify a correct Application Id."))
                {
                    Deployment.Current.Dispatcher.BeginInvoke(
                        () =>
                    {
                        var res = MessageBox.Show((string)Application.Current.Resources["VersionKeyErrorMessage"],
                                                  (string)Application.Current.Resources["GeneralErrorTitle"],
                                                  MessageBoxButton.OK);

                        if (res == MessageBoxResult.OK || res == MessageBoxResult.None)
                        {
                            Application.Current.Terminate();
                        }
                    });
                }
            }
        }
        protected override void ReadOptionalFields(IJSonObject input)
        {
            // reset field values:
            SubscriptionChannel = null;

            if (input.Contains("subscription"))
                SubscriptionChannel = input["subscription"].StringValue;
        }
Example #21
0
	public static IJSonObject Empty()
	{
		if (ExtensionJSon.empty != null)
			return ExtensionJSon.empty;
		
		ExtensionJSon.empty = ERROR_EMPTY_JSON.ToJSon();
		return ExtensionJSon.empty;
	}
Example #22
0
	void OnUpdateOfflineItems(string error, IJSonObject data)
	{
		if(error != null) Debug.Log(error);
		else
		{
			Debug.Log("meu deus do ceu: "+data);
		}
	}
 private string ReadSharedFieldsSingleRequest(IJSonObject r)
 {
     ClientID = r["clientId", ClientID].StringValue;
     if (r.Contains("ext"))
     {
         Token = r["ext"]["token", Token].StringValue;
     }
     return(r["id", (string)null].StringValue);
 }
 /// <summary>
 /// Init constructor.
 /// </summary>
 public BayeuxConnectionEventArgs(BayeuxConnection connection, HttpStatusCode statusCode, string statusDescription, string data, IJSonObject message, BayeuxResponse response)
 {
     Connection = connection;
     StatusCode = statusCode;
     StatusDescription = statusDescription;
     Data = data;
     Message = message;
     Response = response;
 }
        private void UpdateSingleResponse(IJSonObject request, IJSonObject response, string id)
        {
            if (response == null)
            {
                return;
            }

            // update response 'id' and 'clientId' fields:
            if (!response.IsMutable)
            {
                return;
            }

            var mutableResponse = response.AsMutable;

            if (mutableResponse == null || !mutableResponse.IsEnumerable)
            {
                return;
            }

            if (id == null)
            {
                mutableResponse.Remove("id");
            }
            else
            {
                mutableResponse.SetValue("id", id);
            }

            mutableResponse.SetValue("clientId", ClientID);

            // update response 'token' field:
            var responseExtObject = mutableResponse["ext", (IJSonObject)null];

            if (responseExtObject != null && responseExtObject.IsMutable)
            {
                responseExtObject.AsMutable.SetValue("token", Token);
            }

            // send update notification for a request that is an array of bayeux messages,
            // or if allowed, for the first message from that array:
            if (!AllowUpdateNotificationWithFirstMessageItemOnly || request == null || !request.IsEnumerable || !request.IsArray)
            {
                Event.Invoke(UpdateResponse, this, new RecordedBayeuxDataSourceUpdateEventArgs(this, request, mutableResponse));
            }
            else
            {
                foreach (var item in request.ArrayItems)
                {
                    Event.Invoke(UpdateResponse, this, new RecordedBayeuxDataSourceUpdateEventArgs(this, item, mutableResponse));
                    return;
                }

                // in case it's empty array:
                Event.Invoke(UpdateResponse, this, new RecordedBayeuxDataSourceUpdateEventArgs(this, null, mutableResponse));
            }
        }
Example #26
0
    private void handleBadgeReset(string error, IJSonObject data)
    {
        if (error != null)
        {
            return;
        }

        EtceteraBinding.setBadgeCount(0);
    }
Example #27
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);
        }
    }
Example #28
0
 /// <summary>
 /// Init constructor.
 /// </summary>
 public BayeuxConnectionEventArgs(BayeuxConnection connection, HttpStatusCode statusCode, string statusDescription, string data, IJSonObject message, BayeuxResponse response)
 {
     Connection        = connection;
     StatusCode        = statusCode;
     StatusDescription = statusDescription;
     Data     = data;
     Message  = message;
     Response = response;
 }
        internal RecordedBayeuxDataSourceUpdateEventArgs(RecordedBayeuxDataSource dataSource, IJSonObject request, IJSonMutableObject response)
        {
            if (dataSource == null)
                throw new ArgumentNullException("dataSource");

            DataSource = dataSource;
            Request = request;
            Response = response;
        }
    // Obtem as informacoes dos amigos do usuario
    void HandleGetFriends(string error, IJSonObject data, object counter_o)
    {
        Debug.Log(data);
        int counter = (int)counter_o;

        Flow.game_native.stopLoading();
        UIManager.instance.blockInput = false;

        if (error != null || data == null)
        {
            if (counter > 0)
            {
                GameJsonAuthConnection conn = new GameJsonAuthConnection(Flow.URL_BASE + "login/friends/list.php", HandleGetFriends);
                conn.connect(null, counter - 1);
                return;
            }

            Flow.game_native.showMessage("Error", error);
            return;
        }

        string allLetter     = "";
        string playingLetter = "";

        if (data.Count > 0)
        {
            allLetter = data[0]["name"].StringValue.Substring(0, 1).ToUpper();
            GameObject firstL = GameObject.Instantiate(letterPrefab) as GameObject;

            firstL.transform.FindChild("Letter").GetComponent <SpriteText>().Text = allLetter.ToUpper();
            scroll.AddItem(firstL);
        }

        foreach (IJSonObject friend in data.ArrayItems)
        {
            GameObject allContainer = CreateFriendContainer(friend);

            if (friend["name"].StringValue.Substring(0, 1).ToUpper() != allLetter)
            {
                allLetter = friend["name"].StringValue.Substring(0, 1).ToUpper();
                GameObject l = GameObject.Instantiate(letterPrefab) as GameObject;
                l.transform.FindChild("Letter").GetComponent <SpriteText>().Text = allLetter.ToUpper();
                scroll.AddItem(l);
            }
            scroll.AddItem(allContainer);
        }

        if (data.Count == 0)
        {
            noFriendsLabel.gameObject.SetActive(true);
        }
        else
        {
            noFriendsLabel.gameObject.SetActive(false);
        }
    }
Example #31
0
    public static IJSonObject Empty()
    {
        if (ExtensionJSon.empty != null)
        {
            return(ExtensionJSon.empty);
        }

        ExtensionJSon.empty = ERROR_EMPTY_JSON.ToJSon();
        return(ExtensionJSon.empty);
    }
        /// <summary>
        /// Init constructor.
        /// </summary>
        public TokenDataString(string token, JSonReaderTokenType type, object value, IJSonObject jValue)
            : base(type)
        {
            if (string.IsNullOrEmpty(token))
                throw new ArgumentNullException("token");

            Token = token;
            Value = value;
            ValueAsJSonObject = jValue;
        }
        protected override void ReadOptionalFields(IJSonObject input)
        {
            // reset field values:
            SubscriptionChannel = null;

            if (input.Contains("subscription"))
            {
                SubscriptionChannel = input["subscription"].StringValue;
            }
        }
    void GetShareData(string error, IJSonObject data)
    {
        tries++;
        Debug.Log(tries);
        if (error != null)
        {
            Debug.Log(error);
            tries = 0;
            if (tempCallback != null)
            {
                tempCallback("Connection Error. Please try again later.", tempFace, tempParams, null);
            }
            tempFace     = "";
            tempCallback = null;
            tempParams   = new Dictionary <string, string>();
        }
        else
        {
            if (data["result"].ToString() == "shared")
            {
                Debug.Log("deu shared..." + data);
                tries = 0;
                if (tempCallback != null)
                {
                    tempCallback(null, tempFace, tempParams, data["post_id"].StringValue);
                }

                tempFace     = "";
                tempCallback = null;
                tempParams   = new Dictionary <string, string>();
            }
            else
            {
                Debug.Log("deu not shared...");
                if (tries > 5)
                {
                    Debug.Log("ja tentou mais de 5 vezes");
                    tries = 0;
                    if (tempCallback != null)
                    {
                        tempCallback("Connection Error. Please try again later.", tempFace, tempParams, null);
                    }

                    tempFace     = "";
                    tempCallback = null;
                    tempParams   = new Dictionary <string, string>();
                }
                else
                {
                    Debug.Log("tentou menos, tentar de novo!");
                    Invoke("promptAgain", 1f);
                }
            }
        }
    }
Example #35
0
 private void SetValue(string name, IJSonObject value)
 {
     if (Data.ContainsKey(name))
     {
         Data[name] = value;
     }
     else
     {
         Data.Add(name, value);
     }
 }
Example #36
0
 void OnUpdateOfflineItems(string error, IJSonObject data)
 {
     if (error != null)
     {
         Debug.Log(error);
     }
     else
     {
         //Debug.Log("meu deus do ceu: "+data);
     }
 }
Example #37
0
        internal RecordedBayeuxDataSourceUpdateEventArgs(RecordedBayeuxDataSource dataSource, IJSonObject request, IJSonMutableObject response)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }

            DataSource = dataSource;
            Request    = request;
            Response   = response;
        }
Example #38
0
 public void BuyingConfirmation(string error, IJSonObject data)
 {
     if (error != null)
     {
         Debug.Log(error);
     }
     else
     {
         // registrou itens e coins no server, nao precisa fazer nada.
     }
 }
Example #39
0
        /// <summary>
        /// Init constructor.
        /// </summary>
        public BayeuxAdvice(IJSonObject data)
        {
            if (data == null)
                throw new ArgumentNullException("data");

            if (data.Contains("reconnect"))
                Reconnect = ParseReconnect(data["reconnect"].StringValue);

            if (data.Contains("interval"))
                Interval = data["interval"].Int32Value;

            Data = data;
        }
Example #40
0
	public static void save(IJSonObject data)
	{
		if (!Save.HasKey(PlayerPrefsKeys.TOKEN_EXPIRATION.ToString()))
		{
			Save.Set(PlayerPrefsKeys.TOKEN_EXPIRATION.ToString(), data["expiration"].StringValue,true);
			Save.Set(PlayerPrefsKeys.TOKEN.ToString(), data["token"].StringValue,true);
		}
		
		else
		{
			System.DateTime old_date = System.DateTime.Parse(Save.GetString(PlayerPrefsKeys.TOKEN_EXPIRATION.ToString()));
			System.DateTime new_date = System.DateTime.Parse(data["expiration"].StringValue);
			
			if (new_date > old_date) 
			{
				Save.Set(PlayerPrefsKeys.TOKEN.ToString(), data["token"].StringValue,true);
			}
		}
	}
        /// <summary>
        /// Gets the 'channel' field of the bayeux message or null if not invalid format.
        /// </summary>
        internal static string GetChannel(IJSonObject o)
        {
            if (o == null)
                return null;

            if (!o.IsEnumerable)
                return null;

            if (o.IsArray)
            {
                foreach (var item in o.ArrayItems)
                {
                    if (item.IsEnumerable && !item.IsArray)
                        return item["channel", (string)null].StringValue;
                }

                // an empty array or no JSON objects items of this array...
                return null;
            }

            return o["channel", (string)null].StringValue;
        }
Example #42
0
	void OnGetCustomGames(string error, IJSonObject data)
	{
		if(error != null)
		{
			Debug.Log(error);
		}
		else
		{
			Debug.Log(data);
			
			newPanel.transform.FindChild("NewScroll").GetComponent<UIScrollList>().ClearList(true);
			oldPanel.transform.FindChild("OldScroll").GetComponent<UIScrollList>().ClearList(true);
			
			Flow.customGames = new List<CustomStage>();
			foreach(IJSonObject item in data.ArrayItems)
			{
				CreateChallengeContainerImproved(item, data);
			}
			
			if(swapToRanking) RealQuickSwapToRanking();
		}
	}
	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());
			}
		}
	}
        protected override void ReadOptionalFields(IJSonObject input)
        {
            // reset field values:
            SupportedConnectionTypes = BayeuxConnectionTypes.None;

            // read additional data:
            if (input.Contains("supportedConnectionTypes"))
            {
                IJSonObject supportedTypes = input["supportedConnectionTypes"];

                if (supportedTypes == null)
                    throw new MissingMemberException("Missing 'supportedConnectionTypes' field");

                if (!supportedTypes.IsArray)
                    throw new FormatException("Expected supportedConnectionTypes to be an array");

                BayeuxConnectionTypes types = BayeuxConnectionTypes.None;

                foreach (IJSonObject connectionType in supportedTypes.ArrayItems)
                {
                    types |= BayeuxConnectionTypesHelper.Parse(connectionType.StringValue);
                }
            }
        }
Example #45
0
	void HandlePushNotifications(string error, IJSonObject data)
	{
		if(error != null)
		{
			Flow.game_native.showMessage("Error", error);
		}
		else
		{
			Flow.game_native.showMessage("Push Notifications",data.StringValue);
			
			if(data.StringValue == "Push notifications enabled!") 
			{
				pushOn.gameObject.SetActive(true);
				pushOff.gameObject.SetActive(false);
				Save.Set(PlayerPrefsKeys.PUSHNOTIFICATIONS.ToString(),"On", true);
			}
			else if(data.StringValue == "Push notifications disabled!") 
			{
				pushOn.gameObject.SetActive(false);
				pushOff.gameObject.SetActive(true);
				Save.Set(PlayerPrefsKeys.PUSHNOTIFICATIONS.ToString(), "Off", true);
			}
		}
	}
 void IJSonMutableObject.SetValue(IJSonObject value)
 {
     Data = value != null && value.BooleanValue;
 }
Example #47
0
	void HandleChoose(string error, IJSonObject data)
	{
		//GameGUI.game_native.stopLoading();
		
		if (error != null)
		{
			//GameGUI.game_native.showMessage("Error", error);
			return;
		}
		
		id = data["user_id"].ToString();
		Debug.Log("e o id novo do cara é..."+id);
		
		AssignDataToFlow();
	}
 void IJSonMutableObject.SetValue(IJSonObject value)
 {
     Data = value != null ? value.Int32Value : 0;
 }
Example #49
0
	void handleDeleteFriendConnection(string error, IJSonObject data)
	{
		Flow.game_native.stopLoading();

		if (error != null)
		{
			Flow.game_native.showMessage("Error", error);
			return;
		}

		// Remove o amigo da lista all e da lista playing independentemente se você clicou no delete de uma ou de outra.
		
		if(gameObject.GetComponent<UIListItemContainer>().GetScrollList().transform.tag == "FriendList")
		{
			UIScrollList playingScroll = gameObject.GetComponent<UIListItemContainer>().GetScrollList().transform.parent.FindChild("PlayingList").GetComponent<UIScrollList>();
						
			for(int i = 0 ; i < playingScroll.Count ; i++)
			{
				if(playingScroll.GetItem(i).transform.GetComponent<Friend>() && id == playingScroll.GetItem(i).transform.GetComponent<Friend>().id)
				{
					// se for 2, soh tem um container e uma letra
					if(playingScroll.Count != 2)
					{
						// se o proximo cara nao tiver o component friend, indica que ele é uma letra
						if(!playingScroll.GetItem(i+1).transform.GetComponent<Friend>())
						{
							// se o cara anterior nao tiver o component friend, indica que ele é uma letra
							if(!playingScroll.GetItem(i-1).transform.GetComponent<Friend>())
							{
								// remove a letra passada pois o container sendo removido é o unico da letra
								playingScroll.RemoveItem(i-1,true);
								// o cara passou a ter o indice da letra, remove ele
								playingScroll.RemoveItem(i-1,true);
								
								break;
							}
						}
					}
					else
					{
						// remove letra
						playingScroll.RemoveItem(0, true);
						// o cara passou a ter o indice da letra, remove ele
						playingScroll.RemoveItem(0, true);
						
						break;
					}
					
					// remove o container
					playingScroll.RemoveItem(i,true);
					break;
				}
			}
		}
		else
		{
			UIScrollList allScroll = gameObject.GetComponent<UIListItemContainer>().GetScrollList().transform.parent.FindChild("FriendList").GetComponent<UIScrollList>();
			
			for(int i = 0 ; i < allScroll.Count ; i++)
			{
				if(allScroll.GetItem(i).transform.GetComponent<Friend>() && id == allScroll.GetItem(i).transform.GetComponent<Friend>().id)
				{
					// se for 2, soh tem um container e uma letra
					if(allScroll.Count != 2)
					{
						// se o proximo cara nao tiver o component friend, indica que ele é uma letra
						if(!allScroll.GetItem(i+1).transform.GetComponent<Friend>())
						{
							// se o cara anterior nao tiver o component friend, indica que ele é uma letra
							if(!allScroll.GetItem(i-1).transform.GetComponent<Friend>())
							{
								// remove a letra passada pois o container sendo removido é o unico da letra
								allScroll.RemoveItem(i-1,true);
								// o cara passou a ter o indice da letra, remove ele
								allScroll.RemoveItem(i-1,true);
								
								break;
							}
						}
					}
					else
					{
						// remove a letra
						allScroll.RemoveItem(0, true);
						// o cara passou a ter o indice da letra, remove ele
						allScroll.RemoveItem(0, true);
						
						break;
					}
					
					// remove o container
					allScroll.RemoveItem(i,true);
					break;
				}
			}
		}
		
		// se for 2, soh tem um container e uma letra
		if(gameObject.GetComponent<UIListItemContainer>().GetScrollList().Count != 2)
		{
			// se o proximo cara nao tiver o component friend, indica que ele é uma letra
			if(!gameObject.GetComponent<UIListItemContainer>().GetScrollList().GetItem(GetComponent<UIListItemContainer>().Index+1).transform.GetComponent<Friend>())
			{
				// se o cara anterior nao tiver o component friend, indica que ele é uma letra
				if(!gameObject.GetComponent<UIListItemContainer>().GetScrollList().GetItem(GetComponent<UIListItemContainer>().Index-1).transform.GetComponent<Friend>())
				{
					// remove a letra passada pois o container sendo removido é o unico da letra
					gameObject.GetComponent<UIListItemContainer>().GetScrollList().RemoveItem(GetComponent<UIListItemContainer>().Index-1,true);
					// o cara passou a ter o indice da letra, remove ele (MAS NESSE CASO O EZGUI ATUALIZOU O INDEX)
					gameObject.GetComponent<UIListItemContainer>().GetScrollList().RemoveItem(GetComponent<UIListItemContainer>().Index,true);
					
					return;
				}
			}
		}
		else
		{
			// remove a letra
			gameObject.GetComponent<UIListItemContainer>().GetScrollList().RemoveItem(0, true);
			// o cara passou a ter o indice da letra, remove ele
			gameObject.GetComponent<UIListItemContainer>().GetScrollList().RemoveItem(0, true);
			
			return;
		}
		
		gameObject.GetComponent<UIListItemContainer>().GetScrollList().RemoveItem(GetComponent<UIListItemContainer>(),false);
		
	}
	private void actionResponse(string error, IJSonObject data)
	{
		if (error != null) Debug.Log ("error: " + error);
		else Debug.Log ("data: " + data);
	}
        void IJSonMutableObject.SetValue(IJSonObject value)
        {
            var input = value as JSonDecimalInt64Object;

            if (input != null)
            {
                Data = input.Data;
                StringRepresentation = input.StringRepresentation;
            }
            else
            {
                Data = value.Int64Value;
                StringRepresentation = null;
            }
        }
 /// <summary>
 /// Init constructor.
 /// </summary>
 public SubscribeResponse(IJSonObject data)
     : base (data)
 {
 }
	public void GameSent(string error, IJSonObject data)
	{	
		if(error != null)
		{
			Debug.Log(error);
		}
		else
		{
			Debug.Log(data);
			Flow.nextPanel = PanelToLoad.BattleStatus;
			tommyMaterial.mainTexture = tommyTextures[0];
			Application.LoadLevel("Mainmenu");
		}
	}
	// Cria uma lista a partir do json
	protected List<AdvertisementBase> fromJson(IJSonObject data, string defaultAd)
	{
		if (data.Count == 0)
			return null;
		
		List<AdvertisementBase> adsList = new List<AdvertisementBase>();
		
		foreach (IJSonObject ad in data.ArrayItems)
		{
			AdvertisementBase curAd = fromString(ad.ToString(), defaultAd);
			
			if (ad != null && curAd != null)
				adsList.Add(curAd);
		}
		
		return adsList;
	}
        private void ProcessResponseMessage(BayeuxRequest request, HttpStatusCode httpStatusCode, string httpStatusDescription, IJSonObject message, string rawMessage)
        {
            try
            {

                string channel = message["channel"].StringValue; // each Bayuex message must have a channel associated!
                BayeuxResponse response = null;

                if (string.IsNullOrEmpty(channel))
                    throw new BayeuxException("Unexpected message with empty channel!");
                if (request != null && (channel.StartsWith("/meta", StringComparison.Ordinal) && channel != request.Channel))
                    throw new BayeuxException(string.Format(CultureInfo.InvariantCulture, "Unexpected response with channel: '{0}'", channel), request, null, message);
                if (request != null && channel.StartsWith("/meta", StringComparison.Ordinal) && request.ID != message["id"].StringValue)
                    throw new BayeuxException(string.Format(CultureInfo.InvariantCulture, "Invalid response ID, current: '{0}', expected: '{1}'", request.ID, message["id"].StringValue), request, null,
                                              message);

                ///////////////////////////////////////////////////////////////////////////////////////////
                // identify meta messages:
                if (channel == HandshakeRequest.MetaChannel)
                {
                    var handshakeResponse = new HandshakeResponse(message);
                    response = handshakeResponse;

                    // inform, that connection succeeded:
                    if (handshakeResponse.Successful)
                    {
                        ClientID = response.ClientID;

                        if (string.IsNullOrEmpty(ClientID))
                        {
                            throw new BayeuxException("Invalid ClientID received from server", request, handshakeResponse, message);
                        }

                        OnConnected(new BayeuxConnectionEventArgs(this, httpStatusCode, httpStatusDescription, rawMessage, message, handshakeResponse));
                    }
                    else
                    {
                        // inform that Handshake failed, via dedicated event:
                        ClientID = null;
                        OnConnectionFailed(new BayeuxConnectionEventArgs(this, response.Successful ? HttpStatusCode.OK : HttpStatusCode.BadRequest, null, rawMessage, message, response));
                    }
                }

                if (channel == DisconnectRequest.MetaChannel)
                {
                    response = new BayeuxResponse(message);

                    // inform that disconnection succeeded:
                    _state = BayeuxConnectionState.Disconnected;
                    ClientID = null;

                    OnDisconnected(new BayeuxConnectionEventArgs(this, response.Successful ? HttpStatusCode.OK : HttpStatusCode.BadRequest, null, rawMessage, message, response));
                }

                if (channel == SubscribeRequest.MetaChannel)
                {
                    var subscribeResponse = new SubscribeResponse(message);
                    response = subscribeResponse;

                    if (subscribeResponse.Successful)
                        _subscribedChannels.Add(subscribeResponse.SubscriptionChannel);
                }

                if (channel == UnsubscribeRequest.MetaChannel)
                {
                    var unsubscribeResponse = new UnsubscribeResponse(message);
                    response = unsubscribeResponse;

                    if (unsubscribeResponse.Successful)
                        _subscribedChannels.Remove(unsubscribeResponse.SubscriptionChannel);
                }

                if (_subscribedChannels.Contains(channel))
                {
                    response = new BayeuxResponse(message);

                    // event from server:
                    OnEventReceived(new BayeuxConnectionEventArgs(this, httpStatusCode, httpStatusDescription, rawMessage, message, response));
                }

                // process generic response:
                if (response == null)
                    response = ProvideResponse(message);

                // allow filtering of ResponseReceived event:
                if (ProcessResponse(request, response))
                    return;

                // one place to process all responses:
                OnResponseReceived(new BayeuxConnectionEventArgs(this, httpStatusCode, httpStatusDescription, rawMessage, message, response));
            }
            catch (Exception ex)
            {
                DebugLog.WriteBayeuxException(ex);

                string statusDescription = string.Concat(httpStatusDescription, "; unexpected exception: \"", ex.Message, "\"");
                OnDataFailed(new BayeuxConnectionEventArgs(this, httpStatusCode, statusDescription, rawMessage, message));
            }
        }
 /// <summary>
 /// Get the custom bayeux-response associated with given message.
 /// By default returns a generic response.
 /// </summary>
 protected virtual BayeuxResponse ProvideResponse(IJSonObject message)
 {
      return new BayeuxResponse(message);
 }
 void IJSonMutableObject.InsertValueAt(int index, IJSonObject value)
 {
     throw new InvalidOperationException();
 }
	public void UpdateChallenge(string error, IJSonObject data)
	{
		if(error != null)
		{
			Debug.Log(error);
		}
		else
		{
			Debug.Log(data);
			Debug.Log("current rank: " + Flow.currentRank.id);
			Flow.nextPanel = PanelToLoad.Ranking;
			tommyMaterial.mainTexture = tommyTextures[0];
			Application.LoadLevel("Mainmenu");
		}
	}
 void IJSonMutableObject.SetValue(string name, IJSonObject value)
 {
     throw new InvalidOperationException();
 }
Example #60
0
	public void OnReceiveNudge(string error, IJSonObject data)
	{
		isNudging = false;
		if(error != null) Debug.Log("error nudging.. "+error);
		else
		{
			nudgeButton.SetActive(false);
		}
	}