public void onAddLabel(UAddLabelMsgData msgData) { if (msgData == null) { return; } if (SupportVoteFrame != null) { SupportVoteFrame.UpdateSubFrame(); } SSchemeLabelConfig labelConfig = WarSupportPlayerConfigPage.Instance.GetLabelConfig(msgData.nLabelID); if (labelConfig == null) { return; } // 播放广播 string strFormat = ULocalizationService.Instance.Get("UIView", "Support", "AddLabelMsg"); string strMsg = string.Format(strFormat, ChatMessageManager.ChatItemFlag, msgData.operatorName, ChatMessageManager.ChatItemFlag, msgData.targetName, ChatMessageManager.ChatItemFlag, labelConfig.labelName); gamelogic_show_chat_message msg = new gamelogic_show_chat_message(); msg.channel = (int)EMChatChannelType.CHAT_CHANNEL_WARSCENE; msg.message = strMsg; LogicDataCenter.chatMessageManager.AddChatMessage(ref msg); }
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); } }
public void OnTimer(int nTimerID) { if (nTimerID == (int)EChatTimer.EChatTimer_ShowChatMsg) { LogicDataCenter.chatMessageManager.ShowOneChatMessage(); } #if FUNCTION_AUTO_ADD_CHAT_OPEN else if (nTimerID == (int)EChatTimer.EChatTimer_AddChatMsg) { //if (UnityEngine.Random.Range(0, 100) > 50) { gamelogic_show_chat_message newMsg = new gamelogic_show_chat_message(); newMsg.channel = (int)EMChatChannelType.CHAT_CHANNEL_WARSCENE; int nCount = UnityEngine.Random.Range(0, 4); string str = Time.time.ToString(); for (int i = 0; i < nCount; ++i) { str += "一一一一一一一一一一一一一一一一一一一一"; } newMsg.message = str; newMsg.senderName = "test"; LogicDataCenter.chatMessageManager.AddChatMessage(ref newMsg); } } #endif }
// 添加一条聊天内容 public void AddChatMessage(ref gamelogic_show_chat_message msgInfo) { if (msgInfo.message == null || msgInfo.channel < 0 || msgInfo.channel >= (int)EMChatChannelType.CHAT_CHANNEL_MAX) { return; } // 不显示黑名单中玩家的信息 if (isBlackList((int)msgInfo.senderUdbid)) { return; } SChatMessageInfo info; info.sequenceID = ++SChatMessageInfo.seqGeneID; info.strMessage = msgInfo.message; info.channel = (EMChatChannelType)msgInfo.channel; info.senderName = msgInfo.senderName; info.senderPdbid = msgInfo.senderPdbid; info.senderUdbid = msgInfo.senderUdbid; info.senderKinID = msgInfo.senderKinID; info.targetPdbid = 0; info.targetName = ""; // 分割解析聊天对象 info.objList = new List <SChatMessageObjectInfo>(); // 加入前缀 String channelName; String normalColor; switch (info.channel) { case EMChatChannelType.CHAT_CHANNEL_SYSTEM: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "SystemChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_WORLD: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "WorldChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_MATCHROOM: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "MatchroomChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_WARSCENE: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "WarSceneChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_TEAMMATE: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "TeammateChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_PRIVATE: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "PrivateChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_KIN: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "KinChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_CLAN: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "ClanChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_NEARBY: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "NearbyChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_ZONE: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "ZoneChannelName"); break; case EMChatChannelType.CHAT_CHANNEL_CAMP: channelName = ULocalizationService.Instance.Get("UIView", "ChatBox", "CampChannelName"); break; default: channelName = ""; break; } normalColor = CreateColorParam(UDefines.ChatChannelColor((int)info.channel)); if (channelName != null && channelName.Length > 0) { SChatMessageObjectInfo channelObj; channelObj.type = ChatItemType.ObjType_Text; channelObj.subType = ChatItemSubType.ObjSubType_Text_Channel; channelObj.text = "[" + channelName + "]"; channelObj.param = new Dictionary <String, String>(); channelObj.param.Add("color", normalColor); channelObj.param.Add("type", "" + (int)info.channel); info.objList.Add(channelObj); } if (info.senderName != null && info.senderName.Length > 0) { SChatMessageObjectInfo nameObjInfo; if (info.senderPdbid > 0) { nameObjInfo.type = ChatItemType.ObjType_Text; nameObjInfo.subType = ChatItemSubType.ObjSubType_Text_Actor; nameObjInfo.param = new Dictionary <String, String>(); nameObjInfo.param.Add("color", CreateColorParam(255, 255, 127)); nameObjInfo.param.Add("id", "" + info.senderPdbid); nameObjInfo.param.Add("userID", "" + info.senderUdbid); nameObjInfo.param.Add("kinID", "" + info.senderKinID); } else { nameObjInfo.type = ChatItemType.ObjType_Text; nameObjInfo.subType = ChatItemSubType.ObjSubType_Text_Text; nameObjInfo.param = null; } nameObjInfo.text = info.senderName; info.objList.Add(nameObjInfo); SChatMessageObjectInfo splitObjInfo; splitObjInfo.type = ChatItemType.ObjType_Text; splitObjInfo.subType = ChatItemSubType.ObjSubType_Text_Text; splitObjInfo.text = ": "; splitObjInfo.param = null; info.objList.Add(splitObjInfo); } // 加入聊天内容 addChatContent(ref info, normalColor); bool isHasLargeEmo = isHasLargeEmotion(info); // 默认显示在聊天框 int showPos = (int)ChatMessageShowPos.CMS_ChatBox; // 大表情不显示在聊天框 if (isHasLargeEmo) { showPos &= ~(int)ChatMessageShowPos.CMS_ChatBox; } // 玩家发送的消息才显示聊天气泡 if (msgInfo.senderUID > 0 || msgInfo.senderPdbid > 0) { showPos |= (int)ChatMessageShowPos.CMS_Bubble; } if ((showPos & (int)ChatMessageShowPos.CMS_ChatBox) > 0) { m_CacheMsgInfoQueue.Enqueue(info); } if ((showPos & (int)ChatMessageShowPos.CMS_Bubble) > 0) { showChatBubble(msgInfo, isHasLargeEmo ? false : true); } }