private void ClientChatBufferCommandOnCommandReceived(object sender, ChatHistoryItem chatHistoryItem,
                                                              string @from, string command, string[] param,
                                                              string fullParam)
        {
            var player = _rconClient.PlayerListCommand.GetPlayer(chatHistoryItem.From);

            if (command == "track")
            {

                if (param.Length == 0)
                {
                    _rconClient.SendMessagePlayer(player, "KD: Player name required for tracking.");
                }
                else
                {
                    var targetPlayerName = param[0];
                    var targetPlayer = _rconClient.PlayerListCommand.SearchForPlayer(targetPlayerName);

                    if (targetPlayer == null)
                    {
                        _rconClient.SendMessagePlayer(player, "KD: Could not find match for player name " + targetPlayerName + ".");
                        return;
                    }
                    targetPlayerName = targetPlayer.Name;

                    AddTrackingTarget(player, targetPlayer);

                    _rconClient.SendMessagePlayer(player,
                                                  "KD: Tracking " + targetPlayerName + ". Will report kills/deaths to you.");
                }
            }
            if (command == "untrack")
            {

                if (param.Length == 0)
                {
                    _rconClient.SendMessagePlayer(player, "KD: Player name required for untracking.");
                }
                else
                {
                    var targetPlayerName = param[0];
                    var targetPlayer = _rconClient.PlayerListCommand.SearchForPlayer(targetPlayerName);

                    if (targetPlayer == null)
                    {
                        _rconClient.SendMessagePlayer(player, "KD: Could not find match for player name " + targetPlayerName + ".");
                        return;
                    }
                    targetPlayerName = targetPlayer.Name;

                    bool result = RemoveTrackingTarget(player, targetPlayer);

                    if (result)
                        _rconClient.SendMessagePlayer(player, "KD: Tracking of " + targetPlayerName + " stopped.");
                    else
                        _rconClient.SendMessagePlayer(player, "KD: You were not tracking " + targetPlayerName + ".");
                }
            }
        }
 private void ClientChatBufferCommandOnChatLineReceived(object sender, ChatHistoryItem chatHistoryItem)
 {
     WriteLine(string.Format("{0} {1} {2} <{3} -> {4}> {5}",
         chatHistoryItem.TimeStamp,
         chatHistoryItem.Type,
         chatHistoryItem.Number,
         chatHistoryItem.From,
         chatHistoryItem.What,
         chatHistoryItem.Message), Brushes.Black);
 }
        public async void RefreshClientChatBufferCommand()
        {
            log.Trace("RefreshClientChatBufferCommand(): Start");
            var qi = new RconQueueItem("bf2cc clientchatbuffer", RconClient.RconState.AsyncCommand);
            RconClient.EnqueueCommand(qi);
            var lines = await qi.TaskCompletionSource.Task;
            
            foreach (var line in lines)
            {
                var clientBuffer = reg_ClientBuffer.Match(line);
                if (clientBuffer.Success)
                {
                    var number = clientBuffer.Groups["number"].Value;
                    var from = clientBuffer.Groups["from"].Value;
                    var what = clientBuffer.Groups["what"].Value;
                    var type = clientBuffer.Groups["type"].Value;
                    var timestamp = clientBuffer.Groups["timestamp"].Value;
                    var message = clientBuffer.Groups["message"].Value;
                    Debug.WriteLine(timestamp + " <" + from + "> " + message);
                    var item = new ChatHistoryItem()
                                   {
                                       Number = int.Parse(number),
                                       From = from,
                                       What = what,
                                       Type = type,
                                       TimeStamp = timestamp,
                                       Message = message
                                   };
                    lock (ChatHistory)
                    {
                        ChatHistory.Add(item);
                        while (ChatHistory.Count > ChatHistorySize)
                        {
                            ChatHistory.RemoveAt(0);
                        }
                    }
                    OnChatLineReceived(item);

                    // Now check if its a command
                    var result = reg_Command.Match(item.Message);
                    if (result.Success)
                    {
                        var cmd = result.Groups["cmd"].Value.ToLower();
                        var p = result.Groups["params"].Value;
                        p = Regex.Replace(p, @"\s\s+", " ");
                        var ps = p.Split(c_space);
                        OnCommandReceived(item, item.From, cmd, ps, p);
                    }
                        

                }
            }
            log.Trace("RefreshClientChatBufferCommand(): End (" + lines.Count + " chat lines)");

        }
