예제 #1
0
    public static void LoadFriendImages()
    {
        if (FaceBook.friends != null)
        {
            foreach (Dictionary <string, object> temp in FaceBook.friends)
            {
                FacebookPictureDownloader.EnQueue((string)temp["id"]);

                /*
                 * if (!friendImages.ContainsKey((string)temp["id"]))
                 * {
                 *  // We don't have this players image yet, request it now
                 *  FB.API(Util.GetPictureURL((string)temp["id"], 128, 128), Facebook.HttpMethod.GET, pictureResult =>
                 *  {
                 *      if (pictureResult.Error != null)
                 *      {
                 *          FbDebug.Error(pictureResult.Error);
                 *      }
                 *      else
                 *      {
                 *          try
                 *          {
                 *              friendImages.Add((string)temp["id"], pictureResult.Texture);
                 *          }
                 *          catch (System.Exception e)
                 *          {
                 *              Debug.Log(e.Message + " : Exceiption.");
                 *          }
                 *      }
                 *  });
                 * }
                 */
            }
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        //btn_Toggle.isChecked

        if (loading)
        {
            picture.fid = fid;
            if (!FaceBook.getfriendImages().ContainsKey(fid))
            {
                FacebookPictureDownloader.EnQueue(fid);

                /*
                 * FB.API(Util.GetPictureURL(fid, 128, 128), Facebook.HttpMethod.GET, pictureResult =>
                 * {
                 *  if (pictureResult.Error != null)
                 *  {
                 *      Debug.LogError(pictureResult.Error);
                 *  }
                 *  else
                 *  {
                 *      FaceBook.getfriendImages().Add(fid.ToString(), pictureResult.Texture);
                 *  }
                 * });
                 */
            }

            loading = false;
        }
    }
예제 #3
0
    public void SetInit(int rank, string fid, string name, string score, string sendable, bool me)
    {
        this.fid = fid;

        if (this.label_rank != null)
        {
            this.label_rank.text = rank.ToString();
        }
        if (this.label_name != null)
        {
            this.label_name.text = name;
        }
        if (this.label_score != null)
        {
            this.label_score.text = score;
        }

        if (sendable.Equals("1"))
        {
            this.sendable = true;
        }
        else
        {
            this.sendable = false;
        }

        this.me = me;

        if (me)
        {
            label_rank.color = new Color(13.0f / 255.0f, 150.0f / 255.0f, 150.0f / 255.0f);
            this.sendable    = false;
            sendBtn.SetActive(false);
        }
        else if (this.sendable)
        {
            sendBtn.SetActive(true);
            sendunable.SetActive(false);
        }
        else
        {
            sendBtn.SetActive(true);
            sendunable.SetActive(true);
        }

        if (!me && rank > 3)
        {
            label_rank.color = new Color(8.0f / 255.0f, 8.0f / 255.0f, 8.0f / 255.0f);
        }

        picture.fid = fid;

        if (!FaceBook.getfriendImages().ContainsKey(fid))
        {
            FacebookPictureDownloader.EnQueue(fid);
        }

        this.init = true;
    }
예제 #4
0
    public static void LoginCallback(FBResult result)
    {
        FbDebug.Log("call login: "******"login result: " + result.Text);

        FB.API("/me?fields=id,name,first_name,last_name,gender,locale,currency,friends.limit(1000).fields(first_name,last_name,id)", Facebook.HttpMethod.GET, FaceBook.APICallback);
        FacebookPictureDownloader.EnQueue(FB.UserId);
        FB.API("/app/scores?fields=score,user.limit(1000)", Facebook.HttpMethod.GET, ScoresCallback);
    }
예제 #5
0
    public void SetFriendTogetherContext(string friendname, string fid)
    {
        setenable = true;
        //this.friendname = friendname;
        this.fid    = fid;
        picture.fid = fid;

        if (!FaceBook.getfriendImages().ContainsKey(fid))
        {
            FacebookPictureDownloader.EnQueue(fid);
        }

        if (label_name != null)
        {
            label_name.text = friendname;
        }
    }
    private IEnumerator WaitForRequest(WWW www)
    {
        yield return(www);

        if (www.error == null)
        {
            Debug.Log("WWW get Ok!: " + www.text);
            JsonData jData = JsonMapper.ToObject(www.text);
            Debug.Log("Json Data Count is " + jData.Count);

            CMainData.Gold        = int.Parse(jData["gold"].ToString());
            CMainData.Dice_Count  = int.Parse(jData["dice"].ToString());
            CMainData.Dice_Time   = float.Parse(jData["dicetime"].ToString());
            CMainData.UserScore   = int.Parse(jData["score"].ToString());
            CMainData.TopUser     = jData["top"];
            CMainData.UserRanking = int.Parse(jData["ranking"].ToString());
            int nTutorial = int.Parse(jData["tutorial"].ToString());
            if (nTutorial == 1)
            {
                CMainData.Tutorial = true;
            }
            else
            {
                CMainData.Tutorial = false;
            }

            for (int i = 0; i < CMainData.TopUser.Count; i++)
            {
                string topfid = CMainData.TopUser[i]["fid"].ToString();
                FacebookPictureDownloader.EnQueue(topfid);
            }

            SendGetMessage();
        }
        else
        {
            Debug.Log("WWW Error: " + www.error);
        }
    }
예제 #7
0
    public static void ScoresCallback(FBResult result)
    {
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }

        List <object> scoresList = Util.DeserializeScores(result.Text);
        var           x          = 0;

        CMainData.appFriends.Clear();

        foreach (object score in scoresList)
        {
            x++;
            Dictionary <string, object> entry = (Dictionary <string, object>)score;
            Dictionary <string, object> user  = (Dictionary <string, object>)entry["user"];

            string userId = (string)user["id"];
            string name   = ((string)user["name"]);

            if (string.Equals(userId, FB.UserId))
            {
                FbDebug.Log("Start Ranking is " + x.ToString());
            }
            else
            {
                // App Play 중인 친구 정보 추가
                Dictionary <string, string> friend = new Dictionary <string, string>();
                friend.Add("fid", userId);
                friend.Add("name", name);
                CMainData.appFriends.Add(friend);
            }

            FacebookPictureDownloader.EnQueue(userId);
        }
    }
