Exemplo n.º 1
0
    private static void GetPlayerInfoCallback(IGraphResult result)
    {
        Debug.Log("GetPlayerInfoCallback");
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }
        Debug.Log(result.RawResult);

        // Save player name
        string name;

        if (result.ResultDictionary.TryGetValue("first_name", out name))
        {
            GameStateManager.Username = name;
        }

        //Fetch player profile picture from the URL returned
        string playerImgUrl = GraphUtil.DeserializePictureURL(result.ResultDictionary);

        GraphUtil.LoadImgFromURL(playerImgUrl, delegate(Texture pictureTexture)
        {
            // Setup the User's profile picture
            if (pictureTexture != null)
            {
                GameStateManager.UserTexture = pictureTexture;
            }

            // Redraw the UI
            GameStateManager.CallUIRedraw();
        });
    }
Exemplo n.º 2
0
    private static void GetPlayerInfoCallback(IGraphResult result)
    {
        Debug.Log("GetPlayerInfoCallback");
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }
        Debug.Log(result.RawResult);

        // Save player name
        string name;

        if (result.ResultDictionary.TryGetValue("first_name", out name))
        {
            Game.Username = name;
        }

        //Fetch player profile picture from the URL returned
        string playerImgUrl = GraphUtil.DeserializePictureURL(result.ResultDictionary);

        GraphUtil.LoadImgFromURL(playerImgUrl, delegate(Texture pictureTexture) {
            // Setup the User's profile picture
            if (pictureTexture != null)
            {
                Game.UserTexture = pictureTexture;
            }

            if (StartMenu.self != null)
            {
                StartMenu.self.FacebookUser.text = "Welcome " + Game.Username;
            }
        });
    }
Exemplo n.º 3
0
    protected void checkImageExist(EFriendsType friendsType)
    {
        switch (friendsType)
        {
        case EFriendsType.ALL:
            if (!allFriendsImageExist)
            {
                allFriendsImageExist = true;
                for (int i = 0; i < invitableFriends.friends.Count; i++)
                {
                    if (!invitableFriends.friends[i].imageSetted)
                    {
                        allFriendsImageExist = false;
                        Sprite image = FacebookPersistentData.GetInstance().getSpritePictureById(invitableFriends.friends [i].id);
                        if (image == null)
                        {
                            invitableFriends.friends [i].getTextureFromURL(GraphUtil.DeserializePictureURL(FacebookPersistentData.GetInstance().getFriendInfo(invitableFriends.friends [i].id)));
                        }
                        else
                        {
                            invitableFriends.friends [i].setFriendImage(image);
                            invitableFriends.friends [i].imageSetted = true;
                        }
                    }
                }
            }
            break;

        case EFriendsType.GAME:
            if (!allGamesFriendsImageExist)
            {
                allGamesFriendsImageExist = true;
                for (int i = 0; i < gameFriends.friends.Count; i++)
                {
                    if (!gameFriends.friends[i].imageSetted)
                    {
                        allGamesFriendsImageExist = false;
                        Sprite image = FacebookPersistentData.GetInstance().getSpritePictureById(gameFriends.friends [i].id);
                        if (image == null)
                        {
                            gameFriends.friends [i].getTextureFromURL(GraphUtil.DeserializePictureURL(FacebookPersistentData.GetInstance().getFriendInfo(gameFriends.friends [i].id)));
                        }
                        else
                        {
                            gameFriends.friends [i].setFriendImage(image);
                            gameFriends.friends [i].imageSetted = true;
                        }
                    }
                }
            }
            break;

        default:
            break;
        }
    }
Exemplo n.º 4
0
    private void CacheFriends(List <object> newFriends)
    {
        Dictionary <string, object> friend;

        texturesCount += newFriends.Count;
        foreach (Dictionary <string, object> f in newFriends)
        {
            friend = f as Dictionary <string, object>;

            string playerImgUrl = GraphUtil.DeserializePictureURL(friend);

            getTextureFromURL(playerImgUrl, (string)friend ["id"]);
        }
    }
Exemplo n.º 5
0
    public void LoadFriendAPI(string id, FriendDataDelegate callback = null)
    {
        string query = "/" + id + "?fields=id,first_name,picture.width(120).height(120)";

        FB.API(query, HttpMethod.GET, delegate(IGraphResult result)
        {
            if (result.Error == null)
            {
                object value = string.Empty;
                result.ResultDictionary.TryGetValue("first_name", out value);
                FBPlayer f = new FBPlayer(id, (string)value, playing: false, invited: false, 0, 0L);
                string url = GraphUtil.DeserializePictureURL(result.ResultDictionary);
                LoadFriendPicture(url, f, callback);
            }
        });
    }
