Class AreaBehavior.Cell

java.lang.Object
ch.epfl.cs107.play.areagame.area.AreaBehavior.Cell
All Implemented Interfaces:
Interactable
Enclosing class:
AreaBehavior

public abstract class AreaBehavior.Cell extends Object implements Interactable
Each AreaGame will have its own Cell extension. At minimum a cell is linked to its content
  • Field Details

  • Constructor Details

    • Cell

      protected Cell(int x, int y)
      Default Cell constructor
      Parameters:
      x - (int): x-coordinate of this cell
      y - (int): y-coordinate of this cell
  • Method Details

    • enter

      protected void enter(Interactable entity)
      Do the given interactable enter into this Cell
      Parameters:
      entity - (Interactable), not null
    • leave

      protected void leave(Interactable entity)
      Do the given Interactable leave this Cell
      Parameters:
      entity - (Interactable), not null
    • canLeave

      protected abstract boolean canLeave(Interactable entity)
      Indicate if the given Interactable can leave this Cell
      Parameters:
      entity - (Interactable), not null
      Returns:
      (boolean): true if entity can leave
    • canEnter

      protected abstract boolean canEnter(Interactable entity)
      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: Interactable
      Indicate 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:
      takeCellSpace in interface Interactable
      Returns:
      (boolean)
    • onLeaving

      public void onLeaving(List<DiscreteCoordinates> coordinates)
      Description copied from interface: Interactable
      Called when this Interactable leaves a cell
      Specified by:
      onLeaving in interface Interactable
      Parameters:
      coordinates - left cell coordinates
    • onEntering

      public void onEntering(List<DiscreteCoordinates> coordinates)
      Description copied from interface: Interactable
      Called when this Interactable enters a cell
      Specified by:
      onEntering in interface Interactable
      Parameters:
      coordinates - entered cell coordinates
    • getCurrentCells

      public List<DiscreteCoordinates> getCurrentCells()
      Description copied from interface: Interactable
      Get this Interactor's current occupying cells coordinates
      Specified by:
      getCurrentCells in interface Interactable
      Returns:
      (List of DiscreteCoordinates). May be empty but not null