예제 #8
0
    //private string sendderName = null;

    public void SetMessageContext(int type, string sendderName, string fid)
    {
        setenable = true;
        this.type = type;
        //this.sendderName = sendderName;
        this.fid    = fid;
        picture.fid = fid;
        if (!FaceBook.getfriendImages().ContainsKey(fid))
        {
            FacebookPictureDownloader.EnQueue(fid);
        }

        switch (type)
        {
        case 1:
            if (title != null)
            {
                //title.text = StringData.getType1_Title(sendderName);
                title.text = StringData.getString(StringData.Type1_Title_key).Replace("%s", sendderName);
            }
            if (subtitle != null)
            {
                //subtitle.text = StringData.getType1_Message(sendderName);
                subtitle.text = StringData.getString(StringData.Type1_Message_key).Replace("%s", sendderName);
            }
            if (label_acceptbutton != null)
            {
                //label_acceptbutton.text = StringData.Type1_AcceptButton;
                label_acceptbutton.text = StringData.getString(StringData.Type1_AcceptButton_key);
            }
            break;

        case 2:
            if (title != null)
            {
                //title.text = StringData.getType2_Title(sendderName);
                title.text = StringData.getString(StringData.Type2_Title_key).Replace("%s", sendderName);
            }
            if (subtitle != null)
            {
                //subtitle.text = StringData.getType2_Message(sendderName);
                subtitle.text = StringData.getString(StringData.Type2_Message_key).Replace("%s", sendderName);
            }
            if (label_acceptbutton != null)
            {
                //label_acceptbutton.text = StringData.Type2_AcceptButton;
                label_acceptbutton.text = StringData.getString(StringData.Type2_AcceptButton_key);
            }
            break;

        case 3:
            if (title != null)
            {
                //title.text = StringData.getType3_Title(sendderName);
                title.text = StringData.getString(StringData.Type3_Title_key).Replace("%s", sendderName);
            }
            if (subtitle != null)
            {
                //subtitle.text = StringData.getType3_Message(sendderName);
                subtitle.text = StringData.getString(StringData.Type3_Message_key).Replace("%s", sendderName);
            }
            if (label_acceptbutton != null)
            {
                //label_acceptbutton.text = StringData.Type3_AcceptButton;
                label_acceptbutton.text = StringData.getString(StringData.Type3_AcceptButton_key);
            }
            break;

        default:
            if (title != null)
            {
                title.text = StringData.getString(StringData.Type_Unknown_key);
                //title.text = "알수 없는 메시지";
            }
            if (subtitle != null)
            {
                subtitle.text = sendderName;
            }
            break;
        }
    }
