예제 #1
0
 public void ReceiveMessage(string Message, MirChatType Type, string Name = "")
 {
     S.ObjectChat P = new S.ObjectChat {
         Message = Message, Name = Name, Type = Type
     };
     QueuePacket(P);
 }
예제 #2
0
        public void Chat(string Message)
        {
            if (Message.Length == 0)
            {
                return;
            }

            int    TempI;
            string TempS;
            Packet TempP = null;

            switch (Message[0])
            {
            case '/':     // PM
                TempS = Message.Substring(1);
                TempI = TempS.IndexOf(' ');
                if (TempI != -1)
                {
                    TempS  = TempS.Substring(0, TempI);
                    TempI += 2;
                }
                else
                {
                    TempI = Message.Length;
                }

                PlayerObject P = Network.GetPlayer(TempS);
                if (P == null)
                {
                    QueuePacket(new S.ObjectChat {
                        Message = string.Format("User {0} not found.", TempS), Type = MirChatType.RedSystem
                    });
                    return;
                }
                P.QueuePacket(new S.ObjectChat {
                    Name = Name, Message = Message.Substring(TempI), Type = MirChatType.Whisper
                });
                return;

            case '!':
                if (Message.Length == 1)
                {
                    if (ShoutTime > Main.Time)
                    {
                        ReceiveMessage(string.Format("You cannot shout for another {0} seconds.", (ShoutTime - Main.Time) / 1000), MirChatType.RedSystem);
                        return;
                    }

                    TempP = new S.ObjectChat {
                        Name = Name, Message = Message.Substring(1), Type = MirChatType.Shout
                    };

                    for (int I = 0; I < CurrentMap.Players.Count; I++)
                    {
                        if (CurrentMap.Players[I] == this)
                        {
                            continue;
                        }
                        CurrentMap.Players[I].QueuePacket(TempP);
                    }

                    ShoutTime = Main.Time + ShoutDelay;
                    break;
                }
                switch (Message[1])
                {
                case '!':         // Group

                    break;

                case '~':         //Guild

                    break;

                default:         //Shout
                    if (ShoutTime > Main.Time)
                    {
                        ReceiveMessage(string.Format("You cannot shout for another {0} seconds.", (ShoutTime - Main.Time) / 1000), MirChatType.RedSystem);
                        return;
                    }

                    TempP = new S.ObjectChat {
                        Name = Name, Message = Message.Substring(1), Type = MirChatType.Shout
                    };

                    for (int I = 0; I < CurrentMap.Players.Count; I++)
                    {
                        if (CurrentMap.Players[I] == this)
                        {
                            continue;
                        }
                        CurrentMap.Players[I].QueuePacket(TempP);
                    }

                    ShoutTime = Main.Time + ShoutDelay;
                    break;
                }
                break;

            case '@':     //Command
                TempS = Message.Substring(1);
                TempI = TempS.IndexOf(' ');
                if (TempI != -1)
                {
                    TempS  = TempS.Substring(0, TempI);
                    TempI += 2;
                }
                else
                {
                    TempI = Message.Length;
                }

                ReceiveMessage(string.Format("Command {0} not found.", TempS), MirChatType.RedSystem);
                return;

            default:     // Normal
                TempP = new S.ObjectChat {
                    Name = Name, Message = Message, Type = MirChatType.Normal
                };
                List <PlayerObject> TempList = NearByPlayers;
                for (int I = 0; I < TempList.Count; I++)
                {
                    TempList[I].QueuePacket(TempP);
                }
                break;
            }
            if (TempP != null)
            {
                QueuePacket(TempP);
            }
        }