public void SetFriend(Fresvii.AppSteroid.Models.Friend friend, AUIFriendList parentPage)
        {
            this.Friend = friend;

            this.parentPage = parentPage;

            this.user = this.Friend.ToUser();

            if (this.user.Id == FAS.CurrentUser.Id)
            {
                tagLabel.gameObject.SetActive(true);

                tagText.text = FASText.Get("You");

                if (!tagSized)
                {
                    userName.rectTransform.sizeDelta = new Vector2(userName.rectTransform.sizeDelta.x - tagLabel.rectTransform.sizeDelta.x - 30f, userName.rectTransform.sizeDelta.y);

                    tagSized = true;
                }
            }

            userIcon.Set(user.ProfileImageUrl);

            userName.text = user.Name;
        }
        public void SetUser(Fresvii.AppSteroid.Models.User user, AUIUserSearch parentPage)
        {
            this.User = user;

            this.parentPage = parentPage;

            userName.text = user.Name;

            userIcon.Set(user.ProfileImageUrl);

            if (this.User.Id == FAS.CurrentUser.Id)
            {
                tagLabel.gameObject.SetActive(true);

                tagLabel.GetComponent<Image>().color = tagYouColor;

                tagText.text = FASText.Get("You");

                tagText.color = tagYouColor;
            }
            else if (this.User.FriendStatus == Models.User.FriendStatuses.Friend)
            {
                tagLabel.gameObject.SetActive(true);

                tagText.text = FASText.Get("Friend");

                tagLabel.GetComponent<Image>().color = tagFriendColor;

                tagText.color = tagFriendColor;
            }

            if (tagLabel.gameObject.activeSelf)
            {
                if (!tagSized)
                {
                    userName.rectTransform.sizeDelta = new Vector2(userName.rectTransform.sizeDelta.x - tagLabel.rectTransform.sizeDelta.x - 30f, userName.rectTransform.sizeDelta.y);

                    tagSized = true;
                }
            }
        }
        void ChangeTurn()
        {
            if (latestGameContext == null)
            {
                turnUser = currentMatch.Players[0].User;

                turn = Players.Player1;
            }
            else
            {
                turnUser = currentMatch.Players[(int)latestGameContext.UpdatedCount % 2].User;

                turn = (latestGameContext.UpdatedCount % 2 == 0) ? Players.Player1 : Players.Player2;
            }

            currentPiece = (GameObject)Instantiate((turn == Players.Player1) ? prfbCircle : prfbCross);

            currentPiece.transform.parent = piecies.transform;

            currentPiece.GetComponent<Renderer>().material.color = new Color(currentPiece.GetComponent<Renderer>().material.color.r, currentPiece.GetComponent<Renderer>().material.color.g, currentPiece.GetComponent<Renderer>().material.color.b, 0.4f);

            currentPiece.GetComponent<Renderer>().enabled = false;
        }
        public void UpdateCell()
        {
            tagLabel.gameObject.SetActive(false);

            userNameMatching.rectTransform.sizeDelta = userNameSetting.rectTransform.sizeDelta = normalSize;

            if (parentPage.State != AUIMatchMaking.Status.Matching)
            {
                goMatching.SetActive(false);

                goSetting.SetActive(true);
            }
            else
            {
                goMatching.SetActive(true);

                goSetting.SetActive(false);
            }

            buttonInfo.gameObject.SetActive(Player != null && !string.IsNullOrEmpty(Player.User.Id));

            if (Player != null && !string.IsNullOrEmpty(Player.User.Id))
            {
                if (postUser == null || postUser.Id != Player.User.Id)
                {
                    userNameMatching.text = userNameSetting.text = Player.User.Name;
                }

                postUser = Player.User;

                if (Player.User.Id == FAS.CurrentUser.Id)
                {
                    tagLabel.gameObject.SetActive(true);

                    foreach (GameObject go in tagLabelSpaces)
                        go.SetActive(true);

                    tagText.text = FASText.Get("You");

                    tagLabel.color = tagText.color = tagMeColor;

                    //userNameMatching.rectTransform.sizeDelta = userNameSetting.rectTransform.sizeDelta = taggedSize;
                }
                else if (Player.User.FriendStatus == Models.User.FriendStatuses.Friend)
                {
                    tagLabel.gameObject.SetActive(true);

                    foreach (GameObject go in tagLabelSpaces)
                        go.SetActive(true);

                    tagText.text = FASText.Get("Friend");

                    tagLabel.color = tagText.color = tagFriendColor;

                    //userNameMatching.rectTransform.sizeDelta = userNameSetting.rectTransform.sizeDelta = taggedSize;
                }
                else
                {
                    tagLabel.gameObject.SetActive(false);

                    foreach (GameObject go in tagLabelSpaces)
                        go.SetActive(false);
                }

                //buttonInfo.gameObject.SetActive(true);

                if (parentPage.State == AUIMatchMaking.Status.Matching)
                {
                    //buttonInfo.gameObject.SetActive(false);

                    if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Invited)
                    {
                        matchingStatus.text = FASText.Get("PlayerStatusInvited");

                        matchingStatus.color = invitingColor;
                    }
                    else if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Accepted)
                    {
                        matchingStatus.text = FASText.Get("PlayerStatusAccepted");

                        matchingStatus.color = joinedColor;
                    }
                    else if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Cancelled)
                    {
                        matchingStatus.text = FASText.Get("PlayerStatusCancelled");

                        matchingStatus.color = cancelColor;
                    }
                    else if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Matching)
                    {
                        matchingStatus.text = FASText.Get("PlayerStatusMatching");

                        matchingStatus.color = joinedColor;
                    }
                    else if (Player.State == Fresvii.AppSteroid.Models.Player.Status.Declined)
                    {
                        matchingStatus.text = FASText.Get("PlayerStatusDeclined");

                        matchingStatus.color = cancelColor;
                    }
                }

                foreach (GameObject go in infoButtonSpaces)
                    go.SetActive(true);

            }
            else if (parentPage.State != AUIMatchMaking.Status.Matching)
            {
                foreach (GameObject go in infoButtonSpaces)
                        go.SetActive(false);

                tagLabel.gameObject.SetActive(false);

                foreach (GameObject go in tagLabelSpaces)
                    go.SetActive(false);

                userNameSetting.text = FASText.Get("InviteFriend");
            }
            else if (parentPage.State == AUIMatchMaking.Status.Matching && string.IsNullOrEmpty(Player.User.Id))
            {
                foreach (GameObject go in infoButtonSpaces)
                    go.SetActive(false);

                tagLabel.gameObject.SetActive(false);

                foreach (GameObject go in tagLabelSpaces)
                    go.SetActive(false);

                goMatching.SetActive(false);

                goSetting.SetActive(true);

                userNameSetting.text = FASText.Get("AutoMatch");
            }

            buttonCell.interactable = (parentPage.State == AUIMatchMaking.Status.Setting);
        }
        public void OnProfileTapped()
        {
            if (Group.Pair)
            {
                frameProfile = ((GameObject)Instantiate(prfbGUIFrameUserProfile)).GetComponent<FresviiGUIFrame>();

                if (Other != null)
                {
                    frameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(Other);
                }
                else
                {
                    foreach (Fresvii.AppSteroid.Models.Member member in Group.Members)
                    {
                        if (member.Id != FAS.CurrentUser.Id)
                        {
                            Other = member.ToUser();
                        }
                    }

                    frameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(Other);
                }

                Debug.Log(Other.Id + ", " + Other.ProfileImageUrl);

                frameProfile.Init(null, postFix, scaleFactor, this.GuiDepth - 10);

                frameProfile.transform.parent = this.transform;

                frameProfile.SetDraw(true);

                frameProfile.PostFrame = this;

                this.Tween(Vector2.zero, new Vector2(-Screen.width, 0.0f), delegate()
                {
                    this.SetDraw(false);
                });

                frameProfile.Tween(new Vector2(Screen.width, 0.0f), Vector2.zero, delegate() { });
            }
        }
        public void SetInitCheckedUser(Fresvii.AppSteroid.Models.User user)
        {
            if (user != null)
            {
                initCheckedUser = user;

                AddFriendToGroup(initCheckedUser, null);
            }
        }
        void GetUser()
        {
            FASUser.GetUser(Friend.Id, (_user, _error) =>
            {
                if (this == null) return;

                if (_error == null)
                {
                    this.user = _user;

                    userIcon.Set(user.ProfileImageUrl);

                    userName.text = user.Name;
                }
                else
                {
                    Invoke("GetUser", 3f);
                }
            });
        }
 public void SetCurrentUser(Fresvii.AppSteroid.Models.User user)
 {
     currentUser = user;
 }
        public void Init(Texture2D appIcon, string postFix, float scaleFactor, int guiDepth, FresviiGUIChat frameChat)
        {
            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                guiStyleTitle.font = null;

                guiStyleTitle.fontStyle = FontStyle.Bold;

                guiStyleBackButton.font = null;

                guiStyleDoneButton.font = null;
            }

            this.frameChat = frameChat;

            this.other = frameChat.Other;

            this.scaleFactor = scaleFactor;

            this.postFix = postFix;

            this.GuiDepth = guiDepth;

            this.guiDepth = guiDepth;

            palette = FresviiGUIColorPalette.Palette;

            texCoordsMenu = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.NavigationBarBackground);

            texCoordsBorderLine = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.NavigationBarUnderLine);

            this.backIcon = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.BackIconTextureName + postFix, false);

            this.navDownIcon = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.NavMenuTextureName + postFix, false);

            height *= scaleFactor;

            guiStyleTitle.fontSize = (int)(titleFontSize * scaleFactor);

            this.popUpOffset *= scaleFactor;

            guiStyleTitle.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.NavigationBarTitle);

            guiStyleDoneButton.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.NavigationBarPositive);

            hMargin *= scaleFactor;

            vMargin *= scaleFactor;

            editButtonPosition = FresviiGUIUtility.RectScale(editButtonPosition, scaleFactor);

            navButtonPosition = FresviiGUIUtility.RectScale(navButtonPosition, scaleFactor);

            callIconPosition = FresviiGUIUtility.RectScale(callIconPosition, scaleFactor);

            iconColor = colorNormal = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.NavigationBarNormal);

            guiStyleDoneButton.fontSize = (int)(guiStyleDoneButton.fontSize * scaleFactor);

            guiStyleDoneButton.padding = FresviiGUIUtility.RectOffsetScale(guiStyleDoneButton.padding, scaleFactor);

            if (this.other != null)
            {
                this.title = FresviiGUIUtility.Truncate(other.Name, guiStyleTitle, Screen.width - vMargin * 4f - backIcon.width - navDownIcon.width, "...");
            }
            else
            {
                if (frameChat.Group.Members == null)
                {
                    frameChat.Group.FetchMembers((error) =>
                    {
                        if (error == null)
                        {
                            SetMemberNames();
                        }
                    });
                }
                else if (frameChat.Group.Members.Count == 0)
                {
                    frameChat.Group.FetchMembers(delegate(Fresvii.AppSteroid.Models.Error error)
                    {
                        if (error == null)
                        {
                            SetMemberNames();
                        }
                    });
                }
                else
                {
                    SetMemberNames();
                }
            }

            CalcLayout();

            if (frameChat.Group != null)
            {
                if (!frameChat.Group.Pair)
                    enableEditMember = true;
            }
        }
    void OnGUI()
    {
        int space = 10;
        int largeLength = Mathf.Max(Screen.height, Screen.width);
        int lineHeight = largeLength / 12;

        int logAreaHeight = largeLength / 3;

        guiSkin.label.fontSize = lineHeight / 3;
        guiSkin.button.fontSize = lineHeight / 3;
        guiSkin.button.fixedHeight = lineHeight;
        guiSkin.button.fixedHeight = Screen.width / 5;
        guiSkin.textArea.fontSize = lineHeight / 3;

        guiSkin.verticalScrollbar.fixedWidth = 0;
        guiSkin.horizontalScrollbar.fixedWidth = 0;

        guiSkin.textField.fontSize = lineHeight / 3;
        guiSkin.textField.fixedHeight = lineHeight;

        GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));

        #region Log

        logScrollPosition = GUILayout.BeginScrollView(logScrollPosition, guiSkin.scrollView, GUILayout.Height(logAreaHeight));
            GUILayout.Label("---------- Log ----------", guiSkin.label);
            GUILayout.Space(space);
            GUILayout.Label(logMessage, guiSkin.textArea, GUILayout.Height(lineHeight * 10));
        GUILayout.EndScrollView();

        #endregion

        uiScrollPosition = GUILayout.BeginScrollView(uiScrollPosition, false, false, guiSkin.horizontalScrollbar, guiSkin.verticalScrollbar, guiSkin.scrollView);

        #region Buttons

        #region CommonService
        if (mode == GUIMode.CommonService)
        {
            if (modeChanged)
            {
                uiScrollPosition = Vector2.zero;

                modeChanged = false;
            }

            GUILayout.BeginHorizontal();

            GUILayout.Label("Tabs GUI", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("Show", guiSkin.button))
            {
                FASGui.ShowGUI(FASGui.Mode.Forum | FASGui.Mode.Leaderboards | FASGui.Mode.GroupMessage | FASGui.Mode.MyProfile, FASGui.Mode.Forum);
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("Match making (Everyone)", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("Show", guiSkin.button))
            {
                SetMatchMakingParameter();

                FASGui.ShowMatchMakingGui((uint)matchMinMemberNum, (uint)matchMaxMemberNum, null, null, null, FASMatchMaking.Recipient.Everyone, "");
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("Match making (Friend Only)", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("Show", guiSkin.button))
            {
                SetMatchMakingParameter();

                FASGui.ShowMatchMakingGui((uint)matchMinMemberNum, (uint)matchMaxMemberNum, null, null, null, FASMatchMaking.Recipient.FriendOnly, "");
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("MatchMaking Min Number(2-16)", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            matchMemberMinNumString = GUILayout.TextField(matchMemberMinNumString, guiSkin.textField);

            GUILayout.EndHorizontal();

            GUILayout.Space(space * 4f);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("MatchMaking Max Number(2-16)", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            matchMemberMaxNumString = GUILayout.TextField(matchMemberMaxNumString, guiSkin.textField);

            GUILayout.EndHorizontal();

            GUILayout.Space(space * 4f);

            //-----------------------------------------------
        #if UNITY_IOS
            GUILayout.BeginHorizontal();

            GUILayout.Label("Video Record", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button((FASPlayVideo.IsRecording()) ? "Stop" : "Start", guiSkin.button))
            {
                if (FASVideo.isRecording)
                {
                    FASPlayVideo.StopRecording();
                }
                else
                {
                    FASPlayVideo.StartRecording();
                }
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("Latest Video Sharing", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("Share", guiSkin.button))
            {
                if (!FASPlayVideo.ShowLatestVideoSharingGUI(Application.loadedLevelName))
                {
                    Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog("Error : Recorded video does not exist", delegate(bool del) { });
                }
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);
        #endif
            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("Report Score random(1,2000)", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("Report", guiSkin.button))
            {
                if (FASUser.IsLoggedIn())
                {
                    if (this.leaderboard == null)
                    {
                        if (string.IsNullOrEmpty(leaderboardId))
                        {
                            logMessage = "leaderboardId is null or empty";

                            return;
                        }

                        FASLeaderboard.GetLeaderboard(leaderboardId, delegate(Fresvii.AppSteroid.Models.Leaderboard leaderboard, Fresvii.AppSteroid.Models.Error error)
                        {
                            if (error == null)
                            {
                                this.leaderboard = leaderboard;

                                FASLeaderboard.ReportScore(leaderboard.Id, ((Random.Range(1, 10) <= 1) ? Random.Range(1, 2000) : Random.Range(1, 1000)), delegate(Fresvii.AppSteroid.Models.Score score, Fresvii.AppSteroid.Models.Error error2)
                                {
                                    if (error2 == null)
                                    {
                                        logMessage = "Report score : " + score.Value;
                                    }
                                    else
                                    {
                                        logMessage = "Report score error";

                                        Debug.LogError(error2.ToString());
                                    }
                                });
                            }
                            else
                            {
                                logMessage = error.ToString();
                            }
                        });
                    }
                    else
                    {
                        FASLeaderboard.ReportScore(this.leaderboard.Id, ((Random.Range(1, 10) <= 1) ? Random.Range(1, 2000) : Random.Range(1, 1000)), delegate(Fresvii.AppSteroid.Models.Score score, Fresvii.AppSteroid.Models.Error error2)
                        {
                            if (error2 == null)
                            {
                                Debug.Log(score.User.Name + " : " + score.Value);

                                logMessage = "Report score : " + score.Value;
                            }
                            else
                            {
                                logMessage = "Report score error";

                                Debug.LogError(error2.ToString());
                            }
                        });
                    }
                }
                else
                {
                    logMessage = "Not login";
                }
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("Get Custom Messages", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("Get", guiSkin.button))
            {
                if (FASUser.IsLoggedIn())
                {
                    FASCustomMessage.GetCustomMessageList(delegate(IList<Fresvii.AppSteroid.Models.CustomMessage> customMessges, Fresvii.AppSteroid.Models.ListMeta meta, Fresvii.AppSteroid.Models.Error error)
                    {
                        Debug.Log("============ Custom Messages == " + meta.TotalCount);

                        foreach (Fresvii.AppSteroid.Models.CustomMessage cm in customMessges)
                        {
                            Debug.Log(cm.Action);

                            if (cm.Params != null)
                            {

                                foreach (DictionaryEntry de in cm.Params)
                                {
                                    Debug.Log(de.Key + ", " + de.Value);
                                }
                            }
                        }
                    });

                }
                else
                {
                    logMessage = "Not login";
                }
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            GUILayout.Space(space * 3f);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("LogIn", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("LogIn", guiSkin.button))
            {
                logMessage = "LogIn start";

                if (currentUser != null)
                    FASUser.LogIn(currentUser.Id, currentUser.Token, true, OnSignIn);
                else
                    logMessage = "Not sign up";
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(2f * space);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("User Name", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            userName = GUILayout.TextField(userName, guiSkin.textField);

            GUILayout.EndHorizontal();

            GUILayout.Space(space * 4f);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

                GUILayout.Label("SignUp", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

                GUILayout.Space(space);

                if (GUILayout.Button("SignUp", guiSkin.button))
                {
        #if !UNITY_EDITOR
                    Fresvii.AppSteroid.Util.DialogManager.Instance.SetLabel("OK", "Cancel", "Close");

                    Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSelectDialog("Sign up : Name = " + userName, delegate(bool del)
                    {
                        if(del)
                        {
        #endif
                            logMessage = "SignUp start";

        #if UNITY_IOS
        #if UNITY_5
                            Handheld.SetActivityIndicatorStyle(UnityEngine.iOS.ActivityIndicatorStyle.Gray);
        #else
                            Handheld.SetActivityIndicatorStyle(iOSActivityIndicatorStyle.Gray);
        #endif
        #elif UNITY_ANDROID
                            Handheld.SetActivityIndicatorStyle(AndroidActivityIndicatorStyle.Small);
        #endif
                            Handheld.StartActivityIndicator();

                            FASUser.LogOut();

                            FASUser.SignUp(userName, delegate(Fresvii.AppSteroid.Models.User user, Fresvii.AppSteroid.Models.Error error)
                            {
                                Handheld.StopActivityIndicator();

                                if (error != null)
                                {
                                    logMessage = error.ToString();

                                    Debug.LogError(logMessage);
                                }
                                else
                                {
                                    logMessage = "Sign up success: " + userName;

                                    currentUser = user;
                                }
                            });
        #if !UNITY_EDITOR
                        }
                    });
        #endif
                }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("LogOut", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("LogOut", guiSkin.button))
            {
                logMessage = "Log out";
                if (currentUser != null)
                    FASUser.LogOut();
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("Register Notification", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("Register", guiSkin.button))
            {
                logMessage = "Register Notification";

                FASNotification.RegisterRemoteNotification((info, error) =>
                {
                    if (error != null)
                    {
                        Debug.LogError(error.ToString());

                        logMessage = "Register Notification Error : " + error.ToString();
                    }
                    else
                    {
                        Debug.Log("#### Register Notification Success : " + info.CertificateType);

                        logMessage = "Register Notification Success";
                    }
                });
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            //-----------------------------------------------
            GUILayout.BeginHorizontal();

            GUILayout.Label("Unregister Notification", guiSkin.label, GUILayout.Height(lineHeight), GUILayout.Width(Screen.width * .55f));

            GUILayout.Space(space);

            if (GUILayout.Button("Unregister", guiSkin.button))
            {
                logMessage = "Unregister Notification";

                FASNotification.UnregisterRemoteNotification(OnUnregisterRemoteNotification);
            }

            GUILayout.EndHorizontal();

            GUILayout.Space(space);

            //-----------------------------------------------
            if (GUILayout.Button("In Game Chat", guiSkin.button))
            {
                mode = GUIMode.Groups;

                modeChanged = true;
            }
            GUILayout.Space(space);

            // ----------------------
        }
        #endregion
        else if (mode == GUIMode.Groups)
        {
            if (modeChanged)
            {
                uiScrollPosition = Vector2.zero;

                modeChanged = false;

                FASGroup.GetGroupList(delegate(IList<Fresvii.AppSteroid.Models.Group> groups, Fresvii.AppSteroid.Models.Error error)
                {
                    if(error == null){

                        this.groups = groups;

                        foreach(Fresvii.AppSteroid.Models.Group group in this.groups)
                        {
                            group.FetchMembers(delegate {});
                        }
                    }
                    else
                    {
                        logMessage = error.ToString();
                        Debug.LogError(error.ToString());
                    }
                });
            }

            if(this.groups != null)
            {
                foreach(Fresvii.AppSteroid.Models.Group group in this.groups){

                    GUILayout.Space(space);

                    string members = "";

                    if(group.Members != null)
                    {
                        foreach(Fresvii.AppSteroid.Models.Member member in group.Members)
                        {
                            members += member.Name + ", ";
                        }
                    }

                    if (GUILayout.Button(members, guiSkin.button))
                    {
                        modeChanged = true;

                        mode = GUIMode.InGameChat;

                        inGameChatGroup = group;
                    }
                }
            }

            GUILayout.Space(space * 2f);

            if (GUILayout.Button("Back", guiSkin.button))
            {
                mode = GUIMode.CommonService;

                modeChanged = true;
            }
        }

        else if (mode == GUIMode.InGameChat)
        {
            if (modeChanged)
            {
                uiScrollPosition = Vector2.zero;

                modeChanged = false;

                logMessage = "";
            }

            GUILayout.Space(space);

            GUILayout.Label("Chat", guiSkin.label, GUILayout.Height(lineHeight));

            chat = GUILayout.TextArea(chat, guiSkin.textArea, GUILayout.Height(lineHeight));

            GUILayout.Space(space);

            if (GUILayout.Button("Send", guiSkin.button))
            {
                FASGroup.SendGroupMessageInGames(inGameChatGroup.Id, chat, delegate(Fresvii.AppSteroid.Models.GroupMessage groupMessage, Fresvii.AppSteroid.Models.Error error)
                {
                    if (error != null)
                    {
                        if (FASConfig.Instance.logLevel <= FAS.LogLevels.Error)
                            Debug.LogError(error.ToString());
                    }
                    else
                    {
                        if (FASConfig.Instance.logLevel <= FAS.LogLevels.Verbose)
                            Debug.Log(groupMessage.Text);
                    }
                });

                chat = "";
            }

            GUILayout.Space(space * 2f);

            if (GUILayout.Button("Back", guiSkin.button))
            {
                mode = GUIMode.CommonService;

                modeChanged = true;
            }
        }

        GUILayout.EndScrollView();

        #endregion

        GUILayout.EndArea();
    }
        void GetUser()
        {
            FASUser.GetUser(this.Friend.Id, (user, error) =>
            {
                if (error == null)
                {
                    this.user = user;

                    userIcon.Set(user.ProfileImageUrl);

                    userName.text = user.Name;
                }
                else
                {
                    Invoke("GetUser", 3f);
                }
            });
        }
        public void Init(Fresvii.AppSteroid.Models.User user, float scaleFactor, bool isHiddenCard, FresviiGUIFriendRequests guiFriendRequest)
        {
            this.User = user;

            this.guiFriendRequest = guiFriendRequest;

            this.isHiddenCard = isHiddenCard;

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                guiStyleUserName.font = null;

                guiStyleUserName.fontStyle = FontStyle.Bold;

                guiStyleDescription.font = null;

                guiStyleButtonAdd.font = null;

                guiStyleButtonHide.font = null;
            }

            palette = FresviiGUIColorPalette.Palette;

            userIconPosition = FresviiGUIUtility.RectScale(userIconPosition, scaleFactor);

            userNamePosition = FresviiGUIUtility.RectScale(userNamePosition, scaleFactor);

            userDescriptionPosition = FresviiGUIUtility.RectScale(userDescriptionPosition, scaleFactor);

            sideMargin = userIconPosition.x;

            hMargin *= scaleFactor;

            buttonSize *= scaleFactor;

            guiStyleUserName.fontSize = (int)(guiStyleUserName.fontSize * scaleFactor);

            guiStyleUserName.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardUserName);

            guiStyleDescription.fontSize = (int)(guiStyleDescription.fontSize * scaleFactor);

            guiStyleDescription.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardText1);

            guiStyleButtonAdd.fontSize = (int)(guiStyleButtonAdd.fontSize * scaleFactor);

            guiStyleButtonAdd.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardAddButtonText);

            guiStyleButtonHide.fontSize = (int)(guiStyleButtonHide.fontSize * scaleFactor);

            guiStyleButtonHide.normal.textColor = FresviiGUIColorPalette.GetColor(FresviiGUIColorPalette.CardHideButtonText);

            texCoordsBackground = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardBackground);
        }
        void OnFriendshipRequestCreated(Fresvii.AppSteroid.Models.User user)
        {
            if (user.Id == this.User.Id)
            {
                FASUser.GetUser(User.Id, (_user, _error) =>
                {
                    if (_error == null && this != null)
                    {
                        this.User = _user;

                        SetCurrentUserInfo();
                    }
                });
            }
        }
        IEnumerator Init()
        {
            requestedPanel.SetActive(false);

            while (!AUIManager.Instance.Initialized)
            {
                yield return 1;
            }

            while (User == null)
            {
                yield return 1;
            }

            while (frameTween.Animating)
            {
                yield return 1;
            }

            FASUser.GetUser(User.Id, (user, error) =>
            {
                if (error == null)
                {
                    this.User = user;

                    SetCurrentUserInfo();
                }
            });

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

            userIds.Add(User.Id);

            FASPlayStats.GetStatList(userIds.ToArray(), (stats, meta, error) =>
            {
                if (error != null)
                {
                    Debug.LogError(error.ToString());
                }
                else
                {
                    int i = 0;

                    foreach (var stat in stats)
                    {
                        GameObject statCell = Instantiate(prfbAUIStatCell) as GameObject;

                        var auiStatCell = statCell.GetComponent<AUIStatCell>();

                        auiStatCell.Set(stat, cellColors[i % cellColors.Length]);

                        statCell.transform.SetParent(statsNode, false);

                        i++;
                    }

                    if (!statInitialized)
                    {
                        int addCount = (3 - stats.Count % 3);

                        addCount %= 3;

                        for (int j = 0; j < addCount; j++)
                        {
                            GameObject statCell = Instantiate(prfbAUIStatCell) as GameObject;

                            statCell.transform.SetParent(statsNode, false);
                        }

                        statInitialized = true;
                    }

                    auiGridLayoutHelper.CalcSize();
                }
            });

            FASUtility.SendPageView("pv.my_page", this.User.Id, System.DateTime.UtcNow, (e) =>
            {
                if (e != null)
                    Debug.LogError(e.ToString());
            });
        }
        public void Set(Fresvii.AppSteroid.Models.User user, string backButton, AUIFrame parentFrameTween)
        {
            this.User = user;

            this.parentFrameTween = parentFrameTween;

            backButtonText.text = backButton;

            SetCurrentUserInfo();

            if (this.User.Official)
            {
                 buttonCall.gameObject.SetActive(false);
            }
        }
        public void SetPairUser(Fresvii.AppSteroid.Models.User other)
        {
            IsPair = true;

            this.Other = other;
        }
        public void SetTitle(Fresvii.AppSteroid.Models.User user, Fresvii.AppSteroid.Models.ListMeta meta)
        {
            this.user = user;

            this.friendsListMeta = meta;

            LayoutTitle();
        }
    IEnumerator Start()
    {
        if(FASGesture.Instance == null)
        {
            gameObject.AddComponent<FASGesture>();
        }

        logMessage = "SDK Version: " + FAS.Version + "\n";

        logMessage += "UUID: " + FASConfig.Instance.appId + "\n\n";

        signedUpUsers = FASUser.LoadSignedUpUsers();

        if (signedUpUsers.Count > 0)
        {
            currentUser = signedUpUsers[signedUpUsers.Count - 1]; // saved user has only id and token data.

            logMessage += "current user id: " + currentUser.Id;

            Debug.Log("current user id: " + currentUser.Id);
        }
        else
        {
            Debug.Log("#########  Save User is none");
        }

        FASGui.SetLeaderboardId(leaderboardId);

        while (string.IsNullOrEmpty(FAS.Host))
        {
            yield return 1;
        }

        logMessage = "SDK Version: " + FAS.Version + "\n";

        logMessage += "UUID: " + FASConfig.Instance.appId + "\n\n";

        logMessage += "Host: " + FAS.Host + "\n";

        if (signedUpUsers.Count > 0)
        {
            currentUser = signedUpUsers[signedUpUsers.Count - 1]; // saved user has only id and token data.

            logMessage += "current user id: " + currentUser.Id;
        }
    }
        void GetAccout()
        {
            FASUser.GetAccount(delegate(Fresvii.AppSteroid.Models.User user, Fresvii.AppSteroid.Models.Error error)
            {
                loadingSpinner.Hide();

                if (error != null)
                {
                    FASUser.GetAccountFromCache(delegate(Fresvii.AppSteroid.Models.User _user, Fresvii.AppSteroid.Models.Error _error)
                    {
                        currentUser = _user;

						if(currentUser == null) return;

                        userCodeContent = new GUIContent(currentUser.UserCode);

                        isReady = true;

                        FASFriendship.GetFriendshipRequestedUsersList(currentUser.Id, OnGetFriendshipRequestedUsersList);

                        GetAccountFriendList();
                    });
                }
                else
                {
                    currentUser = user;

                    userCodeContent = new GUIContent(currentUser.UserCode);

                    isReady = true;

                    FASFriendship.GetFriendshipRequestedUsersList(currentUser.Id, OnGetFriendshipRequestedUsersList);

                    GetAccountFriendList();
                }

                CalcLayout();
            });
        }
        void GetUser()
        {
            FASUser.GetUser(friend.Id, delegate(Fresvii.AppSteroid.Models.User _user, Fresvii.AppSteroid.Models.Error _error)
            {
                if (_error == null)
                {
                    this.user = _user;

                    Select(IsSelected);
                }
            });
        }
        public void SetUser(Fresvii.AppSteroid.Models.User user)
        {
			hasError = false;

            if (textureUserProfile != null)
                DestroyImmediate(textureUserProfile);

            FresviiGUIManager.Instance.resourceManager.TextureFromCacheOrDownloadOrMemory(user.ProfileImageUrl, true, delegate(Texture2D tex)
            {
                textureUserProfile = tex;
            });

            this.user = user;

            userInfoEnable = false;

            FASUser.GetUser(user.Id, delegate(Fresvii.AppSteroid.Models.User _user, Fresvii.AppSteroid.Models.Error error)
            {
                if (error != null)
                {
					this.user = null;

					hasError = true;

                    Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("UnknownError"), delegate(bool del) { });

					BackToPostFrame();

					return;
                }

                this.user = _user;

                userInfoEnable = true;

                scrollPosition = Vector2.zero;

                CalcLayout();
				                
            });

            userCodeContent = new GUIContent(this.user.UserCode);

			GetUserFriendList();
        }
        void GetUser()
        {
            FASUser.GetUser(friend.Id, delegate(Fresvii.AppSteroid.Models.User _user, Fresvii.AppSteroid.Models.Error _error)
            {
                if(_error == null)
                {
                    this.user = _user;

                    isMe = (this.user.Id == FAS.CurrentUser.Id);

                    if (isMe)
                    {
                        textureTagYou = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.TagYou + FresviiGUIManager.postFix, false);

                        tagString = FresviiGUIText.Get("You");
                    }
                }
            });
        }
        public void SetUserIcons()
        {
            if (Group.Pair && Group.MessageMembers != null)
            {
                for (int i = 0; i < Group.MessageMembers.Count; i++)
                {
                    if (Group.MessageMembers[i].Id != FAS.CurrentUser.Id)
                    {
                        other = Group.MessageMembers[i].ToUser();

                        FresviiGUIManager.Instance.resourceManager.TextureFromCacheOrDownloadOrMemory(Group.MessageMembers[i].ProfileImageUrl, true, delegate(Texture2D tex)
                        {
                            if (!userIcons.ContainsKey(Group.MessageMembers[i].ProfileImageUrl))
                            {
                                userIcons.Add(Group.MessageMembers[i].ProfileImageUrl, tex);
                            }
                        });

                        break;
                    }
                }
            }
            else if (Group.MessageMembers != null)
            {
                if (Group.MessageMembers.Count >= 1)
                {
                    FresviiGUIManager.Instance.resourceManager.TextureFromCacheOrDownloadOrMemory(Group.MessageMembers[0].ProfileImageUrl, true, delegate(Texture2D tex)
                                                                                   {
                        if (!userIcons.ContainsKey(Group.MessageMembers[0].ProfileImageUrl))
                        {
                            userIcons.Add(Group.MessageMembers[0].ProfileImageUrl, tex);
                        }
                    });
                }

                if (Group.MessageMembers.Count >= 2)
                {
                    FresviiGUIManager.Instance.resourceManager.TextureFromCacheOrDownloadOrMemory(Group.MessageMembers[1].ProfileImageUrl, true, delegate(Texture2D tex)
                                                                                   {
                        if (!userIcons.ContainsKey(Group.MessageMembers[1].ProfileImageUrl))
                        {
                            userIcons.Add(Group.MessageMembers[1].ProfileImageUrl, tex);
                        }
                    });
                }

                if (Group.MessageMembers.Count >= 3)
                {
                    FresviiGUIManager.Instance.resourceManager.TextureFromCacheOrDownloadOrMemory(Group.MessageMembers[2].ProfileImageUrl, true, delegate(Texture2D tex)
                    {
                        if (!userIcons.ContainsKey(Group.MessageMembers[2].ProfileImageUrl))
                        {
                            userIcons.Add(Group.MessageMembers[2].ProfileImageUrl, tex);
                        }
                    });
                }
            }

            SetGroupMemberNames();

            postScreenWidth = 0f;
        }
 void GetUser()
 {
     FASUser.GetUser(member.Id, delegate(Fresvii.AppSteroid.Models.User _user, Fresvii.AppSteroid.Models.Error _error)
     {
         if (_error == null)
         {
             this.user = _user;
         }
     });
 }
        public override void Init(Texture2D appIcon, string postFix, float scaleFactor, int guiDepth)
        {
            ControlLock = false;

            this.GuiDepth = guiDepth;

            if (Application.platform == RuntimePlatform.IPhonePlayer)
            {
                guiStyleLabelTo.font = null;

                guiStyleLableToUsers.font = null;
            }

            textureCoordsBackground = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.MainBackground);

            groupMessageCreateTopMenu = GetComponent<FresviiGUIGroupMessageCreateTop>();

            groupMessageCreateTopMenu.Init(appIcon, postFix, scaleFactor, GuiDepth - 1, this);

            guiStyleLabelTo.fontSize = (int)(guiStyleLabelTo.fontSize * scaleFactor);

            guiStyleLabelTo.padding = FresviiGUIUtility.RectOffsetScale(guiStyleLabelTo.padding, scaleFactor);

            guiStyleLableToUsers.fontSize = (int)(guiStyleLableToUsers.fontSize * scaleFactor);

            addCommentBottomMenu = GetComponent<FresviiGUIAddCommentBottomMenu>();

            addCommentBottomMenu.Init(postFix, scaleFactor, GuiDepth - 1, this, AddComment);

            addCommentBottomMenu.autoSendImageLoaded = true;

            this.scaleFactor = scaleFactor;

            toMargin *= scaleFactor;

            loadingSpinnerSize *= scaleFactor;

            sideMargin *= scaleFactor;

            topMargin = scaleFactor;

            heightMessageTo *= scaleFactor;

            scrollPosition.y = 0.0f;

            textureCoordsTo = FresviiGUIColorPalette.GetTextureCoods(FresviiGUIColorPalette.CardBackground);

            textureCheckMark = FresviiGUIManager.Instance.resourceManager.LoadTextureFromResource(FresviiGUIConstants.ResouceTextureFolderName + "/" + FresviiGUIConstants.IconFriendTextureName + postFix, false);

            FASFriendship.GetAccountFriendList(OnGetFriends);

            contentLabelTo = new GUIContent(FresviiGUIText.Get("To"));

            loadingSpinnerPosition = new Rect(Screen.width * 0.5f - loadingSpinnerSize.x * 0.5f, Screen.height * 0.5f - loadingSpinnerSize.y * 0.5f, loadingSpinnerSize.x, loadingSpinnerSize.y);

            loadingSpinner = Fresvii.AppSteroid.Gui.LoadingSpinner.Show(loadingSpinnerPosition, GuiDepth - 10);

            SetScrollSlider(scaleFactor * 2.0f);

            addCommentBottomMenu.SetSendEnableAtAction(false, FresviiGUIText.Get("Error"), FresviiGUIText.Get("NoSelectedMember"));

            FASUser.GetOfficialUser((user, error) =>
            {
                if (error == null)
                {
                    OfficialUser = user;
                }
            });
        }
        public void SetUser(Fresvii.AppSteroid.Models.User user)
        {
            this.user = user;

            IsMyList = (user.Id == FAS.CurrentUser.Id);
        }
        void GetUser()
        {
            FASUser.GetUser(this.Member.Id, (_user, _error) =>
            {
                if (_error == null)
                {
                    this.user = _user;
                }
                else
                {
                    Debug.LogError(_error.ToString());

                    Invoke("GetUser", 3f);
                }
            });
        }
        public void SetCurrentUserProfile(Fresvii.AppSteroid.Models.User user, Texture2D userProfileImage)
        {
            this.me = user;

            this.userProfileImage = userProfileImage;

            inputUsername = me.Name;

            inputDescription = me.Description;
        }