org.deken.game.movement
Class PathFindingToTile4Movement

java.lang.Object
  extended by org.deken.game.movement.BaseMovement
      extended by org.deken.game.movement.ToTile4Movement
          extended by org.deken.game.movement.PathFindingToTile4Movement
All Implemented Interfaces:
Movement, Updateable

public class PathFindingToTile4Movement
extends ToTile4Movement
implements Movement

Title: PathFindingToTileMovement

Description: TODO

Copyright: Copyright (c) Apr 1, 2012

Version:
1.0
Author:
Gary Deken

Nested Class Summary
static class PathFindingToTile4Movement.FINDING_DIRECTION
          FORWARD_FORWARD = path is always forward FORWARD_BACK = path is forward, but on New Target change go back ANY_BACK = path is first find path, but on New Target change go back ANY_FORWARD = path is first find path, but on New Target change go forward
 
Field Summary
 
Fields inherited from class org.deken.game.movement.ToTile4Movement
currentXTile, currentYTile, mapSize, movingToTile, parent, running, speed, targetX, targetXTile, targetY, targetYTile
 
Fields inherited from class org.deken.game.movement.BaseMovement
gameVector, name
 
Constructor Summary
PathFindingToTile4Movement()
           
PathFindingToTile4Movement(Actor actor, MapSize mapSize, FindPathsFourWay findPaths, Sprite target)
           
PathFindingToTile4Movement(Actor actor, MapSize mapSize, FindPathsFourWay findPaths, Sprite target, PathFindingToTile4Movement.FINDING_DIRECTION pathFinding)
          The Targeting is used to determine the course of action.
 
Method Summary
 void addTileMovementListener(TileMovementListener listener)
           
 void collideHorizontal()
          Adjust the horizontal (x axis) movement to a collision.
 void collideVertical()
          Adjust the vertical (y axis) movement to a collision.
 Movement copy(Actor actor)
          Copies the movement.
protected  GameVector.DIRECTION getDirectionEnum()
           
 boolean isTargetReached()
           
protected  void markTileReached()
           
 void reset()
           
 void resetLocation(int xTile, int yTile)
           
 void resetLocation(int xTile, int yTile, int lastXTile, int lastYTile)
           
 void setFindPaths(FindPathsFourWay findPaths, Sprite target)
           
 void setTarget(Sprite sprite)
          Sets a new Target for Parent to move towards.
 void update(long elapseTime)
          This method takes the elapse time, since the last update, and to determine the next movement to set to the GameVector.
 
Methods inherited from class org.deken.game.movement.ToTile4Movement
checkReverseDirection, collideLayer, copyBase, getXUpdate, getYUpdate, isMovingToTile, setRunning, setSpeed, setTargetTile
 
Methods inherited from class org.deken.game.movement.BaseMovement
baseCopy, getDirection, getGameVector, getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.deken.game.movement.Movement
collideLayer, getDirection, getGameVector, getXUpdate, getYUpdate
 
Methods inherited from interface org.deken.game.Updateable
getName
 

Constructor Detail

PathFindingToTile4Movement

public PathFindingToTile4Movement()

PathFindingToTile4Movement

public PathFindingToTile4Movement(Actor actor,
                                  MapSize mapSize,
                                  FindPathsFourWay findPaths,
                                  Sprite target)

PathFindingToTile4Movement

public PathFindingToTile4Movement(Actor actor,
                                  MapSize mapSize,
                                  FindPathsFourWay findPaths,
                                  Sprite target,
                                  PathFindingToTile4Movement.FINDING_DIRECTION pathFinding)
The Targeting is used to determine the course of action. Should movement stop when target is reached, or continue to the next node. Path_Finding is used to determine if the movement should double back on itself or continue forwards. If it should be continues until collision.

Parameters:
actor -
mapSize -
findPaths -
target -
pathFinding -
Method Detail

addTileMovementListener

public void addTileMovementListener(TileMovementListener listener)

collideHorizontal

public void collideHorizontal()
Description copied from interface: Movement
Adjust the horizontal (x axis) movement to a collision.

Specified by:
collideHorizontal in interface Movement
Overrides:
collideHorizontal in class ToTile4Movement

collideVertical

public void collideVertical()
Description copied from interface: Movement
Adjust the vertical (y axis) movement to a collision.

Specified by:
collideVertical in interface Movement
Overrides:
collideVertical in class ToTile4Movement

copy

public Movement copy(Actor actor)
Description copied from interface: Movement
Copies the movement.

Specified by:
copy in interface Movement
Returns:
Movement

isTargetReached

public boolean isTargetReached()

reset

public void reset()
Overrides:
reset in class ToTile4Movement

resetLocation

public void resetLocation(int xTile,
                          int yTile)

resetLocation

public void resetLocation(int xTile,
                          int yTile,
                          int lastXTile,
                          int lastYTile)

setFindPaths

public void setFindPaths(FindPathsFourWay findPaths,
                         Sprite target)

setTarget

public void setTarget(Sprite sprite)
Sets a new Target for Parent to move towards. This also calculates a path to the new Target. This uses the Path_Finding Forward on Target Change

Parameters:
sprite -

update

public void update(long elapseTime)
Description copied from interface: Movement
This method takes the elapse time, since the last update, and to determine the next movement to set to the GameVector.

Specified by:
update in interface Movement
Specified by:
update in interface Updateable
Overrides:
update in class ToTile4Movement
Parameters:
elapseTime - long

markTileReached

protected void markTileReached()
Specified by:
markTileReached in class ToTile4Movement

getDirectionEnum

protected GameVector.DIRECTION getDirectionEnum()
Specified by:
getDirectionEnum in class ToTile4Movement