Example #1
0
        private void showChatBubble(gamelogic_show_chat_message msgInfo, bool isShowBg = true)
        {
            string           normalColor = CreateColorParam(UDefines.ChatChannelColor((int)msgInfo.channel));
            SChatMessageInfo chatMsgInfo = new SChatMessageInfo();

            chatMsgInfo.channel     = (EMChatChannelType)msgInfo.channel;
            chatMsgInfo.senderKinID = msgInfo.senderKinID;
            chatMsgInfo.senderName  = msgInfo.senderName;
            chatMsgInfo.senderPdbid = msgInfo.senderPdbid;
            chatMsgInfo.senderUdbid = msgInfo.senderUdbid;
            chatMsgInfo.objList     = new List <SChatMessageObjectInfo>();
            chatMsgInfo.strMessage  = msgInfo.message;

            // 实体气泡
            if (msgInfo.channel == (int)EMChatChannelType.CHAT_CHANNEL_NEARBY ||
                msgInfo.channel == (int)EMChatChannelType.CHAT_CHANNEL_KIN ||
                msgInfo.channel == (int)EMChatChannelType.CHAT_CHANNEL_CLAN ||
                msgInfo.channel == (int)EMChatChannelType.CHAT_CHANNEL_CAMP ||
                msgInfo.channel == (int)EMChatChannelType.CHAT_CHANNEL_WARSCENE)
            {
                // 战场内不显示联盟和战队的气泡
                if (msgInfo.channel == (int)EMChatChannelType.CHAT_CHANNEL_KIN || msgInfo.channel == (int)EMChatChannelType.CHAT_CHANNEL_CLAN)
                {
                    if (GameLogicAPI.isInWarScene() > 0)
                    {
                        return;
                    }
                }

                // 解析内容
                addChatContent(ref chatMsgInfo, normalColor);

                UChatBubbleMsgData msgData = new UChatBubbleMsgData();
                msgData.msgID    = (int)WndMsgID.WND_MSG_CHATBUBBLE_NEW_MESSAGE;
                msgData.uid      = msgInfo.senderUID;
                msgData.info     = chatMsgInfo;
                msgData.isShowBg = isShowBg;

                UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_CHATBUBBLE_NEW_MESSAGE, msgData);
            }
            else if (msgInfo.channel == (int)EMChatChannelType.CHAT_CHANNEL_TEAMMATE)                   // 队伍聊天气泡
            {
                if (msgInfo.senderPdbid == 0)
                {
                    Debug.LogWarning("msgInfo.senderPdbid == 0");
                    return;
                }

                // 解析内容
                addChatContent(ref chatMsgInfo, normalColor);

                UTeamBubbleChatMessage msgData = new UTeamBubbleChatMessage();
                msgData.msgID = (int)WndMsgID.WND_MSG_CHATBUBBLE_TEAM_CHAT_MESSAGE;
                msgData.pdbid = msgInfo.senderPdbid;
                msgData.info  = chatMsgInfo;

                // 发送到队伍UI上显示聊天气泡
                UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_CHATBUBBLE_TEAM_CHAT_MESSAGE, msgData);
            }
        }
Example #2
0
        public void onNewMessage(UChatBubbleMsgData data)
        {
            if (data == null)
            {
                return;
            }

            uint uid = data.uid;

            // 判断是否在视野范围内
            if (ChatBubbleItem.isInSight(uid, data.info.senderPdbid) == false)
            {
                return;
            }

            Debug.LogWarning("data.isShowBg:" + data.isShowBg);

            ChatBubbleItem tmpItem;

            if (!m_ItemList.TryGetValue(uid, out tmpItem))
            {
                tmpItem = ResNode.InstantiateRes <ChatBubbleItem>(DefaultItem);
                if (tmpItem == null)
                {
                    return;
                }

                tmpItem.Init();

                tmpItem.transform.SetParent(this.transform, false);

                m_ItemList.Add(uid, tmpItem);
            }

            if (tmpItem.setData(this, uid, data.info))
            {
                tmpItem.gameObject.SetActive(true);
                tmpItem.bg.gameObject.SetActive(data.isShowBg);
            }
            else
            {
                removeChatBubbleItem(uid);
            }
        }