示例#4
0
        private void ClientChatBufferCommandOnCommandReceived(object sender, ChatHistoryItem chatHistoryItem, string @from, string command, string[] param, string fullParam)
        {
            var player = _rconClient.PlayerListCommand.GetPlayer(chatHistoryItem.From);

            if (command == "c" || command == "clear")
            {
                Task.Delay(2000)
                .ContinueWith(task => _rconClient.SendMessagePlayer(player, "Tip: To stop spam type /stopspam"));
            }
            if (command == "stopspam")
            {
                PlayerCacheAndHistory.Current.GetPlayerCache(player).Settings.StopSpam = true;
                _rconClient.SendMessagePlayer(player, "KD: Lowering amount of messages sent to you. /startspam to undo.");
            }
            if (command == "startspam")
            {
                PlayerCacheAndHistory.Current.GetPlayerCache(player).Settings.StopSpam = true;
                _rconClient.SendMessagePlayer(player, "KD: Increasing amount of messages sent to you. /stopspam to undo.");
            }

            if (command == "deaths")
            {
                Player thisPlayer = player;
                var    playerName = "Your";
                if (param.Length > 0)
                {
                    playerName = param[0];
                    thisPlayer = _rconClient.PlayerListCommand.SearchForPlayer(playerName);
                }
                if (thisPlayer == null)
                {
                    _rconClient.SendMessagePlayer(player, "KD: Could not find match for player name " + playerName + ".");
                    return;
                }
                playerName = thisPlayer.Name;
                _rconClient.SendMessagePlayer(player,
                                              "KD: " + playerName + " kills/deaths this round: " +
                                              thisPlayer.Score.Kills + "/" + thisPlayer.Score.Deaths);
            }

            if (command == "ping")
            {
                Player pingPlayer = player;
                var    playerName = "Your";
                if (param.Length > 0)
                {
                    playerName = param[0];
                    pingPlayer = _rconClient.PlayerListCommand.SearchForPlayer(playerName);
                }
                if (pingPlayer == null)
                {
                    _rconClient.SendMessagePlayer(player, "KD: Could not find match for player name " + playerName + ".");
                    return;
                }
                playerName = pingPlayer.Name;
                PlayerCache playerCache = PlayerCacheAndHistory.Current.GetPlayerCache(pingPlayer);

                var      total   = 0;
                var      num     = 0;
                var      highest = 0;
                var      lowest  = 10000;
                DateTime oldest  = DateTime.Now;
                foreach (var h in playerCache.CopyHistory())
                {
                    if (h.Player.Ping != 0)
                    {
                        num++;
                        total  += h.Player.Ping;
                        lowest  = Math.Min(lowest, h.Player.Ping);
                        highest = Math.Max(highest, h.Player.Ping);
                        if (h.Time < oldest)
                        {
                            oldest = h.Time;
                        }
                    }
                }
                _rconClient.SendMessagePlayer(player, "KD: " + playerName + " current ping: " + player.Ping + " ms.");
                if (num > 0)
                {
                    var ping    = (decimal)total / (decimal)num;
                    var pingStr = string.Format("{0:0.00}", ping);
                    var since   = DateTime.Now.Subtract(oldest);
                    _rconClient.SendMessagePlayer(player, "KD: " + playerName + " average ping the last " + (int)since.TotalSeconds + " seconds is " + pingStr + " ms.");
                    _rconClient.SendMessagePlayer(player, "KD: " + playerName + " highest: " + highest + "ms. Lowest: " + lowest + " ms.");
                }
            }
        }