Exemplo n.º 6
0
    private void GetPlayerInfoCallback(IGraphResult result)
    {
        bool textureReady = false;
        bool infoReady    = false;

        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }
        //Debug.Log(result.RawResult);

        // Save player id
        string id = "";

        if (result.ResultDictionary.TryGetValue("id", out id))
        {
        }

        string name = "";

        result.ResultDictionary.TryGetValue("first_name", out name);


        //Fetch player profile picture from the URL returned
        string playerImgUrl = GraphUtil.DeserializePictureURL(result.ResultDictionary);

        GraphUtil.LoadImgFromURL(playerImgUrl, delegate(Texture pictureTexture)
        {
            // Setup the User's profile picture
            if (OnGetFriendTextures != null)
            {
                OnGetFriendTextures(id, pictureTexture, true);
            }
            textureReady = true;
            setPlayerInfoReady(infoReady, textureReady);
            //print("finishPLAYERINFO");
        });

        if (OnPlayerInfo != null)
        {
            OnPlayerInfo(id, name);
        }
        infoReady = true;
        setPlayerInfoReady(infoReady, textureReady);
    }
Exemplo n.º 7
0
    public void OnPlayClicked()
    {
        Debug.Log("OnPlayClicked");

        if (GameStateManager.Friends != null && GameStateManager.Friends.Count > 0)
        {
            // Select a random friend and setup game state
            int randFriendNum = UnityEngine.Random.Range(0, GameStateManager.Friends.Count);
            var friend        = GameStateManager.Friends[randFriendNum] as Dictionary <string, object>;
            GameStateManager.FriendName  = friend["first_name"] as string;
            GameStateManager.FriendID    = friend["id"] as string;
            GameStateManager.CelebFriend = -1;

            // Set friend image
            if (GameStateManager.FriendImages.ContainsKey(GameStateManager.FriendID))
            {
                GameStateManager.FriendTexture = GameStateManager.FriendImages[GameStateManager.FriendID];
            }
            else
            {
                // We don't have this players image yet, request it now
                string friendImgUrl = GraphUtil.DeserializePictureURL(friend);
                GraphUtil.LoadImgFromURL(friendImgUrl, delegate(Texture pictureTexture)
                {
                    if (pictureTexture != null)
                    {
                        GameStateManager.FriendImages.Add(GameStateManager.FriendID, pictureTexture);
                        GameStateManager.FriendTexture = pictureTexture;
                    }
                });
            }
        }
        else
        {
            //We can't access friends -- Use celebrity
            GameStateManager.CelebFriend   = UnityEngine.Random.Range(0, gResources.CelebTextures.Length - 1);
            GameStateManager.FriendName    = gResources.CelebNames[GameStateManager.CelebFriend];
            GameStateManager.FriendTexture = gResources.CelebTextures[GameStateManager.CelebFriend];
        }

        // Start the main game
        Application.LoadLevel("GameStage");
        GameStateManager.Instance.StartGame();
    }
Exemplo n.º 8
0
    private static void GetPlayerInfoCallback(IGraphResult result)
    {
        Debug.Log("GetPlayerInfoCallback");
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }
        Debug.Log(result.RawResult);

        // Save player name
        string name;

        if (result.ResultDictionary.TryGetValue("first_name", out name))
        {
            FacebookUI.UserName = name;
        }
        int id;

        if (result.ResultDictionary.TryGetValue("id", out id))
        {
            FacebookUI.ID = id;
        }

        //Fetch player profile picture from the URL returned
        string playerImgUrl = GraphUtil.DeserializePictureURL(result.ResultDictionary);

        GraphUtil.LoadImgFromURL(playerImgUrl, delegate(Texture pictureTexture)
        {
            // Setup the User's profile picture
            if (pictureTexture != null)
            {
                FacebookUI.UserPicture = pictureTexture;
            }
            // Redraw the UI
            if (OnFacebookLoggedInUpdated != null)
            {
                OnFacebookLoggedInUpdated();
            }
        });
    }
Exemplo n.º 9
0
 private void LoadMyDataAPI(string url, MyDataDelegate callback = null)
 {
     FB.API(meQueryString, HttpMethod.GET, delegate(IGraphResult result)
     {
         if (result.Error == null)
         {
             Dictionary <string, string> dictionary = GraphUtil.DeserializeJSONProfile(result.RawResult);
             List <object> friends = GraphUtil.DeserializeJSONFriends(result.RawResult);
             string id             = "me";
             if (dictionary.ContainsKey("id"))
             {
                 id = dictionary["id"];
             }
             string name = dictionary["first_name"];
             int value   = PlayerData.Instance.LifetimeChunk.Value;
             FBPlayer f  = new FBPlayer(id, name, playing: false, invited: false, value, 0L);
             string url2 = GraphUtil.DeserializePictureURL(result.ResultDictionary);
             LoadMyPicture(url2, f, friends, callback);
         }
     });
 }
 public string getFriendPictureUrl(object friendInfo)
 {
     return(GraphUtil.DeserializePictureURL(friendInfo));
 }