Class AreaBehavior

java.lang.Object
ch.epfl.cs107.play.areagame.area.AreaBehavior
All Implemented Interfaces:
Interactable.Listener, Interactor.Listener

public abstract class AreaBehavior extends Object implements Interactable.Listener, Interactor.Listener
AreaBehavior is a basically a map made of Cells. Those cells are used for the game behavior Note: implementation from Interactable.Listener not excpected from students
  • Constructor Details

    • AreaBehavior

      public AreaBehavior(Window window, String name)
      Default AreaBehavior Constructor
      Parameters:
      window - (Window): graphic context, not null
      name - (String): name of the behavior image, not null
  • Method Details

    • dropInteractionOf

      public void dropInteractionOf(Draggable draggable, DiscreteCoordinates mouseCoordinates)
    • cellInteractionOf

      public void cellInteractionOf(Interactor interactor)
      Description copied from interface: Interactor.Listener
      Do the interactor interact with Interactable (i.e. Interactable sharing the same cell)
      Specified by:
      cellInteractionOf in interface Interactor.Listener
      Parameters:
      interactor - (Interactor). Not null
    • viewInteractionOf

      public void viewInteractionOf(Interactor interactor)
      Description copied from interface: Interactor.Listener
      Do the interactor interact with Interactable (i.e. Interactable in its field of view cells)
      Specified by:
      viewInteractionOf in interface Interactor.Listener
      Parameters:
      interactor - (Interactor). Not null
    • setCell

      protected void setCell(int x, int y, AreaBehavior.Cell cell)
    • getCell

      protected AreaBehavior.Cell getCell(int x, int y)
    • getRGB

      protected int getRGB(int r, int c)
    • getHeight

      protected int getHeight()
    • getWidth

      protected int getWidth()
    • canLeave

      public boolean canLeave(Interactable entity, List<DiscreteCoordinates> coordinates)
      Description copied from interface: Interactable.Listener
      Indicate if the given Interactable entity can leave the cell at given coordinates
      Specified by:
      canLeave in interface Interactable.Listener
      Parameters:
      entity - (Interactable). Not null
      coordinates - (List of DiscreteCoordinates). Not null
      Returns:
      (boolean): true if the entity can leave all the given cell
    • canEnter

      public boolean canEnter(Interactable entity, List<DiscreteCoordinates> coordinates)
      Description copied from interface: Interactable.Listener
      Indicate if the given Interactable entity can enter the cell at given coordinates
      Specified by:
      canEnter in interface Interactable.Listener
      Parameters:
      entity - (Interactable). Not null
      coordinates - (List of DiscreteCoordinates). Not null
      Returns:
      (boolean): true if the entity can enter all the given cell
    • leave

      public void leave(Interactable entity, List<DiscreteCoordinates> coordinates)
      Description copied from interface: Interactable.Listener
      Do the given interactable entity leave the given cells
      Specified by:
      leave in interface Interactable.Listener
      Parameters:
      entity - (Interactable). Not null
      coordinates - (List of DiscreteCoordinates). Not null
    • enter

      public void enter(Interactable entity, List<DiscreteCoordinates> coordinates)
      Description copied from interface: Interactable.Listener
      Do the given interactable entity enter the given cells
      Specified by:
      enter in interface Interactable.Listener
      Parameters:
      entity - (Interactable). Not null
      coordinates - (List of DiscreteCoordinates). Not null