public override void Deserialize(NetworkReader reader)
    {
        Vector2?position       = null;
        var     hasNewPosition = reader.ReadBoolean();

        if (hasNewPosition)
        {
            position = reader.ReadVector2();
        }
        Direction?orientation       = null;
        var       hasNewOrientation = reader.ReadBoolean();

        if (hasNewOrientation)
        {
            orientation = DirectionIO.readDirectionFromBuffer(reader);
        }
        var bullets   = new HashSet <BulletState>();
        var numBullet = reader.ReadInt32();

        for (var i = 0; i < numBullet; i++)
        {
            var bullet = new BulletState();
            bullet.Deserialize(reader);
            bullets.Add(bullet);
        }
        NewPosition    = position;
        NewOrientation = orientation;
        BulletsCreated = bullets;
    }
 public override void Serialize(NetworkWriter writer)
 {
     writer.Write(NewPosition.HasValue);
     if (NewPosition.HasValue)
     {
         writer.Write(NewPosition.Value);
     }
     writer.Write(NewOrientation.HasValue);
     if (NewOrientation.HasValue)
     {
         DirectionIO.writeDirectionToBuffer(NewOrientation.Value, writer);
     }
     writer.Write(BulletsCreated.Count);
     foreach (var bullet in BulletsCreated)
     {
         bullet.Serialize(writer);
     }
 }
Esempio n. 3
0
 public override void Deserialize(NetworkReader reader)
 {
     Position  = reader.ReadVector2();
     Direction = DirectionIO.readDirectionFromBuffer(reader);
     BulletID  = reader.ReadString();
 }
Esempio n. 4
0
 public override void Serialize(NetworkWriter writer)
 {
     writer.Write(Position);
     DirectionIO.writeDirectionToBuffer(Direction, writer);
     writer.Write(BulletID);
 }
Esempio n. 5
0
 public override void Deserialize(NetworkReader reader)
 {
     Position    = reader.ReadVector2();
     Orientation = DirectionIO.readDirectionFromBuffer(reader);
     HP          = reader.ReadSingle();
 }
Esempio n. 6
0
 public override void Serialize(NetworkWriter writer)
 {
     writer.Write(Position);
     DirectionIO.writeDirectionToBuffer(Orientation, writer);
     writer.Write(HP);
 }