private Color GetChannelColor(BroadcastMessageData data) { if (IsFromSystem(data)) { return(UiCommonColor.SystemMessageColor); } var channel = ChatTypeToChannel((ChatType)data.ChatType); return(UiCommonColor.GetChatColorByChatChannel(channel)); }
BroadcastMessageData GetNewBroadcastMessageData(string str) { var data = BroadcastMessageData.Allocate(); data.SendRoleName = string.Empty; data.ChatMessage = ChatMessageData.Allocate(); data.ChatMessage.Message = str; data.ChatMessage.Type = 1; return(data); }
private string GetChannelNamePrefix(BroadcastMessageData data, Color color) { string channelName; var channel = ChatTypeToChannel((ChatType)data.ChatType); channelName = IsFromSystem(data) ? ScriptLocalization.hall_chat.word228 : GetChannelChannelTip(channel); var colorText = ColorUtility.ToHtmlStringRGB(color); if (!string.IsNullOrEmpty(channelName)) { channelName = string.Format("<color=#{0}>[{1}]</color> ", colorText, channelName); } return(channelName); }
private NearbyChatData GetNearData(BroadcastMessageData data, List <long> idList) { var targetData = NearbyChatData.Allocate(); targetData.BroadcastMsg = data; List <long> nearIds = idList; NearbyRoleIdList ids = NearbyRoleIdList.Allocate(); foreach (long id in nearIds) { ids.RoleId.Add(id); } targetData.NearbyRoleIdListData = ids.ToByteString(); targetData.Crc = 1; return(targetData); }
private void SendChatMessage(BroadcastMessageData data) { HallUtility.SendChatMessage(data); }
private bool IsFromSystem(BroadcastMessageData data) { return(data.SendRoleId == 0); }
public void AddMessage(BroadcastMessageData data) { var tf = GetNewMessageItem(); var channelColor = GetChannelColor(data); var channelName = GetChannelNamePrefix(data, channelColor); var messageText = string.Empty; var textComponent = tf.GetComponent <Text>(); var channelRoot = textComponent.transform.GetChild(0); var channelTextComponent = channelRoot != null?channelRoot.GetComponent <Text>() : null; if (tf != null && data != null && data.ChatMessage != null) { if (TargetIdDict != null) { if (!TargetIdDict.ContainsKey(data.SendRoleId)) { TargetIdDict[data.SendRoleId] = string.Empty; } TargetIdDict[data.SendRoleId] = data.SendRoleName; } if (IsFromSystem(data)) { var color = ColorUtility.ToHtmlStringRGB(UiCommonColor.SystemMessageColor); messageText = string.Format(commonMessageWithColorFormat, color, data.ChatMessage.Message); } else if (data.ChatType == (int)ChatType.PrivateChat) { var color = ColorUtility.ToHtmlStringRGB( UiCommonColor.GetChatColorByChatChannel(ChatChannel.PrivateChat)); messageText = string.Format(commonMessageWithColorFormat, color, messageText); long privateChatId = 0; if (data.SendRoleId == _chatState.MyselfId) { privateChatId = data.TargetId; messageText = string.Format(ScriptLocalization.hall_chat.word231, TargetIdDict[privateChatId]) + data.ChatMessage.Message; } else { privateChatId = data.SendRoleId; var name = string.Format(ScriptLocalization.hall_chat.PlayerNameFormat, data.SendRoleName); messageText = name + data.ChatMessage.Message; } PrivateChatRecentUseQueueUpdate(privateChatId); messageText = string.Format(commonMessageWithColorFormat, color, messageText); if (ChatListState != EUIChatListState.Send) { _curChannel = ChatChannel.PrivateChat; SetPrivateTarget(privateChatId); UpdateChannel(); } } else { var color = ColorUtility.ToHtmlStringRGB(UiCommonColor.ChatSenderColor); var name = string.Format(ScriptLocalization.hall_chat.PlayerNameFormat, data.SendRoleName); messageText = string.Format(commonMessageWithColorFormat, color, name) + data.ChatMessage.Message; } if (channelTextComponent != null) { channelTextComponent.text = channelName; } textComponent.text = messageText; } else { Logger.Error("Null object,can't addMessage"); } if (ChatListState == EUIChatListState.None) { ChatListState = EUIChatListState.Receive; } ResetTime(); //_closeViewAnim.Rewind(); }
public void AddMessage(BroadcastMessageData data) { var tf = GetNewMessageItem(); if (tf != null && data != null && data.ChatMessage != null) { if (TargetIdDict != null) { if (!TargetIdDict.ContainsKey(data.SendRoleId)) { TargetIdDict[data.SendRoleId] = string.Empty; } TargetIdDict[data.SendRoleId] = data.SendRoleName; } if (data.SendRoleId == 0) { tf.GetComponent <Text>().text = data.ChatMessage.Message; } else { tf.GetComponent <Text>().text = data.SendRoleName + ":" + data.ChatMessage.Message; } if (data.ChatType == (int)ChatType.PrivateChat) { long privateChatId = 0; if (data.SendRoleId == _chatState.MyselfId) { privateChatId = data.TargetId; tf.GetComponent <Text>().text = string.Format(ScriptLocalization.hall_chat.word231, TargetIdDict[privateChatId]) + data.ChatMessage.Message; PrivateChatRecentUseQueueUpdate(privateChatId); } else { privateChatId = data.SendRoleId; PrivateChatRecentUseQueueUpdate(privateChatId); } if (ChatListState != EUIChatListState.Send) { _curChannel = ChatChannel.PrivateChat; SetPrivateTarget(privateChatId); UpdateChannel(); } } if (data.SendRoleId > 0) { tf.GetComponent <Text>().color = UiCommonColor.GetChatChannelColor(ChatTypeToChannel((ChatType)data.ChatType)); } else { tf.GetComponent <Text>().color = Color.red; } } else { Logger.Error("Null object,can't addMessage"); } ResetTime(); _closeViewAnim.Rewind(); if (messageDict != null) { if (ChatListState == EUIChatListState.None) { ChatListState = EUIChatListState.Receive; } messageDict.Add(tf, data); } }