public override void Update(Piece player, Direction playersDirection) { int deltaY = player.Position.Height - Position.Height; int deltaX = player.Position.Width - Position.Width; Direction direction = Direction.Stay; if (Math.Abs(deltaY) > Math.Abs(deltaX)) { if (deltaY > 0) { direction = Direction.Down; } else { direction = Direction.Up; } } else { if (deltaX > 0) { direction = Direction.Right; } else { direction = Direction.Left; } } Position = PositionTarsformer.Move(Position, direction); }
public override void Update(Piece player, Direction direction) { Position = PositionTarsformer.Move(Position, direction); }