示例#1
0
        /// <summary>
        /// Dynel send to Vicinity
        /// </summary>
        /// <param name="message">Message string</param>
        public void SendVicinityChat(string message)
        {
            // Default vicinity radius is 10 -- Midian
            List <Dynel> clients = FindClient.GetClientsInRadius(this, 10.0f);

            UInt32[] recvers = new UInt32[clients.Count];
            int      index   = 0;

            foreach (Character child in clients)
            {
                recvers[index] = (UInt32)child.Id;
                index++;
            }

            ChatCom.SendVicinity((UInt32)this.Id, 0, recvers, message);
        }
示例#2
0
        public static void Read(byte[] packet, Client cli)
        {
            PacketReader reader = new PacketReader(packet);

            reader.PopShort(); //magic 0xDFDF
            short pktType = reader.PopShort();

            if (pktType != 0x0005)
            {
                //TextMessage type
                throw new WrongPacketTypeException("Wrong packet type given to VicinityHandler.");
            }
            reader.PopShort(); //unknown
            short  packetSize = reader.PopShort();
            UInt32 senderId   = reader.PopUInt();

            reader.PopInt();             // Receiver
            int pktId = reader.PopInt(); // Packet ID

            // 3 unknown values
            reader.PopInt();
            reader.PopInt();
            reader.PopInt();

            short  msgLen  = reader.PopShort();
            string msg     = reader.PopString(msgLen);
            byte   msgType = reader.PopByte();

#if DEBUG
            Console.WriteLine("Vicinity: " + msg);
#endif
            float range = 0f;
            switch (msgType)
            {
            case 0:
                // Say
                range = 10.0f;
                break;

            case 1:
                // Whisper
                range = 1.5f;
                break;

            case 2:
                // Shout
                range = 60.0f;
                break;

            default:
                break;
            }

            List <Client> clients = FindClient.GetClientsInRadius(cli, range);
            UInt32[]      recvers = new UInt32[clients.Count];
            int           index   = 0;

            foreach (Client child in clients)
            {
                recvers[index] = (UInt32)child.Character.Id;
                index++;
            }

            ChatCom.SendVicinity(senderId, msgType, recvers, msg);
        }