Beispiel #1
0
    void GetFriendAsGuest()
    {
        DestroyFriendsList();
        loadingPanel.SetActive(false);


        List <string> onlyGuest = new List <string> ();

        for (int i = 0; i < OnlineUser.users.Count; i++)
        {
            string str = OnlineUser.users[i].ClientId;
            if (str [0] == 'G')
            {
                onlyGuest.Add(str);
                Debug.Log(str + "____________________________::::::::::");
                //instance friends
                GameObject g = Instantiate(FriendPrefab) as GameObject;
                g.SetActive(true);
                g.transform.SetParent(parentObject);
                g.transform.localScale = Vector3.one;
                g.transform.position   = Vector3.zero;
                FriendsObjectList.Add(g);
                g.GetComponent <FriendsDetails> ().Name.text = str;

                Toggle btn = g.GetComponentInChildren <Toggle> ();
                btn.group = toggleGroup;
                string id = str;
                //g.GetComponent<FriendsDetails> ().ID = System.Convert.ToInt64 (id);
                AddListener(btn, id, str);
                int userID = OnlineUser.IsContains(id);

                if (userID >= 0)
                {
                    g.GetComponent <FriendsDetails> ().SetOnline(true);
                    if (OnlineUser.users[userID].isPlaying)
                    {
                        g.GetComponent <FriendsDetails>().playing.SetActive(true);
                    }
                    else
                    {
                        g.GetComponent <FriendsDetails>().playing.SetActive(false);
                    }
                }
                else
                {
                    g.GetComponent <FriendsDetails> ().SetOnline(false);
                    g.GetComponent <FriendsDetails>().playing.SetActive(false);
                }
            }
        }
    }
Beispiel #2
0
    void GetFreindCallback(IResult result)
    {
        loadingPanel.SetActive(false);
        DestroyFriendsList();
        if (GameManager.instance.isRandomPlayer)
        {
            GetFriendAsGuest();
        }
        string resposne = result.RawResult;

        Debug.Log(resposne);
        var data = (Dictionary <string, object>)result.ResultDictionary;

        if (data.ContainsKey("friends"))
        {
            var tagData    = data["friends"] as Dictionary <string, object>;
            var resultData = tagData["data"] as List <object>;
            for (int i = 0; i < resultData.Count; i++)
            {
                var    resultValue = resultData[i] as Dictionary <string, object>;
                var    picture     = resultValue["picture"] as Dictionary <string, object>;
                var    picData     = picture["data"] as Dictionary <string, object>;
                string url         = picData["url"].ToString();
                Debug.Log("url : " + url);
                GameObject g = Instantiate(FriendPrefab) as GameObject;
                g.SetActive(true);
                g.transform.SetParent(parentObject);
                g.transform.localScale = Vector3.one;
                g.transform.position   = Vector3.zero;
                FriendsObjectList.Add(g);
                string name = resultValue["name"].ToString();
                g.GetComponent <FriendsDetails>().Name.text = name;
                Toggle btn = g.GetComponentInChildren <Toggle>();
                btn.group = toggleGroup;
                Debug.Log(resultValue["name"].ToString() + "  , " + resultValue["id"].ToString());
                string id = resultValue["id"].ToString();
                g.GetComponent <FriendsDetails>().ID = System.Convert.ToInt64(id);
                AddListener(btn, id, name);
                int userID = OnlineUser.IsContains(id);

                if (userID >= 0)
                {
                    g.GetComponent <FriendsDetails>().SetOnline(true);
                    if (OnlineUser.users[userID].isPlaying)
                    {
                        g.GetComponent <FriendsDetails>().playing.SetActive(true);
                    }
                    else
                    {
                        g.GetComponent <FriendsDetails>().playing.SetActive(false);
                    }
                }
                else
                {
                    g.GetComponent <FriendsDetails>().SetOnline(false);
                    g.GetComponent <FriendsDetails>().playing.SetActive(false);
                }
                if (!string.IsNullOrEmpty(id))
                {
                    FB.API("https" + "://graph.facebook.com/" + id + "/picture?width=128&height=128", HttpMethod.GET, delegate(IGraphResult avatarResult)
                    {
                        if (avatarResult.Error != null)
                        {
                            Debug.Log(avatarResult.Error);
                        }
                        else
                        {
                            g.GetComponent <FriendsDetails>().ProfilePic.sprite = Sprite.Create(avatarResult.Texture, new Rect(0, 0, 128, 128), new Vector2(0.5f, 0.5f));
                            ;
                        }
                    });
                }
                isFrndsAvials = true;
            }
        }
    }