/// <summary>
        /// </summary>
        /// <param name="sender">
        /// </param>
        /// <param name="message">
        /// </param>
        public void Handle(object sender, Message message)
        {
            if (((TextMessage)message.Body).Message.Text.StartsWith("."))
            {
                // It is a chat command in vicinity chat, lets process it
                ChatCommandHandler.Read(((TextMessage)message.Body).Message.Text.TrimStart('.'), (ZoneClient)sender);
                return;
            }

            ICharacter character = ((IZoneClient)sender).Character;
            IPlayfield playfield = character.Playfield;

            float range = 0.0f;

            switch ((int)((TextMessage)message.Body).Message.Type)
            {
            case 0x01:
                range = 1.5f;
                break;

            case 0x00:
                range = 10.0f;
                break;

            case 0x02:
                range = 60.0f;
                break;
            }

            List <Character> charsInRange = playfield.FindInRange(character, range);

            VicinityChatMessage vicinityChat = new VicinityChatMessage
            {
                CharacterIds =
                    charsInRange.Select(
                        x => x.Identity.Instance).ToList(),
                MessageType =
                    (byte)
                    ((TextMessage)message.Body).Message.Type,
                Text =
                    ((TextMessage)message.Body).Message.Text,
                SenderId = character.Identity.Instance
            };

            Program.ISComClient.Send(vicinityChat);
        }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="message">
        /// </param>
        /// <param name="client">
        /// </param>
        protected override void Read(TextMessage message, IZoneClient client)
        {
            if (message.Message.Text.StartsWith("."))
            {
                MessageWrapper <ChatCmdMessage> wrapper = new MessageWrapper <ChatCmdMessage>()
                {
                    Client      = client,
                    Message     = null,
                    MessageBody =
                        new ChatCmdMessage()
                    {
                        Command
                            =
                                message
                                .Message
                                .Text
                                .TrimStart
                                (
                                    '.'),
                        Identity
                            =
                                client
                                .Controller
                                .Character
                                .Identity,
                        Target
                            =
                                client
                                .Controller
                                .Character
                                .SelectedTarget
                    }
                };

                // It is a chat command in vicinity chat, lets process it
                ChatCmdMessageHandler.Default.Receive(wrapper); // manually call the receive()
            }
            else
            {
                ICharacter character = client.Controller.Character;
                IPlayfield playfield = character.Playfield;

                float range = 0.0f;
                switch ((int)message.Message.Type)
                {
                case 0x01:
                    range = 1.5f;
                    break;

                case 0x00:
                    range = 10.0f;
                    break;

                case 0x02:
                    range = 60.0f;
                    break;
                }

                List <IDynel> charsInRange = playfield.FindInRange(character, range);

                VicinityChatMessage vicinityChat = new VicinityChatMessage
                {
                    CharacterIds =
                        charsInRange.Select(
                            x => x.Identity.Instance)
                        .ToList(),
                    MessageType = (byte)message.Message.Type,
                    Text        = message.Message.Text,
                    SenderId    = character.Identity.Instance
                };

                Program.ISComClient.Send(vicinityChat);
            }
        }