示例#5
0
        private void ClientChatBufferCommandOnCommandReceived(object sender, ChatHistoryItem chatHistoryItem,
                                                              string @from, string command, string[] param,
                                                              string fullParam)
        {
            var player = _rconClient.PlayerListCommand.GetPlayer(chatHistoryItem.From);

            if (command == "track")
            {
                if (param.Length == 0)
                {
                    _rconClient.SendMessagePlayer(player, "KD: Player name required for tracking.");
                }
                else
                {
                    var targetPlayerName = param[0];
                    var targetPlayer     = _rconClient.PlayerListCommand.SearchForPlayer(targetPlayerName);

                    if (targetPlayer == null)
                    {
                        _rconClient.SendMessagePlayer(player, "KD: Could not find match for player name " + targetPlayerName + ".");
                        return;
                    }
                    targetPlayerName = targetPlayer.Name;

                    AddTrackingTarget(player, targetPlayer);

                    _rconClient.SendMessagePlayer(player,
                                                  "KD: Tracking " + targetPlayerName + ". Will report kills/deaths to you.");
                }
            }
            if (command == "untrack")
            {
                if (param.Length == 0)
                {
                    _rconClient.SendMessagePlayer(player, "KD: Player name required for untracking.");
                }
                else
                {
                    var targetPlayerName = param[0];
                    var targetPlayer     = _rconClient.PlayerListCommand.SearchForPlayer(targetPlayerName);

                    if (targetPlayer == null)
                    {
                        _rconClient.SendMessagePlayer(player, "KD: Could not find match for player name " + targetPlayerName + ".");
                        return;
                    }
                    targetPlayerName = targetPlayer.Name;

                    bool result = RemoveTrackingTarget(player, targetPlayer);

                    if (result)
                    {
                        _rconClient.SendMessagePlayer(player, "KD: Tracking of " + targetPlayerName + " stopped.");
                    }
                    else
                    {
                        _rconClient.SendMessagePlayer(player, "KD: You were not tracking " + targetPlayerName + ".");
                    }
                }
            }
        }
示例#6
0
    public string MakeLinkEnabled(string fulltext, ChatHistoryItem history)
    {
        int linkindex = 0;

        while (Utils.IsContainChatLink(fulltext))
        {
            int linkstart_whole = fulltext.IndexOf("<a>");

            int linkstart = NGUITools.StripSymbols(fulltext).IndexOf("<a>");
            int linkend   = NGUITools.StripSymbols(fulltext).IndexOf("</a>") - 3;         // 减3为减去"<a>"三个字符的长度

            string strLinkColor = Utils.GetLinkColor(history, linkindex);
            fulltext = fulltext.Substring(0, fulltext.IndexOf("<a>")) + strLinkColor + fulltext.Substring(fulltext.IndexOf("<a>") + 3);
            string strChannelColor = null;
            if (history.SenderGuid != GlobeVar.INVALID_GUID && history.SenderName != "")
            {
                strChannelColor = "[-]";
            }
            else
            {
                strChannelColor = Utils.GetChannelColor(history);
            }
            fulltext = fulltext.Substring(0, fulltext.IndexOf("</a>")) + strChannelColor + fulltext.Substring(fulltext.IndexOf("</a>") + 4);

            Vector2 LeftSideSpace, RightSideSpace;
            int     nNextLineNum;
            CalculateLinkSpace(ref fulltext, linkstart_whole, linkstart, linkend, out LeftSideSpace, out RightSideSpace, out nNextLineNum);
            //m_ChatTextHeight = RightSideSpace.y;

            GameObject link = null;
            if (history.SenderGuid == Singleton <ObjManager> .GetInstance().MainPlayer.GUID)
            {
                link = ResourceManager.LoadChatLink(m_LinkRootMe);
                if (link != null)
                {
                    link.transform.localPosition  = new Vector3(((LeftSideSpace.x + RightSideSpace.x) / 2), -m_Space_Height / 2, 0);
                    link.transform.localPosition -= new Vector3(25, m_Space_Height * nNextLineNum, 0);
                    if (null != link.GetComponent <BoxCollider>())
                    {
                        link.GetComponent <BoxCollider>().size = new Vector3(RightSideSpace.x - LeftSideSpace.x, m_Space_Height, 0);
                    }

                    if (null != link.GetComponent <ChatLinkLogic>())
                    {
                        link.GetComponent <ChatLinkLogic>().Init(history, linkindex);
                    }
                    gameObject.name = linkindex.ToString();
                    m_LinkList.Add(link);
                }

                linkindex += 1;
            }
            else
            {
                link = ResourceManager.LoadChatLink(m_LinkRootOthers);
                if (link != null)
                {
                    link.transform.localPosition  = new Vector3((LeftSideSpace.x + RightSideSpace.x) / 2, -m_Space_Height / 2, 0);
                    link.transform.localPosition -= new Vector3(-25, m_Space_Height * nNextLineNum, 0);
                    if (null != link.GetComponent <BoxCollider>())
                    {
                        link.GetComponent <BoxCollider>().size = new Vector3(RightSideSpace.x - LeftSideSpace.x, m_Space_Height, 0);
                    }

                    if (null != link.GetComponent <ChatLinkLogic>())
                    {
                        link.GetComponent <ChatLinkLogic>().Init(history, linkindex);
                    }
                    gameObject.name = linkindex.ToString();
                    m_LinkList.Add(link);
                }

                linkindex += 1;
            }
        }
        return(fulltext);
    }
