Beispiel #1
0
    /// <summary>
    /// 添加战绩
    /// </summary>
    /// <param name="obj"></param>
    private void OnAddRecord(TransferData data)
    {
        int groupId = data.GetValue <int>("GroupId");

        if (groupId == m_GroupId)
        {
            UIItemChatGroupRecord item = UIPoolManager.Instance.Spawn("UIItemChatGroupRecord").GetComponent <UIItemChatGroupRecord>();
            item.SetUI(data);
            item.gameObject.SetParent(m_RecordContainer);
            item.transform.SetSiblingIndex(0);
            m_RecordList.Add(item);
        }
        else
        {
            m_NewRecordTip.SetActive(true);
        }
    }
Beispiel #2
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);
            }
        }
    }