Example #1
0
        public void Can_deserialize()
        {
            var rawPacket = FakePackets.Instantiate(new byte[]
            {
                0x77,                   // packet
                0x00, 0x06, 0x62, 0x21, // PlayerId
                0x00, 0x06,             // type
                0x08, 0xED,             // xloc
                0x09, 0x7F,             // yloc
                0x01,                   // zloc
                0x01,                   // direction
                0x09, 0x01,             // color
                0x00,                   // status flag
                0x03,                   // highlight color
            });

            var packet = new UpdatePlayerPacket();

            packet.Deserialize(rawPacket);

            packet.PlayerId.Should().Be(new ObjectId(0x00066221));
            packet.Type.Should().Be((ModelId)0x0006);
            packet.Location.X.Should().Be(0x08ed);
            packet.Location.Y.Should().Be(0x097f);
            packet.Location.Z.Should().Be(1);
            packet.Direction.Should().Be(Direction.Northeast);
            packet.MovementType.Should().Be(MovementType.Walk);
            packet.Color.Should().Be((Color)0x0901);
        }
Example #2
0
 private void HandleUpdatePlayerInfo(UpdatePlayerPacket packet)
 {
     text.text += "Player Shop: ";
     for (int i = 0; i < 5; i++)
     {
         text.text += "\n" + packet.Shop[i];
     }
     text.text += "\n";
 }
Example #3
0
 private void HandleUpdatePlayerPacket(UpdatePlayerPacket packet)
 {
     if (packet.PlayerId == player.PlayerId)
     {
         player.Flags        = packet.Flags;
         player.BodyType     = packet.Type;
         player.Direction    = packet.Direction;
         player.Location     = packet.Location;
         player.MovementType = packet.MovementType;
         player.Color        = packet.Color;
     }
 }
Example #4
0
        private void HandleUpdatePlayerPacket(UpdatePlayerPacket packet)
        {
            if (packet.PlayerId == legacyApi.Me.PlayerId)
            {
                return;
            }

            if (gameObjects.TryGet(packet.PlayerId, out GameObject existingObject) &&
                existingObject is Mobile existingMobile)
            {
                var updatedMobile = existingMobile.Update(packet.Type, packet.Location, packet.Color,
                                                          packet.Direction, packet.MovementType, existingMobile.Notoriety, packet.Flags);
                gameObjects.UpdateObject(updatedMobile);

                CheckFlagsChange(existingMobile, updatedMobile);
            }
            else
            {
                gameObjects.UpdateObject(new Mobile(packet.PlayerId, packet.Type, packet.Location, packet.Color,
                                                    packet.Direction, packet.MovementType, null, packet.Flags));
            }
        }
Example #5
0
        public void UpdatePlayer(ObjectId playerId, ModelId bodyType, Location3D location, Direction direction, Color color)
        {
            var packet = new UpdatePlayerPacket(playerId, bodyType, location, direction, color);

            Send(packet.RawPacket);
        }
Example #6
0
 private void DisplayXPLevel(UpdatePlayerPacket packet)
 {
     xpText.text = "XP: " + packet.XP + "/" + DisplayExperienceToLevel(packet.Level);
 }
Example #7
0
 private void DisplayPlayerLevel(UpdatePlayerPacket packet)
 {
     levelText.text = "Level: " + packet.Level;
 }
Example #8
0
 private void DisplayPlayerGold(UpdatePlayerPacket packet)
 {
     goldText.text = "Gold: " + packet.Gold;
 }