Package ch.epfl.cs107.play.areagame.area
Class Area
java.lang.Object
ch.epfl.cs107.play.areagame.area.Area
- All Implemented Interfaces:
Graphics,PauseMenu.Pausable,Playable,Updatable
Area is a "Part" of the AreaGame. An Area is made of a Behavior, and a List of Actors
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbegin(Window window, FileSystem fileSystem) Initialises game state : display and controls Note: Need to be Overridefinal booleancanEnterAreaCells(Interactable entity, List<DiscreteCoordinates> coordinates) Inform if the entity can enter the area cellsfinal booleancanLeaveAreaCells(Interactable entity, List<DiscreteCoordinates> coordinates) Inform if the entity can leave the area cellsvoidRenders itself on specified canvas.voidend()Cleans up things, called even if initialisation failed.final booleanenterAreaCells(Interactable entity, List<DiscreteCoordinates> coordinates) If possible make the given interactable entity enter the given area cellsbooleanIndicate if the given actor exists into the actor listabstract floatintGetter for the area heightfinal Keyboardfinal MousegetMouse()intgetWidth()Getter for the area widthfinal booleanisPaused()final booleanbooleanfinal booleanleaveAreaCells(Interactable entity, List<DiscreteCoordinates> coordinates) If possible make the given interactable entity leave the given area cellsfinal voidfinal booleanRegister an actor : will be added at next updatefinal voidCan be called by any possessor of this Area.final voidfinal voidCan 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 notbooleanresume(Window window, FileSystem fileSystem) Resume method: Can be overriddenprotected final voidSetter for the Behavior of this Area Please call this method in the begin method of every subclassfinal voidSetter for the view Candidatevoidsuspend()Suspend method: Can be overridden, called before resume otherfinal booleanUnregister an actor : will be removed at next updatevoidupdate(float deltaTime) Simulates a single time step.
-
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
Setter for the Behavior of this Area Please call this method in the begin method of every subclass- Parameters:
ab- (AreaBehavior), not null
-
setViewCandidate
Setter for the view Candidate- Parameters:
a- (Actor), not null
-
registerActor
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
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
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
- Returns:
- the Window Keyboard for inputs
-
getMouse
- Returns:
- the Window Mouse for inputs
-
getRelativeMousePosition
- Returns:
- the mouse position relatively to the area and the cells
-
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
If possible make the given interactable entity leave the given area cells- Parameters:
entity- (Interactable), not nullcoordinates- (List of DiscreteCoordinates), may be empty but not null- Returns:
- (boolean): True if possible to leave
-
enterAreaCells
If possible make the given interactable entity enter the given area cells- Parameters:
entity- (Interactable), not nullcoordinates- (List of DiscreteCoordinates), may be empty but not null- Returns:
- (boolean): True if possible to enter
-
canEnterAreaCells
Inform if the entity can enter the area cells- Parameters:
entity- (Interactable), not nullcoordinates- (List of DiscreteCoordinates), may be empty but not null- Returns:
- (boolean): True if possible to enter
-
canLeaveAreaCells
Inform if the entity can leave the area cells- Parameters:
entity- (Interactable), not nullcoordinates- (List of DiscreteCoordinates), may be empty but not null- Returns:
- (boolean): True if possible to leave
-
begin
Description copied from interface:PlayableInitialises game state : display and controls Note: Need to be Override -
resume
Resume method: Can be overridden- Parameters:
window- (Window): display context, not nullfileSystem- (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:UpdatableSimulates a single time step. Note: Need to be Override -
draw
Description copied from interface:GraphicsRenders itself on specified canvas. -
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:PlayableCleans up things, called even if initialisation failed. Note: Need to be Override -
requestAreaPause
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:
requestPausein interfacePauseMenu.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:
requestResumein interfacePauseMenu.Pausable
-
isPaused
public final boolean isPaused()- Specified by:
isPausedin interfacePauseMenu.Pausable
-
isViewCentered
public boolean isViewCentered()
-