Ejemplo n.º 1
0
    public void JoinGroupHandler(VkResponseRaw _raw, object[] _arguments)
    {
        //   if (_raw.ei != null && _raw.ei.error_code.Equals("17"))
        //    {
        //       Debug.Log("ОШибка при входе");
        PreferencesSaver.SetEnterInVkGroup();
        library.money.AddMoney(GameplayConstants.EnterVkGroupReward);

        //        library.screenController.endScreen.GetComponent<EndScreen>().HideEnterVkButton();
        //       return;
        //   }


        //     var dict = Json.Deserialize(_raw.text) as Dictionary<string, object>;
        //     long resp = (long)dict["response"];

        /*
         *      if (resp == 1)
         *      {
         *          PreferencesSaver.SetEnterInVkGroup();
         *          library.money.AddMoney(GameplayConstants.EnterVkGroupReward);
         *          Debug.Log("Зашло");
         *
         *      }
         *      else
         *      {
         *          Debug.Log("Не зашло");
         *      }*/
        //    PreferencesSaver.SetEnterInVkGroup();
        // library.money.AddMoney(GameplayConstants.EnterVkGroupReward);
    }
Ejemplo n.º 2
0
    public void WallPostHandler(VkResponseRaw _raw, object[] _arguments)
    {
        if (_raw.ei == null)
        {
            //Debug.Log(_raw.text);

            PreferencesSaver.SetDatePostVk(DateTime.Now);
            library.money.AddMoney(GameplayConstants.PostVkReward);

            /*
             * if (ExternalControl.GameControl.ReferalControl.Active)
             *  ExternalControl.GameControl.ReferalControl.InviteFriendsHandler(1);
             * else
             *  ExternalControl.VK_WallPostHandler(1);
             *
             * Debug.Log("success");*/
        }
        else
        {
            /*
             * if
             * (ExternalControl.GameControl.ReferalControl.Active)
             *  ExternalControl.GameControl.ReferalControl.InviteFriendsHandler(1);
             * else
             *  ExternalControl.VK_WallPostHandler(0);
             */
            // Debug.Log("vk error: " + _raw.ei.error_msg);
        }
    }
Ejemplo n.º 3
0
    void OnGet5FriendsCompleted(VkResponseRaw arg1, object[] arg2)
    {
        //проверяем на ошибки
        if (arg1.ei != null)
        {
            //если ошибка, помним что мы передали номер запроса, можно повторить запрос некоторое количество раз
            var attempt = (int)arg2[0];
            if (attempt < 5)
            {
                Get3FriendsDataFromVk(attempt + 1);
            }
            return;
        }

        var dict  = Json.Deserialize(arg1.text) as Dictionary <string, object>;
        var resp  = (Dictionary <string, object>)dict["response"];
        var items = (List <object>)resp["items"];

        foreach (var item in items)
        {
            friends.Add(VKUser.Deserialize(item));
        }
        for (var i = 0; i < 3; i++)
        {
            var friendsOnScene = GameObject.FindObjectsOfType <FriendManager>();

            Action <WWW, object[]> doOnFinish = (www, objarray) =>
            {
                var friendCard = (FriendManager)objarray[0];
                friendCard.setUpImage(www.bytes);
            };
            friendsOnScene[i].t.text = friends[i].first_name;
            d.download(friends[i].photo_200, doOnFinish, new object[] { friendsOnScene[i] });
        }
    }
Ejemplo n.º 4
0
    public void JoinGroupHandler(VkResponseRaw _raw, object[] _arguments)
    {
        if (_raw.ei != null && _raw.ei.error_code.Equals("17"))
        {
            libraryMenu.windowWarning.Show("ВКонтакте требует прохождения процедуры валидации пользователя.");
            return;
        }


        var  dict = Json.Deserialize(_raw.text) as Dictionary <string, object>;
        long resp = (long)dict["response"];


        if (resp == 1)
        {
            PreferencesSaver.UserJoinInGroupVK();
            PreferencesSaver.OpenCar(numBonusCar);
            libraryMenu.carChanger.ShowCar();
        }
        else
        {
            libraryMenu.windowWarning.Show("Превышено ограничение на количество вступлений.");
        }
    }
Ejemplo n.º 5
0
    public void GetFriendsHandler(VkResponseRaw _raw, object[] _arguments)
    {
        if (_raw.ei == null)
        {
            List <VKUser>             FriendsData = new List <VKUser>();
            Dictionary <long, VKUser> Users       = new Dictionary <long, VKUser>();


            Debug.Log("vk: " + _raw.text);

            try
            {
                var dict     = Json.Deserialize(_raw.text) as Dictionary <string, object>;
                var response = (object)dict["response"] as Dictionary <string, object>;


                var items = (List <object>)response["items"];

                foreach (var item in items)
                {
                    FriendsData.Add(VKUser.Deserialize(item));
                }
                //   var friendsResponse = JsonReader.Deserialize < VkResponse < VKList < VKUser»> (_raw.text);

                //     if (friendsResponse.response.items.Count > 0)
                //       FriendsData.AddRange(friendsResponse.response.items);
            }
            catch
            {
                //     ExternalControl.VK_WallPostHandler(0);

                return;
            }

            int FriendsCount = FriendsData.Count;

            if (FriendsCount > 0)
            {
                if (FriendsCount > 3)
                {
                    int PassCount = 0;

                    while (Users.Count < 3)
                    {
                        for (var i = 0; i < FriendsData.Count; i++)
                        {
                            VKUser UserData = FriendsData[i];

                            bool HasMobile = (UserData.has_mobile == 1);
                            bool NowOnline = (UserData.online == 1);
                            bool Man       = (UserData.sex == 2);

                            bool PassCondition = false;

                            switch (PassCount)
                            {
                            case 0:
                                PassCondition = NowOnline && HasMobile && Man;
                                break;

                            case 1:
                                PassCondition = NowOnline && HasMobile;
                                break;

                            case 2:
                                PassCondition = HasMobile;
                                break;

                            case 3:
                                PassCondition = true;
                                break;
                            }

                            if (PassCondition && !Users.ContainsKey(UserData.id))
                            {
                                if (Users.Count < 3)
                                {
                                    Users.Add(UserData.id, UserData);
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }

                        PassCount++;
                    }

                    FriendsCount = 3;
                }
                else
                {
                    for (var i = 0; i < FriendsData.Count; i++)
                    {
                        VKUser UserData = FriendsData[i];

                        Users.Add(UserData.id, UserData);
                    }
                }
            }

            string _friends = "";

            if (Users.Count > 0)
            {
                foreach (KeyValuePair <long, VKUser> _item in Users)
                {
                    _friends += string.Format("[id{0}|{1}], ", _item.Key, _item.Value.first_name + " " + _item.Value.last_name);
                }

                _friends = _friends.Substring(0, _friends.Length - 2);
            }

            //need develop
            WallPostRequest(_friends);
        }
        else
        {
            Debug.Log("vk error: " + _raw.ei.error_msg);
        }
    }