示例#7
0
    //初始化聊天title和内容
    public void MakeTitleEnable(string fulltext, ChatHistoryItem history)
    {
        if (string.IsNullOrEmpty(history.ChatInfo))
        {
            return;
        }
        string strChannelName = "";

//         if (history.EChannel != GC_CHAT.CHATTYPE.CHAT_TYPE_PROVINCE)
//         {
        strChannelName = Utils.GetChannelName((int)history.EChannel);
        //    }
//         else
//         {
//             strChannelName = Utils.GetProvinceName(history.ProvinceID);
//             strChannelName = StrDictionary.GetClientDictionaryString("#{5680}", strChannelName);
//         }
        string strSenderName = "";
        string strChatInfo   = history.ChatInfo;

        if (history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_TELL || history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_FRIEND ||
            history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_SYSTEM || history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_GUILD)
        {
            // 系统频道可能无发送人
            if (history.SenderGuid != GlobeVar.INVALID_GUID && history.SenderName != "")
            {
                //strSenderName = StrDictionary.GetClientDictionaryString("#{5548}", history.SenderName);//{0}
                strSenderName = history.SenderName;//{0}
            }

            if (strChatInfo.Length > 0 && strChatInfo[0] == '#')
            {
                strChatInfo = StrDictionary.GetServerDictionaryFormatString(strChatInfo);
            }

            if (history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_SYSTEM)
            {
                strSenderName = StrDictionary.GetClientDictionaryString("#{4336}");
            }
        }
        else if (history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_LOUDSPEAKER)
        {
            //strSenderName = StrDictionary.GetClientDictionaryString("#{5548}", history.SenderName);//{0}:
            strSenderName = history.SenderName;
            if (strChatInfo.Length > 0 && strChatInfo[0] == '#')
            {
                strChatInfo = StrDictionary.GetServerDictionaryFormatString(strChatInfo);
            }
        }
        else
        {
            if (history.ELinkType.Count > 0 && history.GetLinkIntDataCountByIndex(0) == (int)GC_CHAT.LINKTYPE.LINK_TYPE_GUILDCRUITE)
            {
                strSenderName = "[" + StrDictionary.GetClientDictionaryString("#{3108}", "") + "]:";//招募
            }
            else
            {
                //strSenderName = StrDictionary.GetClientDictionaryString("#{5548}", history.SenderName);//{0}
                strSenderName = history.SenderName;
            }
        }
        string strChatTitle    = strChannelName + strSenderName;//频道+名字
        string strChannelColor = Utils.GetChannelColor(history);

        strChatTitle = strChannelColor + strChatTitle;
        strChatTitle = ShowVIPIcon(strChatTitle, history);
        string strChatDetail = null;

        if (history.SenderGuid != GlobeVar.INVALID_GUID && history.SenderName != "")
        {
            strChatDetail   = strChatInfo;
            strChannelColor = "[FFFFFF]";
        }
        else
        {
            if (history.EChannel != GC_CHAT.CHATTYPE.CHAT_TYPE_SYSTEM)
            {
                strChatDetail   = strChatTitle + strChatInfo;
                strChatTitle    = null;
                strChannelColor = Utils.GetChannelColor(history);
            }
            else // 系统消息特殊处理,有其他需要也在这里进行处理
            {
                strChatDetail   = strChatInfo;
                strChannelColor = Utils.GetChannelColor(history);
            }
        }
        m_Space_Width = m_Font.CalculatePrintedSize("  ", true, UIFont.SymbolStyle.Uncolored).x;

        SelectTextNumber();
        // 显示聊天信息
        if (history.ELinkType.Count > 0)
        {
            strChatDetail = MakeLinkEnabled(strChatDetail, history);
        }
        strChatDetail = MakeEmotionEnabled(strChatDetail, history);
        strChatDetail = ShowPlayVoiceBtn(strChatDetail, history);

        strChatDetail = strChannelColor + strChatDetail;
        StringBuilder bd = new StringBuilder(512);

        if (history.SenderGuid == Singleton <ObjManager> .GetInstance().MainPlayer.GUID)
        {
            SPACE_WIDTH = (int)m_Font.CalculatePrintedSize(" ", true, UIFont.SymbolStyle.Uncolored).x;
            Vector2 space = m_Font.CalculatePrintedSize(strChatDetail, true, UIFont.SymbolStyle.Uncolored);
            //如果没有换行 前面塞点空格,把文字往右边推下 (什么玩意破代码,写的都什么啊。。。。。rubbish)
            if (!strChatDetail.Contains(Environment.NewLine))
            {
                if (space.x < m_ChatInfoItemWidth && SPACE_WIDTH != 0)
                {
                    m_ChatSpaceCount = (int)((m_ChatInfoItemWidth - space.x) / SPACE_WIDTH);
                    for (int i = 0; i < m_ChatSpaceCount; i++)
                    {
                        bd.Append(Str_Space);
                    }
                    strChatDetail = bd.ToString() + strChatDetail;
                }
            }
        }
        UpdateEmotionLinkPos(history, strChatDetail);

        //调整背景框大小
        if (history.SenderGuid == Singleton <ObjManager> .GetInstance().MainPlayer.GUID)
        {
            if (history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_TELL)
            {
                m_LabelChatTitleMe.text = StrDictionary.GetClientDictionaryString("#{11440}", history.ReceiverName);
            }
            else
            {
                m_LabelChatTitleMe.text = strChatTitle;
            }
            m_LabelChatDetailMe.text = strChatDetail;
            int     m_LableChatDetailMeWidth = m_ChatInfoItemWidth - m_ChatSpaceCount * SPACE_WIDTH;
            Vector2 m_ChatInfoSpace          = m_Font.CalculatePrintedSize(strChatDetail, true, UIFont.SymbolStyle.Uncolored);
            if (history.SenderGuid != GlobeVar.INVALID_GUID && history.SenderName != "")
            {
                if (m_LableChatDetailMeWidth < m_ChatInfoItemWidth)
                {
                    m_BackgroundMe.width  = Math.Min((int)(m_ChatInfoSpace.x + m_Space_Width * 2), (int)(m_LableChatDetailMeWidth + m_Space_Width * 2));
                    m_ChatMaxHeight       = m_LabelChatDetailMe.printedSize.y;
                    m_BackgroundMe.height = (int)(m_Space_Height);
                }
                else
                {
                    m_BackgroundMe.width  = (int)(m_LableChatDetailMeWidth + m_Space_Width * 2);
                    m_ChatMaxHeight       = m_LabelChatDetailMe.printedSize.y;
                    m_BackgroundMe.height = (int)((m_ChatMaxHeight + m_Space_Height));
                }
            }
            else
            {
                m_BackgroundOthers.gameObject.SetActive(false);
            }
        }
        else
        {
            if (history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_TELL)
            {
                m_LabelChatTitleOthers.text = StrDictionary.GetClientDictionaryString("#{11441}", history.SenderName);
            }
            else
            {
                m_LabelChatTitleOthers.text = strChatTitle;
            }
            m_LabelChatDetailOthers.text = strChatDetail;
            int     m_LableChatDetailOtherWidth = m_LabelChatDetailOthers.width;
            Vector2 m_ChatInfoSpace             = m_Font.CalculatePrintedSize(strChatDetail, true, UIFont.SymbolStyle.Uncolored);
            if ((history.SenderGuid != GlobeVar.INVALID_GUID && history.SenderName != "") || history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_SYSTEM)
            {
                if (m_ChatInfoSpace.x < m_LableChatDetailOtherWidth && !strChatDetail.Contains(Environment.NewLine))
                {
                    m_BackgroundOthers.width  = Math.Min((int)(m_ChatInfoSpace.x + m_Space_Width * 2), (int)(m_LableChatDetailOtherWidth + m_Space_Width * 2));
                    m_ChatMaxHeight           = m_LabelChatDetailOthers.printedSize.y;
                    m_BackgroundOthers.height = (int)(m_Space_Height);
                }
                else
                {
                    m_BackgroundOthers.width  = (int)(m_LableChatDetailOtherWidth + m_Space_Width * 2);
                    m_ChatMaxHeight           = m_LabelChatDetailOthers.printedSize.y;
                    m_BackgroundOthers.height = (int)(m_ChatMaxHeight + m_Space_Height);
                }
            }
            else
            {
                m_BackgroundOthers.gameObject.SetActive(false);
            }
        }
    }
