/// <summary> /// Method that moves the ghost towards pacman /// </summary> public void Move() { //Changes Target positions once it passes the previous target if (target == position) { target = pacman.Position; } //Use the state objec to decide how to move currentState.Move(); }
/// <summary> /// Moves ghost based on the IGhostState it is currently set to. When a move has been made, checks to see if a collision has been made /// </summary> public void Move() { if (Position.X == target.X && Position.Y == target.Y) { if (currentState is Chase) { ((Chase)currentState).UpdateTarget(pacman.Position); } target = pacman.Position; } currentState.Move(); Collide(); }
/// <summary> /// A Ghost can move depending his state because we /// use an interface the Move will be choosed at run-time /// </summary> public void Move() { currentState.Move(); this.Collide(); }