Example #1
0
        public static Unit ReadFrom(System.IO.BinaryReader reader)
        {
            var result = new Unit();

            result.PlayerId    = reader.ReadInt32();
            result.Id          = reader.ReadInt32();
            result.Health      = reader.ReadInt32();
            result.Position    = Vec2Double.ReadFrom(reader);
            result.Size        = Vec2Double.ReadFrom(reader);
            result.JumpState   = JumpState.ReadFrom(reader);
            result.WalkedRight = reader.ReadBoolean();
            result.Stand       = reader.ReadBoolean();
            result.OnGround    = reader.ReadBoolean();
            result.OnLadder    = reader.ReadBoolean();
            result.Mines       = reader.ReadInt32();
            if (reader.ReadBoolean())
            {
                result.Weapon = Model.Weapon.ReadFrom(reader);
            }
            else
            {
                result.Weapon = null;
            }
            return(result);
        }
Example #2
0
        public static Unit ReadFrom(System.IO.BinaryReader reader)
        {
            if (reader == null)
                throw new System.ArgumentNullException(nameof(reader));

            var playerId = reader.ReadInt32();
            var id = reader.ReadInt32();
            var health = reader.ReadInt32();
            var position = Vec2Double.ReadFrom(reader);
            var size = Vec2Double.ReadFrom(reader);
            var jumpState = JumpState.ReadFrom(reader);
            var walkedRight = reader.ReadBoolean();
            var stand = reader.ReadBoolean();
            var onGround = reader.ReadBoolean();
            var onLadder = reader.ReadBoolean();
            var mines = reader.ReadInt32();
            var weapon = reader.ReadBoolean() ? Weapon.ReadFrom(reader) : null;

            return new Unit(playerId, id, health, position, size, jumpState, walkedRight, stand, onGround, onLadder, mines, weapon);
        }