package ch.epfl.maze.physical.pacman; import ch.epfl.maze.physical.Animal; import ch.epfl.maze.physical.Daedalus; import ch.epfl.maze.physical.GhostPredator; import ch.epfl.maze.util.Direction; import ch.epfl.maze.util.Vector2D; /** * Pink ghost from the Pac-Man game, targets 4 squares in front of its target. * * @author EPFL * @author Pacien TRAN-GIRARD */ public class Pinky extends GhostPredator { private static final int TARGET_OFFSET = 4; /** * Constructs a Pinky with a starting position. * * @param position Starting position of Pinky in the labyrinth */ public Pinky(Vector2D position) { super(position); } /** * Targets the position the Prey is heading toward. * * @param daedalus The Daedalus * @return The projected position */ @Override protected Vector2D getPreyTargetPosition(Daedalus daedalus) { Vector2D offsetVector = this.getTargetOffsetVector(this.getPreyDirection(daedalus)); return this .getPreyPosition(daedalus) .add(offsetVector); } /** * Returns the offset vector directed to the given Direction. * * @param direction The Direction * @return The offset Vector2D */ private Vector2D getTargetOffsetVector(Direction direction) { return (new Vector2D()) .addDirectionTo(direction) .mul(TARGET_OFFSET); } @Override public Animal copy() { return new Pinky(this.getPosition()); } }