Esempio n. 1
0
        public ServerPacket RenderToPacket(bool isClick = false)
        {
            var response = new ServerPacket(0x31);

            if (this is Mailbox)
            {
                response.WriteByte(0x04); // 0x02 - public, 0x04 - mail
                response.WriteByte(0x01); // ??? - needs to be odd number unless board in world has been clicked
                response.WriteUInt16(0);  // board ID;
                response.WriteString8("Mail");
                response.WriteByte(Math.Min((byte)this.Count(), (byte)Constants.MESSAGE_RETURN_SIZE));
                foreach (var message in this)
                {
                    response.WriteBoolean(!message.Read);
                    response.WriteInt16((short)message.Id);
                    response.WriteString8(message.Sender);
                    response.WriteByte((byte)message.Created.Month);
                    response.WriteByte((byte)message.Created.Day);
                    response.WriteString8(message.Subject);
                }
            }
            else if (this is Board)
            {
                // boardId 0 - get mail messages
                response.WriteByte(0x02); // 0x02 - public, 0x04 - mail
                response.WriteByte((byte)(isClick == true ? 0x02 : 0x01));
                // ??? - needs to be odd number unless board in world has been clicked
                response.WriteUInt16((ushort)Id);  // board ID;
                response.WriteString8(DisplayName);
                response.WriteByte(Math.Min((byte)this.Count(),
                                            (byte)Constants.MESSAGE_RETURN_SIZE));
                if (this.Count() == 0)
                {
                    return(response);
                }
                foreach (var message in this)
                {
                    response.WriteBoolean(message.Highlighted);
                    response.WriteInt16((short)message.Id);
                    response.WriteString8(message.Sender);
                    response.WriteByte((byte)message.Created.Month);
                    response.WriteByte((byte)message.Created.Day);
                    response.WriteString8(message.Subject);
                }
            }
            return(response);
        }
Esempio n. 2
0
            internal ServerPacket Packet()
            {
                ServerPacket packet   = new ServerPacket(OpCode);
                int          position = packet.Position;

                packet.WriteUInt32(TargetId);
                packet.WriteUInt32(SourceId ?? 0);
                packet.WriteUInt16((ushort)TargetAnimation);
                packet.WriteUInt16((ushort)(SourceAnimation ?? 0));
                packet.WriteInt16(Speed);
                packet.WriteInt32(0);
                return(packet);
            }
Esempio n. 3
0
            internal ServerPacket Packet()
            {
                var packet = new ServerPacket(OpCode);

                packet.WriteByte((byte)MerchantDialogType);
                packet.WriteByte((byte)MerchantDialogObjectType);
                packet.WriteUInt32(ObjectId);
                packet.WriteByte(0);
                packet.WriteInt16((short)Tile1);
                packet.WriteByte(0);
                packet.WriteByte(1);
                packet.WriteInt16((short)Tile1);
                packet.WriteByte(0);
                packet.WriteByte(0);
                packet.WriteString8(Name);
                packet.WriteString16(Text);
                if (MerchantDialogType == MerchantDialogType.Options)
                {
                    packet.WriteByte(Options.OptionsCount);
                    foreach (var opt in Options.Options)
                    {
                        packet.WriteString8(opt.Text);
                        packet.WriteUInt16(opt.Id);
                    }
                }
                if (MerchantDialogType == MerchantDialogType.OptionsWithArgument)
                {
                    packet.WriteString8(OptionsWithArgument.Argument);
                    packet.WriteByte(OptionsWithArgument.OptionsCount);
                    foreach (var opt in OptionsWithArgument.Options)
                    {
                        packet.WriteString8(opt.Text);
                        packet.WriteUInt16(opt.Id);
                    }
                }
                if (MerchantDialogType == MerchantDialogType.Input)
                {
                    packet.WriteUInt16(Input.Id);
                }
                if (MerchantDialogType == MerchantDialogType.InputWithArgument)
                {
                    packet.WriteString8(InputWithArgument.Argument);
                    packet.WriteUInt16(InputWithArgument.Id);
                }
                if (MerchantDialogType == MerchantDialogType.MerchantShopItems)
                {
                    packet.WriteUInt16(ShopItems.Id);
                    packet.WriteUInt16(ShopItems.ItemsCount);
                    foreach (var item in ShopItems.Items)
                    {
                        packet.WriteUInt16(item.Tile);
                        packet.WriteByte(item.Color);
                        packet.WriteUInt32(item.Price);
                        packet.WriteString8(item.Name);
                        packet.WriteString8(item.Description);
                    }
                }
                if (MerchantDialogType == MerchantDialogType.MerchantSkills)
                {
                    packet.WriteUInt16(Skills.Id);
                    packet.WriteUInt16(Skills.SkillsCount);
                    foreach (var skill in Skills.Skills)
                    {
                        packet.WriteByte(skill.IconType);
                        packet.WriteUInt16(skill.Icon);
                        packet.WriteByte(skill.Color);
                        packet.WriteString8(skill.Name);
                    }
                }
                if (MerchantDialogType == MerchantDialogType.MerchantSpells)
                {
                    packet.WriteUInt16(Spells.Id);
                    packet.WriteUInt16(Spells.SpellsCount);
                    foreach (var spell in Spells.Spells)
                    {
                        packet.WriteByte(spell.IconType);
                        packet.WriteUInt16(spell.Icon);
                        packet.WriteByte(spell.Color);
                        packet.WriteString8(spell.Name);
                    }
                }
                if (MerchantDialogType == MerchantDialogType.UserSkillBook)
                {
                    packet.WriteUInt16(UserSkills.Id);
                }
                if (MerchantDialogType == MerchantDialogType.UserSpellBook)
                {
                    packet.WriteUInt16(UserSpells.Id);
                }
                if (MerchantDialogType == MerchantDialogType.UserInventoryItems)
                {
                    packet.WriteUInt16(UserInventoryItems.Id);
                    packet.WriteByte(UserInventoryItems.InventorySlotsCount);
                    foreach (var slot in UserInventoryItems.InventorySlots)
                    {
                        packet.WriteByte(slot);
                    }
                }

                return(packet);
            }