示例#8
0
    //头像、等级信息
    public string MakeHeadEnabled(string fulltext, ChatHistoryItem history)
    {
        if (null != Singleton <ObjManager> .GetInstance().MainPlayer&&
            history.SenderGuid == Singleton <ObjManager> .GetInstance().MainPlayer.GUID)
        {
            m_Profession = Singleton <ObjManager> .GetInstance().MainPlayer.Profession;

            if (history.SenderGuid != GlobeVar.INVALID_GUID && history.SenderName != "")
            {
                if (history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_TELL || history.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_FRIEND)
                {
                    FY_templateOther.SetActive(false);
                    m_LevelMe.text = Singleton <ObjManager> .GetInstance().MainPlayer.BaseAttr.Level.ToString();

                    //m_Profession = Singleton<ObjManager>.GetInstance().MainPlayer.Profession;
                    for (int i = 0; i < 4 && i < ProfessionSpritesMe.Length; i++)
                    {
                        ProfessionSpritesMe[i].gameObject.SetActive(m_Profession == i);
                        //m_HeadMe.gameObject.SetActive(false);
                    }
                }
                else
                {
                    FY_templateOther.SetActive(false);
//                     m_LevelMe.text = history.SenderLevel.ToString();
//                     m_Profession = (int)history.SenderPro;
                    for (int i = 0; i < 4 && i < ProfessionSpritesMe.Length; i++)
                    {
                        ProfessionSpritesMe[i].gameObject.SetActive(m_Profession == i);
                        //m_HeadMe.gameObject.SetActive(false);
                    }
                }
            }
            else
            {
                FY_templateOther.SetActive(false);
                m_LevelMe.text = null;
                //m_HeadMe.gameObject.SetActive(false);
            }
        }
        else
        {
            if (history.SenderGuid != GlobeVar.INVALID_GUID && history.SenderName != "")
            {
                FY_templateMe.SetActive(false);
                m_LevelOther.text = history.SenderLevel.ToString();
                m_Profession      = (int)history.SenderPro;
                for (int i = 0; i < 4 && i < ProfessionSpritesOthers.Length; i++)
                {
                    ProfessionSpritesOthers[i].gameObject.SetActive(m_Profession == i);
                    //m_HeadOther.gameObject.SetActive(false);
                }
            }
            else
            {
                FY_templateMe.SetActive(false);
                m_LevelOther.text = null;
                //m_HeadOther.gameObject.SetActive(false);
            }
        }
        return(fulltext);
    }
