Package ch.epfl.cs107.play.areagame.area
Class AreaBehavior.Cell
java.lang.Object
ch.epfl.cs107.play.areagame.area.AreaBehavior.Cell
- All Implemented Interfaces:
Interactable
- Enclosing class:
AreaBehavior
Each AreaGame will have its own Cell extension.
At minimum a cell is linked to its content
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.epfl.cs107.play.areagame.actor.Interactable
Interactable.Listener -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancanEnter(Interactable entity) Indicate if the given Interactable can enter this Cellprotected abstract booleancanLeave(Interactable entity) Indicate if the given Interactable can leave this Cellprotected voidenter(Interactable entity) Do the given interactable enter into this CellGet this Interactor's current occupying cells coordinatesprotected voidleave(Interactable entity) Do the given Interactable leave this CellvoidonEntering(List<DiscreteCoordinates> coordinates) Called when this Interactable enters a cellvoidonLeaving(List<DiscreteCoordinates> coordinates) Called when this Interactable leaves a cellbooleanIndicate if the current Interactable take the whole cell space or not i.e.Methods 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, isCellInteractable, isViewInteractable
-
Field Details
-
entities
-
coordinates
-
-
Constructor Details
-
Cell
protected Cell(int x, int y) Default Cell constructor- Parameters:
x- (int): x-coordinate of this celly- (int): y-coordinate of this cell
-
-
Method Details
-
enter
Do the given interactable enter into this Cell- Parameters:
entity- (Interactable), not null
-
leave
Do the given Interactable leave this Cell- Parameters:
entity- (Interactable), not null
-
canLeave
Indicate if the given Interactable can leave this Cell- Parameters:
entity- (Interactable), not null- Returns:
- (boolean): true if entity can leave
-
canEnter
Indicate if the given Interactable can enter this Cell- Parameters:
entity- (Interactable), not null- Returns:
- (boolean): true if entity can enter
-
takeCellSpace
public boolean takeCellSpace()Description copied from interface:InteractableIndicate if the current Interactable take the whole cell space or not i.e. only one Interactable which takeCellSpace can be in a cell (how many Interactable which don't takeCellSpace can also be in the same cell)- Specified by:
takeCellSpacein interfaceInteractable- Returns:
- (boolean)
-
onLeaving
Description copied from interface:InteractableCalled when this Interactable leaves a cell- Specified by:
onLeavingin interfaceInteractable- Parameters:
coordinates- left cell coordinates
-
onEntering
Description copied from interface:InteractableCalled when this Interactable enters a cell- Specified by:
onEnteringin interfaceInteractable- Parameters:
coordinates- entered cell coordinates
-
getCurrentCells
Description copied from interface:InteractableGet this Interactor's current occupying cells coordinates- Specified by:
getCurrentCellsin interfaceInteractable- Returns:
- (List of DiscreteCoordinates). May be empty but not null
-