Exemplo n.º 1
0
        public static LocationDetails FromBytes(BinaryReader br)
        {
            var result = new LocationDetails
            {
                UID = new Guid(br.ReadBytes(16)),
                X   = br.ReadSingle(),
                Y   = br.ReadSingle(),
                MovementDirection = br.ReadInt32(),
                MovementType      = (eMovementType)br.ReadByte(),
                MovementSpeed     = br.ReadSingle()
            };
            var numWaypoints = br.ReadInt16();

            result.Waypoints = new List <PointF>(numWaypoints);
            for (var i = 0; i < numWaypoints; i++)
            {
                result.Waypoints.Add(new PointF
                {
                    X = br.ReadSingle(),
                    Y = br.ReadSingle()
                });
            }

            return(result);
        }
Exemplo n.º 2
0
        public static LocationDetails ToPlayerLocationDetails(this PlayerState source)
        {
            var result = new LocationDetails
            {
                UID           = source.UID,
                X             = source.GetPosition().X,
                Y             = source.GetPosition().Y,
                Waypoints     = source.Waypoints,
                MovementType  = source.MovementType,
                MovementSpeed = (source.MovementType == eMovementType.Running ? source.GetRunVelocity() : source.GetWalkVeloicty()) / 4f
            };

            return(result);
        }
Exemplo n.º 3
0
        public byte[] GetBytes()
        {
            using (var stream = new MemoryStream())
                using (var writer = new BinaryWriter(stream))
                {
                    writer.Write((byte)Hero);
                    writer.Write((byte)MobMode);
                    writer.Write(Name);
                    writer.Write(Equipment);
                    writer.Write(LocationDetails.GetBytes());
                    writer.Write(UID.ToByteArray());

                    return(stream.ToArray());
                }
        }