示例#9
0
 public void FillHistoryTalk(ChatHistoryItem talkItem, string datas)
 {
     RegistUIButton(talkItem.gameObject, (go) => {
         SetText(datas);
     });
 }
示例#10
0
	public void FillHistoryTalk(ChatHistoryItem talkItem, string datas) {
		RegistUIButton(talkItem.gameObject, (go) => {
			SetText(datas);
		});
	}
示例#11
0
    public void InitCurChat()
    {
        int HistoryCount = GameManager.gameManager.PlayerDataPool.ChatHistory.ChatHistoryList.Count;

        if (HistoryCount > 0)
        {
            int nLastLoudSpeakerIndex = -1;
            List <ChatHistoryItem> listChatHistory = GameManager.gameManager.PlayerDataPool.ChatHistory.ChatHistoryList;
            for (int i = listChatHistory.Count - 1; i >= 0; i--)
            {
                if (listChatHistory[i].EChannel != GC_CHAT.CHATTYPE.CHAT_TYPE_LOUDSPEAKER &&
                    listChatHistory[i].ChatInfo != null &&
                    (listChatHistory[i].ChatInfo != "" || (!PlatformHelper.IsChannelMainland() && listChatHistory[i].VoiceChatIndex != GlobeVar.INVALID_ID)) &&
                    ChatInfoSetupLogic.IsChannelReceiveChat(GameManager.gameManager.PlayerDataPool.ChooseChannel, listChatHistory[i].EChannel))
                {
                    nLastLoudSpeakerIndex = i;
                    break;
                }
            }

            if (nLastLoudSpeakerIndex != -1)
            {
                // 显示聊天信息
                ChatHistoryItem LastHistory = listChatHistory[nLastLoudSpeakerIndex];

                string strChannelName  = Utils.GetChannelName((int)LastHistory.EChannel);
                string strSenderName   = "";
                string strLastChatInfo = LastHistory.ChatInfo;
                if (LastHistory.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_TELL ||
                    LastHistory.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_FRIEND)
                {
                    if (LastHistory.SenderName == Singleton <ObjManager> .Instance.MainPlayer.BaseAttr.RoleName)
                    {
                        //strSenderName = "你对[" + LastHistory.ReceiverName + "]说:";
                        strSenderName = StrDictionary.GetClientDictionaryString("#{2822}", LastHistory.ReceiverName);
                    }
                    else
                    {
                        //strSenderName = "[" + LastHistory.SenderName + "]对你说:";
                        strSenderName = StrDictionary.GetClientDictionaryString("#{2823}", LastHistory.SenderName);
                    }
                    if (strLastChatInfo.Length > 0 && strLastChatInfo[0] == '#')
                    {
                        strLastChatInfo = StrDictionary.GetServerDictionaryFormatString(strLastChatInfo);
                    }
                }
                else if (LastHistory.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_SYSTEM ||
                         LastHistory.EChannel == GC_CHAT.CHATTYPE.CHAT_TYPE_GUILD)
                {
                    if (strLastChatInfo == null)
                    {
                        return;
                    }
                    // 台湾版本需要发送纯语音
                    if (strLastChatInfo == "" && (PlatformHelper.IsChannelMainland() || LastHistory.VoiceChatIndex == GlobeVar.INVALID_ID))
                    {
                        return;
                    }

                    // 系统频道可能无发送人
                    if (LastHistory.SenderGuid != GlobeVar.INVALID_GUID && LastHistory.SenderName != "")
                    {
                        //strSenderName = "[" + LastHistory.SenderName + "]说:";
                        strSenderName = StrDictionary.GetClientDictionaryString("#{2824}", LastHistory.SenderName);
                    }
                    // 解析# 字典
                    if (strLastChatInfo.Length > 0 && strLastChatInfo[0] == '#')
                    {
                        strLastChatInfo = StrDictionary.GetServerDictionaryFormatString(strLastChatInfo);
                    }
                }
                else
                {
                    //strSenderName = "[" + LastHistory.SenderName + "]说:";
                    if (LastHistory.ELinkType.Count > 0 && LastHistory.GetLinkIntDataCountByIndex(0) == (int)GC_CHAT.LINKTYPE.LINK_TYPE_GUILDCRUITE)
                    {
                        strSenderName = "[" + StrDictionary.GetClientDictionaryString("#{3108}", "") + "]:";
                    }
                    else
                    {
                        strSenderName = StrDictionary.GetClientDictionaryString("#{2824}", LastHistory.SenderName);
                    }

                    // 解析# 字典
                    if (strLastChatInfo.Length > 0 && strLastChatInfo[0] == '#')
                    {
                        strLastChatInfo = StrDictionary.GetServerDictionaryFormatString(strLastChatInfo);
                    }
                }

                SelectTextNumber();

                string strChatInfo = strLastChatInfo;
                string strChatFull = strChannelName + strSenderName + strChatInfo;

                strChatFull = ShowVIPIcon(strChatFull, ref strSenderName, LastHistory);
                strChatFull = ShowPlayVoiceBtn(strChatFull, strSenderName, LastHistory);

                if (LastHistory.ELinkType.Count > 0)
                {
                    strChatFull = MakeLinkEnabled(strChatFull, LastHistory);
                }

                strChatFull = MakeEmotionEnabled(strChatFull);

                if (!(LastHistory.ELinkType.Count > 0 && LastHistory.GetLinkIntDataCountByIndex(0) == (int)GC_CHAT.LINKTYPE.LINK_TYPE_GUILDCRUITE))
                {
                    strChatFull = MakeNameLinkEnabled(strChatFull, LastHistory);
                }

                string strChannelColor = Utils.GetChannelColor(LastHistory);
                strChatFull = strChannelColor + strChatFull;

                ConfirmEllipsis(ref strChatFull);
                labelChatText.text = strChatFull;

                UpdateEmotionLinkPos(NGUITools.StripSymbols(strChatFull));
            }
        }
    }
 protected virtual void OnChatLineReceived(ChatHistoryItem chathistoryitem)
 {
     ChatLineReceivedDelegate handler = ChatLineReceived;
     if (handler != null) handler(this, chathistoryitem);
 }
 protected virtual void OnCommandReceived(ChatHistoryItem chathistoryitem, string @from, string command, string[] param, string fullparam)
 {
     CommandReceivedDelegate handler = CommandReceived;
     if (handler != null) handler(this, chathistoryitem, @from, command, param, fullparam);
 }