예제 #9
0
    // Use this for initialization
    void Start()
    {
        topUser = CMainData.TopUser;
        if (topUser != null)
        {
            for (int i = 0; i < topUser.Count; i++)
            {
                TextureUpdate t = face[i].GetComponent <TextureUpdate>();
                if (t != null)
                {
                    if (FaceBook.getfriendImages().ContainsKey(topUser[i]["fid"].ToString()))
                    {
                        Texture picture = null;
                        FaceBook.getfriendImages().TryGetValue(topUser[i]["fid"].ToString(), out picture);

                        if (picture != null)
                        {
                            if (face[i] != null)
                            {
                                face[i].mainTexture = picture;
                            }
                            Destroy(t);
                        }
                        else
                        {
                            t.fid = topUser[i]["fid"].ToString();
                        }
                    }
                    else
                    {
                        t.fid = topUser[i]["fid"].ToString();
                        FacebookPictureDownloader.EnQueue(topUser[i]["fid"].ToString());
                    }
                }

                /*
                 * string strURL = topUser[i]["fid"].ToString() + "?fields=id,name";
                 * Debug.Log("FRIEND NAME URL = [ " + strURL + " ]");
                 * FB.API(strURL, Facebook.HttpMethod.GET, result =>
                 * {
                 *  if (result.Error == null)
                 *  {
                 *      Debug.Log("FRIEND NAME RESULT = [ " + result.Text + " ]");
                 *      Dictionary<string, string> friendInfo = Util.DeserializeJSONFriendInfo(result.Text);
                 *      friendInfoList.Add(friendInfo["id"],friendInfo["name"]);
                 *  }
                 * });
                 */

                FacebookName facebookName = friend_name[i].GetComponent <FacebookName>();
                facebookName.fid = topUser[i]["fid"].ToString();

                //if (friend_name[i] != null)
                //    friend_name[i].text = topUser[i]["name"].ToString();

                if (score[i] != null)
                {
                    score[i].text = topUser[i]["score"].ToString();
                }
            }

            for (int i = topUser.Count; i < 10; i++)
            {
                face[i].gameObject.SetActive(false);
                back[i].SetActive(false);
                friend_name[i].gameObject.SetActive(false);
                rank[i].gameObject.SetActive(false);
                score[i].gameObject.SetActive(false);
            }
        }
        else
        {
            for (int i = 0; i < 10; i++)
            {
                face[i].gameObject.SetActive(false);
                back[i].SetActive(false);
                friend_name[i].gameObject.SetActive(false);
                rank[i].gameObject.SetActive(false);
                score[i].gameObject.SetActive(false);
            }
        }

        TextureUpdate t_my = face[10].GetComponent <TextureUpdate>();

        if (CMainData.UserTexture != null)
        {
            face[10].mainTexture = CMainData.UserTexture;
            Destroy(t_my);
        }
        else if (FaceBook.getfriendImages().ContainsKey(FB.UserId))
        {
            Texture picture = null;
            FaceBook.getfriendImages().TryGetValue(FB.UserId, out picture);

            if (picture != null)
            {
                if (face[10] != null)
                {
                    face[10].mainTexture = picture;
                }
                Destroy(t_my);
            }
            else
            {
                t_my.fid = FB.UserId;
            }
        }
        else
        {
            FacebookPictureDownloader.EnQueue(FB.UserId);
        }

        if (CMainData.Username != null)
        {
            friend_name[10].text = CMainData.Username;
        }

        if (score[10] != null)
        {
            score[10].text = CMainData.UserScore.ToString();
        }
        if (rank[10] != null)
        {
            rank[10].text = CMainData.UserRanking.ToString();
        }
    }