Class Area

java.lang.Object
ch.epfl.cs107.play.areagame.area.Area
All Implemented Interfaces:
Graphics, PauseMenu.Pausable, Playable, Updatable

public abstract class Area extends Object implements Playable, Graphics, PauseMenu.Pausable
Area is a "Part" of the AreaGame. An Area is made of a Behavior, and a List of Actors
  • Constructor Details

    • Area

      public Area()
  • Method Details

    • getCameraScaleFactor

      public abstract float getCameraScaleFactor()
      Returns:
      (float): camera scale factor, assume it is the same in x and y direction
    • setBehavior

      protected final void setBehavior(AreaBehavior ab)
      Setter for the Behavior of this Area Please call this method in the begin method of every subclass
      Parameters:
      ab - (AreaBehavior), not null
    • setViewCandidate

      public final void setViewCandidate(Actor a)
      Setter for the view Candidate
      Parameters:
      a - (Actor), not null
    • registerActor

      public final boolean registerActor(Actor a)
      Register an actor : will be added at next update
      Parameters:
      a - (Actor): the actor to register, not null
      Returns:
      (boolean): true if the actor is correctly registered
    • unregisterActor

      public final boolean unregisterActor(Actor a)
      Unregister an actor : will be removed at next update
      Parameters:
      a - (Actor): the actor to unregister, not null
      Returns:
      (boolean): true if the actor is correctly unregistered
    • exists

      public boolean exists(Actor a)
      Indicate if the given actor exists into the actor list
      Parameters:
      a - (Actor): the given actor, may be null
      Returns:
      (boolean): true if the given actor exists into actor list
    • getWidth

      public int getWidth()
      Getter for the area width
      Returns:
      (int) : the width in number of cols
    • getHeight

      public int getHeight()
      Getter for the area height
      Returns:
      (int) : the height in number of rows
    • getKeyboard

      public final Keyboard getKeyboard()
      Returns:
      the Window Keyboard for inputs
    • getMouse

      public final Mouse getMouse()
      Returns:
      the Window Mouse for inputs
    • getRelativeMousePosition

      public Vector getRelativeMousePosition()
      Returns:
      the mouse position relatively to the area and the cells
    • getRelativeMouseCoordinates

      public DiscreteCoordinates getRelativeMouseCoordinates()
      Returns:
      the mouse coordinates relatively to the area and the cells
    • isStarted

      public final boolean isStarted()
      Returns:
      (boolean): true if the method begin already called once. You can use resume() instead
    • leaveAreaCells

      public final boolean leaveAreaCells(Interactable entity, List<DiscreteCoordinates> coordinates)
      If possible make the given interactable entity leave the given area cells
      Parameters:
      entity - (Interactable), not null
      coordinates - (List of DiscreteCoordinates), may be empty but not null
      Returns:
      (boolean): True if possible to leave
    • enterAreaCells

      public final boolean enterAreaCells(Interactable entity, List<DiscreteCoordinates> coordinates)
      If possible make the given interactable entity enter the given area cells
      Parameters:
      entity - (Interactable), not null
      coordinates - (List of DiscreteCoordinates), may be empty but not null
      Returns:
      (boolean): True if possible to enter
    • canEnterAreaCells

      public final boolean canEnterAreaCells(Interactable entity, List<DiscreteCoordinates> coordinates)
      Inform if the entity can enter the area cells
      Parameters:
      entity - (Interactable), not null
      coordinates - (List of DiscreteCoordinates), may be empty but not null
      Returns:
      (boolean): True if possible to enter
    • canLeaveAreaCells

      public final boolean canLeaveAreaCells(Interactable entity, List<DiscreteCoordinates> coordinates)
      Inform if the entity can leave the area cells
      Parameters:
      entity - (Interactable), not null
      coordinates - (List of DiscreteCoordinates), may be empty but not null
      Returns:
      (boolean): True if possible to leave
    • begin

      public boolean begin(Window window, FileSystem fileSystem)
      Description copied from interface: Playable
      Initialises game state : display and controls Note: Need to be Override
      Specified by:
      begin in interface Playable
      Parameters:
      window - (Window): display context. Not null
      fileSystem - (FileSystem): given file system. Not null
      Returns:
      (boolean): whether the game was successfully started
    • resume

      public boolean resume(Window window, FileSystem fileSystem)
      Resume method: Can be overridden
      Parameters:
      window - (Window): display context, not null
      fileSystem - (FileSystem): given file system, not null
      Returns:
      (boolean) : if the resume succeed, true by default
    • update

      public void update(float deltaTime)
      Description copied from interface: Updatable
      Simulates a single time step. Note: Need to be Override
      Specified by:
      update in interface Updatable
      Parameters:
      deltaTime - elapsed time since last update, in seconds, non-negative
    • draw

      public void draw(Canvas canvas)
      Description copied from interface: Graphics
      Renders itself on specified canvas.
      Specified by:
      draw in interface Graphics
      Parameters:
      canvas - target, not null
    • purgeRegistration

      public final void purgeRegistration()
    • suspend

      public void suspend()
      Suspend method: Can be overridden, called before resume other
    • end

      public void end()
      Description copied from interface: Playable
      Cleans up things, called even if initialisation failed. Note: Need to be Override
      Specified by:
      end in interface Playable
    • requestAreaPause

      public final void requestAreaPause(AreaPauseMenu menu)
      Can be called by any possessor of this Area. Caller indicate it requests a pause with given menu displayed. Notice: this method chooses if the request ends up or not
      Parameters:
      menu - (AreaPauseMenu): The context menu to display. It (or any of its components) will be responsible of the ResumeRequest, not null
    • requestPause

      public final void requestPause()
      Specified by:
      requestPause in interface PauseMenu.Pausable
    • requestResume

      public final void requestResume()
      Can be called by anny possessor of this Area Caller indicates it requests a resume of the pause state to the game Notice: this method chooses if the request ends up or not
      Specified by:
      requestResume in interface PauseMenu.Pausable
    • isPaused

      public final boolean isPaused()
      Specified by:
      isPaused in interface PauseMenu.Pausable
    • isViewCentered

      public boolean isViewCentered()