Class MovableAreaEntity
java.lang.Object
ch.epfl.cs107.play.engine.actor.Entity
ch.epfl.cs107.play.areagame.actor.AreaEntity
ch.epfl.cs107.play.areagame.actor.MovableAreaEntity
- All Implemented Interfaces:
Interactable,Acoustics,Actor,Graphics,Updatable,Positionable
MovableAreaEntity represent AreaEntity which can move on the grid
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.epfl.cs107.play.areagame.actor.Interactable
Interactable.Listener -
Constructor Summary
ConstructorsConstructorDescriptionMovableAreaEntity(Area area, Orientation orientation, DiscreteCoordinates position) Default MovableAreaEntity constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected final booleanFinal abortCurrentMove method If a displacement occurs and if the displacement is not end, abort the current move, returning to the previous cell Note the abort is possible only if this MovableAreaEntity can: - return to the cells it left - leave the cells it enteredbooleanchangePosition(DiscreteCoordinates newPosition) Change the unit position to the one specifiedprotected booleanIndicate if a displacement is occurringprotected booleanprotected final booleanmove(int frameForMove) Final move method If no displacement occurs or if the displacement just ends now, start movement of one Cell in the current Orientation direction Note the movement is possible only if this MovableAreaEntity can: - leave the cells this motion implies to leave - enter the cells this motion implies to enterprotected final booleanmove(int frameForMove, int startingFrame) Final move method If no displacement occurs or if the displacement just ends now, start movement of one Cell in the current Orientation direction Note the movement is possible only if this MovableAreaEntity can: - leave the cells this motion implies to leave - enter the cells this motion implies to enterprotected booleanorientate(Orientation orientation) Orientate the AreaEntity to a new orientationprotected voidInitialize or reset (if some) the current motion informationvoidupdate(float deltaTime) Simulates a single time step.Methods inherited from class ch.epfl.cs107.play.areagame.actor.AreaEntity
getCurrentMainCellCoordinates, getOrientation, getOwnerArea, isMouseOver, onEntering, onLeaving, setCurrentPosition, setOwnerAreaMethods inherited from class ch.epfl.cs107.play.engine.actor.Entity
getPosition, getTransformMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ch.epfl.cs107.play.areagame.actor.Interactable
acceptInteraction, getCurrentCells, isCellInteractable, isViewInteractable, takeCellSpace
-
Constructor Details
-
MovableAreaEntity
Default MovableAreaEntity constructor- Parameters:
area- (Area): Owner area. Not nullorientation- (Orientation): Initial orientation of the entity. Not nullposition- (Coordinate): Initial position of the entity. Not null
-
-
Method Details
-
resetMotion
protected void resetMotion()Initialize or reset (if some) the current motion information -
move
protected final boolean move(int frameForMove) Final move method If no displacement occurs or if the displacement just ends now, start movement of one Cell in the current Orientation direction Note the movement is possible only if this MovableAreaEntity can: - leave the cells this motion implies to leave - enter the cells this motion implies to enter- Parameters:
frameForMove- (int): the frame. This value will be cropped to 1 if smaller- Returns:
- (boolean): indicate if the move is initiated
-
move
protected final boolean move(int frameForMove, int startingFrame) Final move method If no displacement occurs or if the displacement just ends now, start movement of one Cell in the current Orientation direction Note the movement is possible only if this MovableAreaEntity can: - leave the cells this motion implies to leave - enter the cells this motion implies to enter- Parameters:
frameForMove- (int): the frame. This value will be cropped to 1 if smallerstartingFrame- (int): start the movement directly from this frame- Returns:
- (boolean): indicate if the move is initiated
-
changePosition
Change the unit position to the one specified- Parameters:
newPosition- new unit's position- Returns:
- true if the move was successful, false otherwise
-
abortCurrentMove
protected final boolean abortCurrentMove()Final abortCurrentMove method If a displacement occurs and if the displacement is not end, abort the current move, returning to the previous cell Note the abort is possible only if this MovableAreaEntity can: - return to the cells it left - leave the cells it entered- Returns:
- (boolean): indicate if the abort is initiated
-
isDisplacementOccurs
protected boolean isDisplacementOccurs()Indicate if a displacement is occurring- Returns:
- (boolean)
-
isTargetReached
protected boolean isTargetReached()- Returns:
- (boolean): true when the target cell is just reaching now
-
orientate
Description copied from class:AreaEntityOrientate the AreaEntity to a new orientation- Overrides:
orientatein classAreaEntity- Parameters:
orientation- (Orientation): The new orientation. Not null- Returns:
- (boolean): if the orientation change happens, by default always true
-
update
public void update(float deltaTime) Description copied from interface:UpdatableSimulates a single time step. Note: Need to be Override- Parameters:
deltaTime- elapsed time since last update, in seconds, non-negative
-
getVelocity
- Specified by:
getVelocityin interfacePositionable- Overrides:
getVelocityin classEntity- Returns:
- (Vector): linear velocity, not null
-