示例#14
0
        private void ClientChatBufferCommandOnCommandReceived(object sender, ChatHistoryItem chatHistoryItem, string @from, string command, string[] param, string fullParam)
        {
            var player = _rconClient.PlayerListCommand.GetPlayer(chatHistoryItem.From);

            if (command == "c" || command == "clear")
            {
                Task.Delay(2000)
                    .ContinueWith(task => _rconClient.SendMessagePlayer(player, "Tip: To stop spam type /stopspam"));
            }
            if (command == "stopspam")
            {
                PlayerCacheAndHistory.Current.GetPlayerCache(player).Settings.StopSpam = true;
                _rconClient.SendMessagePlayer(player, "KD: Lowering amount of messages sent to you. /startspam to undo.");
            }
            if (command == "startspam")
            {
                PlayerCacheAndHistory.Current.GetPlayerCache(player).Settings.StopSpam = true;
                _rconClient.SendMessagePlayer(player, "KD: Increasing amount of messages sent to you. /stopspam to undo.");
            }

            if (command == "deaths")
            {
                Player thisPlayer = player;
                var playerName = "Your";
                if (param.Length > 0)
                {
                    playerName = param[0];
                    thisPlayer = _rconClient.PlayerListCommand.SearchForPlayer(playerName);
                }
                if (thisPlayer == null)
                {
                    _rconClient.SendMessagePlayer(player, "KD: Could not find match for player name " + playerName + ".");
                    return;
                }
                playerName = thisPlayer.Name;
                    _rconClient.SendMessagePlayer(player,
                                                  "KD: " + playerName + " kills/deaths this round: " +
                                                  thisPlayer.Score.Kills + "/" + thisPlayer.Score.Deaths);
            }

              if (command == "ping")
            {
                Player pingPlayer = player;
                var playerName = "Your";
                if (param.Length > 0)
                {
                    playerName = param[0];
                    pingPlayer = _rconClient.PlayerListCommand.SearchForPlayer(playerName);
                }
                if (pingPlayer == null)
                {
                    _rconClient.SendMessagePlayer(player, "KD: Could not find match for player name " + playerName + ".");
                    return;
                }
                playerName = pingPlayer.Name;
                PlayerCache playerCache = PlayerCacheAndHistory.Current.GetPlayerCache(pingPlayer);

                var total = 0;
                var num = 0;
                var highest = 0;
                var lowest = 10000;
                DateTime oldest = DateTime.Now;
                foreach (var h in playerCache.CopyHistory())
                {
                    if (h.Player.Ping != 0)
                    {
                        num++;
                        total += h.Player.Ping;
                        lowest = Math.Min(lowest, h.Player.Ping);
                        highest = Math.Max(highest, h.Player.Ping);
                        if (h.Time < oldest)
                            oldest = h.Time;
                    }
                }
                _rconClient.SendMessagePlayer(player, "KD: " + playerName + " current ping: " + player.Ping + " ms.");
                if (num > 0)
                {
                    var ping = (decimal)total / (decimal)num;
                    var pingStr = string.Format("{0:0.00}", ping);
                    var since = DateTime.Now.Subtract(oldest);
                    _rconClient.SendMessagePlayer(player, "KD: " + playerName + " average ping the last " + (int)since.TotalSeconds + " seconds is " + pingStr + " ms.");
                    _rconClient.SendMessagePlayer(player, "KD: " + playerName + " highest: " + highest + "ms. Lowest: " + lowest + " ms.");
                }

            }
        }