コード例 #1
0
    public IEnumerator IeGetOtherBlockUserProfile()
    {
        var encoding = new System.Text.UTF8Encoding();

        Dictionary <string, string> postHeader = new Dictionary <string, string> ();
        var jsonElement = new Simple_JSON.JSONClass();

        jsonElement ["player_id"] = PlayerPrefs.GetInt("PlayerId").ToString();

        postHeader.Add("Content-Type", "application/json");
        postHeader.Add("Content-Length", jsonElement.Count.ToString());

        WWW www = new WWW(GetBlockUserProfileOther, encoding.GetBytes(jsonElement.ToString()), postHeader);

        print("jsonDtat is ==>> " + jsonElement.ToString());
        yield return(www);

        if (www.error == null)
        {
            JSONNode _jsnode = Simple_JSON.JSON.Parse(www.text);
            print("_jsnode ==>> " + _jsnode.ToString());
            if (_jsnode ["status"].ToString().Contains("200") && _jsnode ["description"].ToString().Contains("Blocked players list has followed"))
            {
                /// Fatch Blocke List
                var        JsonData = _jsnode ["data"];
                BlockeList temList  = null;
                for (int i = 0; i < JsonData.Count; i++)
                {
//					GameObject Go = GameObject.Instantiate (BlockUseePrefeb, Vector3.zero, Quaternion.identity) as GameObject;
                    int playerId = 0;
                    int.TryParse(JsonData [i] ["id"], out playerId);
//					Go.GetComponent<AddFriendUi> ().thisData.Id = playerId;
//					Go.GetComponent<AddFriendUi> ().thisData.Username = JsonData [i] ["name"];
//					Go.GetComponent<AddFriendUi> ().thisData.Type = FriendData.FriendType.BlockedBy;
//					Go.transform.parent = BlockListContainer.transform;
//
                    temList = new BlockeList(playerId, JsonData [i] ["name"].ToString().Trim('\"'));
                    BlockedByList.Add(temList);
                }
//				ScreenAndPopupCall.Instance.MyProfileBlockListPopup ();
//				if (BlockListContainer.transform.childCount == 0)
//					ScreenManager.Instance.MyProfileBlockList.transform.GetChild (1).transform.GetChild (3).gameObject.SetActive (true);
//				else
//					ScreenManager.Instance.MyProfileBlockList.transform.GetChild (1).transform.GetChild (3).gameObject.SetActive (false);
//				BlockListContainer.transform.parent.parent.parent.GetChild (2).GetComponent<Text> ().text = "BLOCKED BY USER LIST";
            }
        }
    }
コード例 #2
0
    public IEnumerator MyBlockUserList(bool show)
    {
        var encoding = new System.Text.UTF8Encoding();

        Dictionary <string, string> postHeader = new Dictionary <string, string> ();
        var jsonElement = new Simple_JSON.JSONClass();

        jsonElement ["player_id"] = PlayerPrefs.GetInt("PlayerId").ToString();

        postHeader.Add("Content-Type", "application/json");
        postHeader.Add("Content-Length", jsonElement.Count.ToString());

        WWW www = new WWW(GetMyBlockUserProfile, encoding.GetBytes(jsonElement.ToString()), postHeader);

        print("jsonDtat is ==>> " + jsonElement.ToString());
        yield return(www);

        if (www.error == null)
        {
            JSONNode _jsnode = Simple_JSON.JSON.Parse(www.text);
            print("_jsnode ==>> " + _jsnode.ToString());
            if (_jsnode ["status"].ToString().Contains("200") && _jsnode ["description"].ToString().Contains("Blocked players list has followed."))
            {
                /// Fatch Blocke List
                var        JsonData = _jsnode ["data"];
                BlockeList temList  = null;
                for (int i = 0; i < JsonData.Count; i++)
                {
                    GameObject Go       = GameObject.Instantiate(BlockUserPrefeb, Vector3.zero, Quaternion.identity) as GameObject;
                    int        playerId = 0;
                    int.TryParse(JsonData [i] ["id"], out playerId);
                    Go.GetComponent <AddFriendUi> ().thisData.Id       = playerId;
                    Go.GetComponent <AddFriendUi> ().thisData.Username = JsonData [i] ["name"];
                    Go.GetComponent <AddFriendUi> ().thisData.Type     = FriendData.FriendType.Blocked;
                    //ToDo:
                    if (show)
                    {
                        ShowBlockList = true;
                        Go.GetComponent <AddFriendUi> ().AddButton.onClick.RemoveAllListeners();
                        Go.GetComponent <AddFriendUi> ().AddButton.onClick.AddListener(() => FriendProfileManager.Instance.ActiveBackButtonForUserProfile());
                    }
                    else
                    {
                        ShowBlockList = false;
                    }
                    Go.transform.parent = BlockListContainer.transform;
                    // add into block List
                    temList = new BlockeList(playerId, JsonData [i] ["name"].ToString().Trim('\"'));
                    MyBlockList.Add(temList);
                }
                if (show)
                {
                    ScreenAndPopupCall.Instance.MyProfileBlockListPopup();
                }
                if (BlockListContainer.transform.childCount == 0)
                {
                    ScreenManager.Instance.MyProfileBlockList.transform.GetChild(1).transform.GetChild(3).gameObject.SetActive(true);
                }
                else
                {
                    ScreenManager.Instance.MyProfileBlockList.transform.GetChild(1).transform.GetChild(3).gameObject.SetActive(false);
                }
                BlockListContainer.transform.parent.parent.parent.GetChild(2).GetComponent <Text> ().text = "BLOCKED LIST";
            }
            else if (_jsnode ["status"].ToString().Contains("200") && _jsnode ["description"].ToString().Contains("No data has found."))
            {
                if (show)
                {
                    ShowPopUpErrorMsg(" You have not blocked anyone yet.");
                }
            }
        }
    }