/// <summary>
        /// </summary>
        /// <param name="client">
        /// </param>
        /// <returns>
        /// </returns>
        public static PlayfieldAnarchyFMessage Create(IZoneClient client)
        {
            var message = new PlayfieldAnarchyFMessage
            {
                Identity =
                    new Identity
                {
                    Type     = IdentityType.Playfield2,
                    Instance =
                        client.Character.Playfield.Identity
                        .Instance
                },
                CharacterCoordinates =
                    new Vector3
                {
                    X = client.Character.Coordinates.x,
                    Y = client.Character.Coordinates.y,
                    Z = client.Character.Coordinates.z,
                },
                PlayfieldId1 =
                    new Identity
                {
                    Type     = IdentityType.Playfield1,
                    Instance =
                        client.Character.Playfield.Identity
                        .Instance
                },
                PlayfieldId2 =
                    new Identity
                {
                    Type     = IdentityType.Playfield2,
                    Instance =
                        client.Character.Playfield.Identity
                        .Instance
                },
                PlayfieldX =
                    Playfields.GetPlayfieldX(
                        client.Character.Playfield.Identity.Instance),
                PlayfieldZ =
                    Playfields.GetPlayfieldZ(
                        client.Character.Playfield.Identity.Instance)
            };

            // TODO: Add the VendorHandler again

            /* var vendorcount = VendorHandler.GetNumberofVendorsinPlayfield(client.Character.PlayField);
             * if (vendorcount > 0)
             * {
             *  var firstVendorId = VendorHandler.GetFirstVendor(client.Character.PlayField);
             *  message.PlayfieldVendorInfo = new PlayfieldVendorInfo
             *                                    {
             *                                        VendorCount = vendorcount,
             *                                        FirstVendorId = firstVendorId
             *                                    };
             * }
             */
            return(message);
        }
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <returns>
        /// </returns>
        private static MessageDataFiller Filler(ICharacter character)
        {
            return(x =>
            {
                x.Identity = new Identity
                {
                    Type = IdentityType.Playfield2,
                    Instance = character.Playfield.Identity.Instance
                };
                Coordinate temp = character.Coordinates();
                x.CharacterCoordinates = new Vector3 {
                    X = temp.x, Y = temp.y, Z = temp.z,
                };
                x.PlayfieldId1 = new Identity
                {
                    Type = IdentityType.Playfield1,
                    Instance = character.Playfield.Identity.Instance
                };
                x.PlayfieldId2 = new Identity
                {
                    Type = IdentityType.Playfield2,
                    Instance = character.Playfield.Identity.Instance
                };
                x.PlayfieldX = Playfields.GetPlayfieldX(character.Playfield.Identity.Instance);
                x.PlayfieldZ = Playfields.GetPlayfieldZ(character.Playfield.Identity.Instance);

                IEnumerable <Vendor> vendors = Pool.Instance.GetAll <Vendor>(
                    character.Playfield.Identity,
                    (int)IdentityType.VendingMachine);

                /*                if (vendors.Any())
                 * {
                 *  x.PlayfieldVendorInfo = new PlayfieldVendorInfo()
                 *                          {
                 *                              VendorCount = vendors.Count(),
                 *                              FirstVendorId =
                 *                                  vendors.ElementAt(0).Identity.Instance
                 *                          };
                 * }*/
            });

            // TODO: Add the VendorHandler again

            /* var vendorcount = VendorHandler.GetNumberofVendorsinPlayfield(client.Character.PlayField);
             * if (vendorcount > 0)
             * {
             *  var firstVendorId = VendorHandler.GetFirstVendor(client.Character.PlayField);
             *  message.PlayfieldVendorInfo = new PlayfieldVendorInfo
             *                                    {
             *                                        VendorCount = vendorcount,
             *                                        FirstVendorId = firstVendorId
             *                                    };
             * }
             */
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        public static void Send(Client client)
        {
            PacketWriter packetWriter = new PacketWriter();

            packetWriter.PushBytes(new byte[] { 0xDF, 0xDF });
            packetWriter.PushShort(10);
            packetWriter.PushShort(1);
            packetWriter.PushShort(0);
            packetWriter.PushInt(3086);
            packetWriter.PushInt(client.Character.Id);
            packetWriter.PushInt(0x5F4B1A39);
            packetWriter.PushIdentity(40016, client.Character.PlayField);
            packetWriter.PushByte(0);

            packetWriter.PushInt(4);
            packetWriter.PushCoord(client.Character.Coordinates);
            packetWriter.PushByte(97);
            packetWriter.PushIdentity(51100, client.Character.PlayField);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0);
            packetWriter.PushIdentity(40016, client.Character.PlayField);
            packetWriter.PushInt(0);
            packetWriter.PushInt(0);

            int vendorcount = VendorHandler.GetNumberofVendorsinPlayfield(client.Character.PlayField);

            if (vendorcount > 0)
            {
                packetWriter.PushInt(51035);
                packetWriter.PushInt(1);
                packetWriter.PushInt(1);
                packetWriter.PushInt(vendorcount);
                packetWriter.PushInt(VendorHandler.GetFirstVendor(client.Character.PlayField));
            }
            // TODO: Use correct World Position for each "outdoors" playfield -Suiv-
            // Playfield WorldPos X
            packetWriter.PushInt(Playfields.GetPlayfieldX(client.Character.PlayField));
            // Playfield WorldPos Z
            packetWriter.PushInt(Playfields.GetPlayfieldZ(client.Character.PlayField));

            byte[] packet = packetWriter.Finish();
            client.SendCompressed(packet);
        }