예제 #1
0
 private void DeselectCurrentPanel(bool closeOldPanelImmediately = false)
 {
     if (_selectedFriendPanel)
     {
         _selectedFriendPanel.Deselect(true);
     }
     _selectedFriendPanel = null;
 }
예제 #2
0
 /// <summary>
 /// Used when new friend panel is selected and we need to close old
 /// </summary>
 /// <param name="friendPanel"></param>
 private void SelectedPanelChange(FriendPanel friendPanel)
 {
     if (_selectedFriendPanel == friendPanel)
     {
         return;
     }
     DeselectCurrentPanel();
     _selectedFriendPanel = friendPanel;
 }
예제 #3
0
        /// <summary>
        /// Populating friend list with elements created basing on loaded friends list from database
        /// </summary>
        private void RefreshFriendsListUI(IApiFriendList friends)
        {
            ClearLists();
            foreach (IApiFriend friend in friends.Friends)
            {
                RectTransform content;

                //selecting to which tab should friend panel be instantiated
                switch (friend.State)
                {
                //  Users are friends with each other.
                case 0: content = _friendsContent; break;

                //  This user has sent an invitation and pending acceptance from other user.
                case 1: content = _sentInvitesContent; break;

                //  This user has received an invitation but has not accepted yet.
                case 2: content = _receivedInvitesContent; break;

                //  This user has banned other user.
                case 3: content = _bannedUsersContent; break;

                //  If state is none of upper log error
                default: Debug.LogError("Wrong friend state value: \"" + friend.State + "\" in " + friend.User.Username + "!"); return;
                }
                //instantiating friend panel object
                GameObject  panelGO = Instantiate(_friendPanelPrefab, content) as GameObject;
                FriendPanel panel   = panelGO.GetComponent <FriendPanel>();
                if (panel)
                {
                    //initializing object with FriendList object and friend data
                    panel.Init(friend);
                    panel.OnSelected += SelectedPanelChange;
                    //subscribing to event fired after every successful request to friends list in database
                    panel.OnDataChanged            += ActualizeFriendsList;
                    panel.OnChatStartButtonClicked += StartChatWithUser;
                }
                else
                {
                    Debug.LogError("Invalid friend panel prefab!");
                    Destroy(panelGO);
                }
            }
        }