Esempio n. 1
0
    /// <summary>
    /// 显示群列表
    /// </summary>
    /// <param name="lst"></param>
    public void ShowGroupList(List <ChatGroupEntity> lst)
    {
        SetPageActive(lst.Count > 0 ? m_ExistGroup : m_NoneGroupPage);
        if (lst == null || lst.Count == 0)
        {
            return;
        }

        for (int i = 0; i < m_GroupList.Count; ++i)
        {
            UIItemChatGroup item = m_GroupList[i];
            UIPoolManager.Instance.Despawn(item.transform);
        }
        m_GroupList.Clear();

        for (int i = 0; i < lst.Count; ++i)
        {
            ChatGroupEntity group = lst[i];
            UIItemChatGroup item  = UIPoolManager.Instance.Spawn("UIItemChatGroup").GetComponent <UIItemChatGroup>();
            item.gameObject.SetParent(m_ChatGroupContainer);
            item.SetUI(group.id, group.name, group.avatar /*GetChatGroupHead(group.avatarIndex)*/, group.currMemberCount, group.maxMemberCount, group.roomCount);
            item.SetSelect(false);
            item.SetNewTip(group.hasNewApply);
            m_GroupList.Add(item);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 添加新群
    /// </summary>
    /// <param name="data"></param>
    private void OnAddGroup(TransferData data)
    {
        SetPageActive(m_ExistGroup);
        ChatGroupEntity group = data.GetValue <ChatGroupEntity>("ChatGroup");
        UIItemChatGroup item  = UIPoolManager.Instance.Spawn("UIItemChatGroup").GetComponent <UIItemChatGroup>();

        item.gameObject.SetParent(m_ChatGroupContainer);
        item.SetUI(group.id, group.name, group.avatar /*GetChatGroupHead(group.avatarIndex)*/, group.currMemberCount, group.maxMemberCount, group.roomCount);
        item.SetSelect(false);
        item.SetNewTip(group.hasNewApply);
        m_GroupList.Add(item);
    }
Esempio n. 3
0
    /// <summary>
    /// 显示群信息
    /// </summary>
    /// <param name="lst"></param>
    public void ShowGroup(TransferData data)
    {
        int    groupId                 = data.GetValue <int>("GroupId");
        bool   playerIsOwner           = data.GetValue <bool>("IsOwner");
        bool   playerIsManager         = data.GetValue <bool>("PlayerIsManager");
        bool   hasNewApply             = data.GetValue <bool>("HasNewApply");
        string groupName               = data.GetValue <string>("GroupName");
        int    memberCount             = data.GetValue <int>("MemberCount");
        int    maxMemberCount          = data.GetValue <int>("MaxMemberCount");
        int    ownerId                 = data.GetValue <int>("OwnerId");
        int    avatarIndex             = data.GetValue <int>("AvatarIndex");
        int    cards                   = data.GetValue <int>("CardCount");
        int    waitingCount            = data.GetValue <int>("WaitingRoomCount");
        int    gamingCount             = data.GetValue <int>("GamingRoomCount");
        string groupAvatar             = data.GetValue <string>("GroupAvatar");
        List <TransferData> lstRoom    = data.GetValue <List <TransferData> >("Room");
        List <TransferData> lstMember  = data.GetValue <List <TransferData> >("Member");
        List <TransferData> lstMessage = data.GetValue <List <TransferData> >("Message");
        List <TransferData> lstRecord  = data.GetValue <List <TransferData> >("Record");

        m_GroupId = groupId;
        SetPageActive(m_GroupList.Count > 0 ? m_ExistGroup : m_NoneGroupPage);
        m_DefaultPageRight.gameObject.SetActive(false);
        m_MemberListPage.gameObject.SetActive(true);
        m_GroupInfoPage.gameObject.SetActive(true);
        m_BtnDisband.gameObject.SetActive(playerIsOwner);
        //m_BtnExit.gameObject.SetActive(!playerIsOwner);
        //m_BtnApply.gameObject.SetActive(playerIsOwner);
        //m_NewApply.SetActive(hasNewApply);
        m_BtnManage.gameObject.SetActive(playerIsOwner || playerIsManager);
        m_NewManageTip.SetActive(hasNewApply);
        m_NewMessageTip.SetActive(false);
        m_NewRecordTip.SetActive(false);
        m_TxtGroupName.SafeSetText(groupName);
        m_TxtGroupId.SafeSetText(string.Format("(ID:{0})", groupId.ToString()));
        m_TxtPlayerCount.SafeSetText(string.Format("{0}人", memberCount));
        m_TxtCards.SafeSetText(cards.ToString());
        m_TxtWaitingRoomCount.SafeSetText(waitingCount.ToString());
        m_TxtGamingRoomCount.SafeSetText(gamingCount.ToString());

        for (int i = 0; i < m_GroupList.Count; ++i)
        {
            if (m_GroupList[i].GroupId == groupId)
            {
                m_GroupList[i].SetNewTip(false);
                break;
            }
        }

        for (int i = 0; i < m_MemberList.Count; ++i)
        {
            UIPoolManager.Instance.Despawn(m_MemberList[i].transform);
        }
        m_MemberList.Clear();
        for (int i = 0; i < m_RoomList.Count; ++i)
        {
            UIPoolManager.Instance.Despawn(m_RoomList[i].transform);
        }
        m_RoomList.Clear();
        for (int i = 0; i < m_RoomPlayerList.Count; ++i)
        {
            UIPoolManager.Instance.Despawn(m_RoomPlayerList[i].transform);
        }
        m_RoomPlayerList.Clear();
        for (int i = 0; i < m_MessageList.Count; ++i)
        {
            UIPoolManager.Instance.Despawn(m_MessageList[i].transform);
        }
        m_MessageList.Clear();
        for (int i = 0; i < m_RecordList.Count; ++i)
        {
            UIPoolManager.Instance.Despawn(m_RecordList[i].transform);
        }
        m_RecordList.Clear();
        for (int i = 0; i < lstMember.Count; ++i)
        {
            TransferData     memberData = lstMember[i];
            int              playerId   = memberData.GetValue <int>("PlayerId");
            string           nickname   = memberData.GetValue <string>("Nickname");
            bool             isOnline   = memberData.GetValue <bool>("IsOnline");
            string           avatar     = memberData.GetValue <string>("Avatar");
            bool             isOwner    = memberData.GetValue <bool>("IsOwner");
            bool             isManager  = memberData.GetValue <bool>("IsManager");
            UIItemChatMember item       = UIPoolManager.Instance.Spawn("UIItemChatMember").GetComponent <UIItemChatMember>();
            item.SetUI(groupId, playerId, nickname, isOnline, avatar, ownerId == playerId, isManager, playerIsOwner, playerIsManager);
            item.gameObject.SetParent(m_MemberContainer, true);
            m_MemberList.Add(item);
        }
        for (int i = 0; i < lstMessage.Count; ++i)
        {
            TransferData messageData = lstMessage[i];
            string       avatar      = messageData.GetValue <string>("Avatar");
            byte[]       message     = messageData.GetValue <byte[]>("Message");
            bool         isPlayer    = messageData.GetValue <bool>("IsPlayer");

            UIItemChatGroupMessage item = UIPoolManager.Instance.Spawn("UIItemChatGroupMessage").GetComponent <UIItemChatGroupMessage>();
            item.SetUI(avatar, message.ToUTF8String(), isPlayer);
            item.gameObject.SetParent(m_MessageContainer);
            m_MessageList.Add(item);
        }
        for (int i = 0; i < lstRoom.Count; ++i)
        {
            TransferData roomData = lstRoom[i];
            int          roomId   = roomData.GetValue <int>("RoomId");
            string       gameName = roomData.GetValue <string>("GameName");
            RoomEntityBase.RoomStatus   roomStatus    = roomData.GetValue <RoomEntityBase.RoomStatus>("RoomStatus");
            List <TransferData>         lstRoomPlayer = roomData.GetValue <List <TransferData> >("Player");
            UIItemChatRoom              item          = UIPoolManager.Instance.Spawn("UIItemChatRoom").GetComponent <UIItemChatRoom>();
            List <UIItemChatRoomPlayer> lst           = new List <UIItemChatRoomPlayer>();
            for (int j = 0; j < lstRoomPlayer.Count; ++j)
            {
                TransferData         playerData = lstRoomPlayer[j];
                int                  playerId   = playerData.GetValue <int>("PlayerId");
                string               avatar     = playerData.GetValue <string>("Avatar");
                UIItemChatRoomPlayer itemPlayer = UIPoolManager.Instance.Spawn("UIItemChatRoomPlayer").GetComponent <UIItemChatRoomPlayer>();
                if (playerData == null)
                {
                    itemPlayer.SetUI(groupId, roomId, 0, string.Empty, false);
                }
                else
                {
                    itemPlayer.SetUI(groupId, roomId, playerId, avatar, playerIsOwner);
                }
                lst.Add(itemPlayer);
                m_RoomPlayerList.Add(itemPlayer);
            }
            item.SetUI(groupId, roomId, roomStatus == RoomEntityBase.RoomStatus.Gaming, gameName);
            item.SetPlayer(lst);
            item.gameObject.SetParent(m_RoomContainer, true);
            m_RoomList.Add(item);
        }

        for (int i = 0; i < lstRecord.Count; ++i)
        {
            TransferData          recordData = lstRecord[i];
            UIItemChatGroupRecord item       = UIPoolManager.Instance.Spawn("UIItemChatGroupRecord").GetComponent <UIItemChatGroupRecord>();
            item.SetUI(recordData);
            item.gameObject.SetParent(m_RecordContainer);
            m_RecordList.Add(item);
        }

        m_CurrentGroup.SetSelect(true);
        m_CurrentGroup.SetNewTip(false);
        m_CurrentGroup.SetUI(groupId, groupName, groupAvatar, memberCount, maxMemberCount, lstRoom.Count);



        if (m_GroupManagePage.gameObject.activeInHierarchy)
        {
            if (!m_BtnManage.gameObject.activeInHierarchy)
            {
                m_GroupManagePage.gameObject.SetActive(false);
                m_GroupRoomPage.gameObject.SetActive(true);
            }
            else
            {
                SendNotification("btnChatGroupViewApply", m_GroupId);
            }
        }
    }