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); } }
private void UpdateChannel() { _viewModel.ChannelTipText = GetChannelChannelTip(_curChannel); _viewModel.ChannelTipColor = UiCommonColor.GetChatChannelColor(_curChannel); }