/// <summary>
        /// Probably some sort of global channel message
        /// </summary>
        public void NotSure(string text, string something)
        {
            var builder = new PacketBuilder(Packets.SendToClient.Message);

            builder.AddString(text);                   // source player
            builder.AddU8((byte)MessageTypes.NotSure); // message type
            builder.AddString(something);              // source player
            builder.Send(_player);
        }
        public void Private(string fromName, string message)
        {
            var builder = new PacketBuilder(Packets.SendToClient.Message);

            builder.AddString(fromName);               // source player
            builder.AddU8((byte)MessageTypes.Private); // message type
            builder.AddString(message);
            builder.Send(_player);
        }
        public void LocalMessage(Position pos, string fromName, string message, byte speechType)
        {
            var builder = new PacketBuilder(Packets.SendToClient.Message);

            builder.AddString(fromName); // source player
            builder.AddU8(speechType);   // message type
            builder.AddPosition(pos);
            builder.AddString(message);
            builder.Send(_player);
        }
        public void Yell(Position pos, string fromName, string message)
        {
            var builder = new PacketBuilder(Packets.SendToClient.Message);

            builder.AddString(fromName);            // source player
            builder.AddU8((byte)MessageTypes.Yell); // message type
            builder.AddPosition(pos);
            builder.AddString(message.ToUpper());
            builder.Send(_player);
        }
        public void Creature(Position pos, string message)
        {
            var builder = new PacketBuilder(Packets.SendToClient.Message);

            builder.AddString("");                      // source player
            builder.AddU8((byte)MessageTypes.Creature); // message type
            builder.AddPosition(pos);
            builder.AddString(message);
            builder.Send(_player);
        }
示例#6
0
        public byte[] ToBytes()
        {
            PacketBuilder builder = new PacketBuilder();

            builder.AddInt32(PACKET_HEADER);
            builder.AddByte((byte)_type);
            builder.AddString(_gameTitle);
            builder.AddVersion(_gameVersion);
            builder.AddIPAddress(_sourceIP);
            builder.AddIPAddress(_destinationIP);
            builder.AddString(_playerName);
            AddInstanceBytes(builder);
            builder.AddInt32(PACKET_FOOTER);
            return(builder.ToBytes());
        }
        public void Open(byte newContainerIndex, Item container, ItemStructure strucc, bool childContainer = true)
        {
            var builder = new PacketBuilder(Packets.SendToClient.OpenContainer);
            builder.AddU8(newContainerIndex); // container index
            builder.AddU16(container.Id); // container look id? the one identifying the container
            builder.AddString(strucc.Name);
            builder.AddU8(strucc.ContainerSize);
            builder.AddU8((byte)(childContainer ? 1 : 0)); // 0 == root container, 1 == child container
            var inside = container.Inside;
            if (inside == null)
            {
                builder.AddU8(0);
            }
            else
            {
                builder.AddU8((byte) inside.Count);
                for (int i = 0; i < inside.Count; i++)
                {
                    builder.AddItem(inside[i]);
                }
            }

            _player.OpenContainer(container);

            builder.Send(_player);
        }
示例#8
0
        private static void NewMethod1(Player player, Item item, ItemStructure strucc)
        {
            var builder = new PacketBuilder(Packets.SendToClient.OpenContainer);

            builder.AddU8(0);        // container index
            builder.AddU16(item.Id); // container look id? the one identifying the container
            builder.AddString(strucc.Name);
            builder.AddU8(strucc.ContainerSize);
            builder.AddU8(0); // root container, 1 == child container
            var inside = player.Equipment.Backpack.Inside;

            if (inside == null)
            {
                builder.AddU8(0);
            }
            else
            {
                builder.AddU8((byte)inside.Count);
                for (int i = 0; i < inside.Count; i++)
                {
                    builder.AddItem(inside[i]);
                }
            }

            player.OpenContainer(player.Equipment.Backpack);

            builder.Send(player);
        }
        public void LookAt(string message)
        {
            var builder = new PacketBuilder(Packets.SendToClient.SpecialMessage);

            builder.AddU8(0x13);
            builder.AddString(message);
            builder.Send(_player);
        }
        public void ServerBroadcast(string message)
        {
            var builder = new PacketBuilder(Packets.SendToClient.SpecialMessage);

            builder.AddU8(0xF);
            builder.AddString(message);
            builder.Send(_player);
        }
        public static void SendSorryMessageBox(this Socket connection, string message)
        {
            var builder = new PacketBuilder();

            builder.AddPacketId(Packets.SendToClient.SorryMessageBox);
            builder.AddString(message);
            builder.Send(connection);
        }
        public void Sorry(string message)
        {
            var builder = new PacketBuilder();

            builder.AddPacketId(Packets.SendToClient.SorryMessageBox);
            builder.AddString(message);
            builder.Send(_player.Connection);
        }
        public void AdvanceOrRaid(string message)
        {
            var builder = new PacketBuilder(Packets.SendToClient.SpecialMessage);

            builder.AddU8(0x10);
            builder.AddString(message);
            builder.Send(_player);
        }
        public void StatusAndConsole(string message)
        {
            var builder = new PacketBuilder(Packets.SendToClient.SpecialMessage);

            builder.AddU8(0x11);
            builder.AddString(message);
            builder.Send(_player);
        }
        public void Animated(Position pos, Colors color, string message)
        {
            var builder = new PacketBuilder(Packets.SendToClient.AnimatedText);

            builder.AddPosition(pos);
            builder.AddU8((byte)color);
            builder.AddString(message);
            builder.Send(_player);
        }
示例#16
0
        private async Task HandleClientRequest()
        {
            var builder = new PacketBuilder();

            builder.AddInt16(0x0003);
            builder.AddBytes(new byte[6]);
            builder.AddByte(0x01);
            builder.AddString("Infantry", 9);
            builder.AddBytes(new byte[16]);

            var buffer = builder.GetBytes();

            await this.networkClient.SendAsync(buffer, buffer.Length);
        }
示例#17
0
        /// <summary>
        /// Serializes high score list to packet bytes.
        /// </summary>
        public byte[] ToBytes()
        {
            PacketBuilder builder = new PacketBuilder();

            lock (this)
            {
                builder.AddUInt16((ushort)_scores.Count);
                foreach (HighScore score in _scores)
                {
                    builder.AddString(score.Initials ?? "");
                    builder.AddInt32(score.Score);
                }
            }
            return(builder.ToBytes());
        }
示例#18
0
        public IPacket BuildChatPacket(ChatType chatType,
                                       string chat,
                                       string targetCharacter)
        {
            IPacketBuilder packetBuilder = new PacketBuilder(PacketFamily.Talk, GetActionFromType(chatType));

            if (chatType == ChatType.PM)
            {
                if (string.IsNullOrEmpty(targetCharacter))
                {
                    throw new ArgumentException("Target character for PM must not be null or empty", nameof(targetCharacter));
                }
                packetBuilder = packetBuilder.AddBreakString(targetCharacter);
            }

            packetBuilder = packetBuilder.AddString(chat);
            return(packetBuilder.Build());
        }