示例#1
0
        /// <summary>
        /// Updates the list of members of a clan.
        /// Instantiates UI containing found user data.
        /// If local user is a part of this clan, updates their <see cref="MyUserState"/>
        /// using <see cref="SetMyState(ClanUserState)"/>.
        /// </summary>
        private void OnClanUserListReceived(List <IGroupUserListGroupUser> userList)
        {
            _clanMembers.Clear();
            // Removing previous results
            foreach (Transform child in _clanUserList)
            {
                Destroy(child.gameObject);
            }

            // Searching through results in order to find local user.
            // If local user belongs to this clan, set their MyUserState
            // Knowing the role of local user in searched clan allows for better UI handling
            ClanUserState myState = ClanUserState.None;

            foreach (IGroupUserListGroupUser user in userList)
            {
                if (user.User.Id == NakamaSessionManager.Instance.Account.User.Id)
                {
                    myState = (ClanUserState)user.State;
                    SetMyState(myState);
                    break;
                }
            }

            // Adding entries for each user found
            foreach (IGroupUserListGroupUser user in userList)
            {
                Debug.Log("Found user in clan: " + user.User.Username);
                ClanUserEntry userEntry = Instantiate(_clanUserEntryPrefab, _clanUserList);
                userEntry.SetUser(user.User, (ClanUserState)user.State, myState, OnUserSelected, OnUserKick, OnUserPromote, OnUserShowProfile);
                _clanMembers.Add(userEntry);
            }
        }
示例#2
0
 /// <summary>
 /// Invoked upon selecting user from clan member list.
 /// Shows user interaction panel.
 /// </summary>
 private void OnUserSelected(ClanUserEntry sender)
 {
     if (_selectedMember == sender)
     {
         _selectedMember.HideInteractionPanel();
         _selectedMember = null;
     }
     else
     {
         if (_selectedMember != null)
         {
             _selectedMember.HideInteractionPanel();
         }
         _selectedMember = sender;
         _selectedMember.ShowInteractionPanel();
     }
 }