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); } }
public override void Deserialize(NetworkReader reader) { Position = reader.ReadVector2(); Direction = DirectionIO.readDirectionFromBuffer(reader); BulletID = reader.ReadString(); }
public override void Serialize(NetworkWriter writer) { writer.Write(Position); DirectionIO.writeDirectionToBuffer(Direction, writer); writer.Write(BulletID); }
public override void Deserialize(NetworkReader reader) { Position = reader.ReadVector2(); Orientation = DirectionIO.readDirectionFromBuffer(reader); HP = reader.ReadSingle(); }
public override void Serialize(NetworkWriter writer) { writer.Write(Position); DirectionIO.writeDirectionToBuffer(Orientation, writer); writer.Write(HP); }