Exemplo n.º 1
0
        public static PlayerLocationDetails ToPlayerLocationDetails(this PlayerState source)
        {
            var result = new PlayerLocationDetails
            {
                PlayerId          = source.Id,
                PlayerX           = source.GetPosition().X,
                PlayerY           = source.GetPosition().Y,
                MovementType      = source.MovementType,
                MovementDirection = source.MovementDirection,
                MovementSpeed     = (source.MovementType == eMovementType.Running ? source.GetRunVelocity() : source.GetWalkVeloicty()) / 4f
            };

            return(result);
        }
Exemplo n.º 2
0
        public static PlayerLocationDetails FromBytes(byte[] data, int offset = 0)
        {
            var result = new PlayerLocationDetails
            {
                PlayerId          = BitConverter.ToInt32(data, offset + 0),
                PlayerX           = BitConverter.ToSingle(data, offset + 4),
                PlayerY           = BitConverter.ToSingle(data, offset + 8),
                MovementDirection = BitConverter.ToInt32(data, offset + 12),
                MovementType      = (eMovementType)data[offset + 16],
                MovementSpeed     = BitConverter.ToSingle(data, offset + 18)
            };

            return(result);
        }
Exemplo n.º 3
0
        public static PlayerInfo FromBytes(byte[] data, int offset = 0)
        {
            using (var stream = new MemoryStream(data))
                using (var reader = new BinaryReader(stream))
                {
                    reader.ReadBytes(offset); // Skip

                    var result = new PlayerInfo
                    {
                        Hero            = (eHero)reader.ReadByte(),
                        MobMode         = (eMobMode)reader.ReadByte(),
                        Name            = reader.ReadString(),
                        Equipment       = reader.ReadPlayerEquipment(),
                        LocationDetails = PlayerLocationDetails.FromBytes(reader.ReadBytes(PlayerLocationDetails.SizeInBytes)),
                        UID             = new Guid(reader.ReadBytes(16))
                    };

                    return(result);
                }
        }