public void AddLoudspeakerMessage(ref gamelogic_show_loudspeaker msgInfo) { // 在战场就不收广播 if (GameLogicAPI.isInWarScene() > 0) { return; } if (msgInfo.message == null) { return; } SLoudspeakerInfo info = new SLoudspeakerInfo(); info.strNotice = msgInfo.message; // 分割解析聊天对象 info.objList = new List <SLoudspeakerObjectInfo>(); // 加入聊天内容 int curIndex = 0; String normalColor = CreateColorParam(255, 255, 255); while (true) { if (curIndex >= msgInfo.message.Length) { break; } int beginIndex = msgInfo.message.IndexOf(ChatItemFlag, curIndex); if (beginIndex < 0) { SLoudspeakerObjectInfo txtObj; txtObj.type = MsgObjType.ObjType_Text; txtObj.subType = MsgObjSubType.ObjSubType_Text_Text; txtObj.text = msgInfo.message.Substring(curIndex); txtObj.param = new Dictionary <String, String>(); txtObj.param.Add("color", normalColor); info.objList.Add(txtObj); break; } else { if (beginIndex > curIndex) { SLoudspeakerObjectInfo txtObj; txtObj.type = MsgObjType.ObjType_Text; txtObj.subType = MsgObjSubType.ObjSubType_Text_Text; txtObj.text = msgInfo.message.Substring(curIndex, beginIndex - curIndex); txtObj.param = new Dictionary <String, String>(); txtObj.param.Add("color", normalColor); info.objList.Add(txtObj); } curIndex = beginIndex + 1; String typeName; Dictionary <String, String> param; String content; if (GetOneChatParam(msgInfo.message, ref curIndex, out typeName, out param, out content) == false) { continue; } MsgObjType objType; MsgObjSubType subType; GetNoticeObjStringSubType(typeName, true, out objType, out subType); if (objType != MsgObjType.ObjType_Null) { SLoudspeakerObjectInfo msgObj; msgObj.type = objType; msgObj.subType = subType; msgObj.text = content; msgObj.param = param; info.objList.Add(msgObj); } } } // 聊天对象放入列表 m_noticeQueue.Enqueue(info); UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_LOUDSPEAKER_ADD, null); }
public SLoudspeakerInfo GetLoudspeakerMessage() { SLoudspeakerInfo info = m_noticeQueue.Dequeue(); return(info); }