Package rekit.logic
Interface IScene
- All Known Subinterfaces:
ILevelScene
- All Known Implementing Classes:
LevelScene
public interface IScene
This is the public interface of all Scenes.
- Author:
- Dominik Fuchss
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a GameElement to the Model.void
Adds a GuiElement to the GameModel.void
applyToGameElements
(Consumer<GameElement> function) Apply function on all game elements.void
applyToGuiElements
(Consumer<GuiElement> function) Apply function on game elements.void
applyToNonNeutralGameElements
(Consumer<GameElement> function) Apply function on game elements (non-neutral).default void
attack
(boolean active) Will invoked if user wants to attack something.float
Get the current camera offset.int
Get the amount of elements in the scene.Get a map of duration-time of elements.getMenu()
Get the associated Root-MenuItem.getModel()
Get the model of the MVC.void
init()
Initialize the scene.default boolean
This method indicates whether the scene encapsulates a level.boolean
isPaused()
Indicates whether the scene is paused.void
Invoke logic.void
Removes a GameElement from the Model The elements will not directly be removed from the internal data structure to prevent concurrency errors.void
Removes a GuiElement to the GameModel.default void
restart()
Restart the scene.default void
setAttackHandler
(Consumer<Boolean> handler) The handler ofattack(boolean)
.void
setCameraTarget
(CameraTarget cameraTarget) Set the camera target.void
setCanPause
(boolean canPause) Set whether the game can pausedvoid
setPause
(boolean pause) Set the pause state.default void
start()
Start the scene.boolean
Toggle pause for the scene.
-
Method Details
-
addGameElement
Adds a GameElement to the Model. The elements will not directly be added to the internal data structure to prevent concurrency errors. Instead there is an internal list to hold all waiting GameElements that will be added in the next call of logicLoop- Parameters:
e
- the GameElement to add
-
markForRemove
Removes a GameElement from the Model The elements will not directly be removed from the internal data structure to prevent concurrency errors. Instead there is an internal list to hold all waiting GameElements that will be removed in the next call of logicLoop- Parameters:
e
- the GameElement to remove
-
addGuiElement
Adds a GuiElement to the GameModel.- Parameters:
e
- the GuiElement to add
-
removeGuiElement
Removes a GuiElement to the GameModel.- Parameters:
e
- the GuiElement to remove
-
setCameraTarget
Set the camera target.- Parameters:
cameraTarget
- the camera target
-
getCameraOffset
float getCameraOffset()Get the current camera offset.- Returns:
- the current camera offset
-
applyToNonNeutralGameElements
Apply function on game elements (non-neutral).- Parameters:
function
- the function- See Also:
-
applyToGameElements
Apply function on all game elements.- Parameters:
function
- the function
-
applyToGuiElements
Apply function on game elements.- Parameters:
function
- the function
-
getModel
Model getModel()Get the model of the MVC.- Returns:
- the model
-
logicLoop
void logicLoop()Invoke logic. -
init
void init()Initialize the scene. e.g. build Level/GUI so Scene is ready to be drawn Must be called on restart. -
start
default void start()Start the scene. Begin drawing and Player/Enemies will begin to move. -
restart
default void restart()Restart the scene. -
getGameElementDurations
Get a map of duration-time of elements.- Returns:
- the duration-time of elements by class
-
getGameElementCount
int getGameElementCount()Get the amount of elements in the scene.- Returns:
- the amount of elements
-
getMenu
MenuItem getMenu()Get the associated Root-MenuItem.- Returns:
- the root-menuItem or
null
if noScenes.MAIN_MENU
-
togglePause
boolean togglePause()Toggle pause for the scene. SeesetPause(boolean)
.- Returns:
true
iff operation is possible,false
otherwise
-
setCanPause
void setCanPause(boolean canPause) Set whether the game can paused- Parameters:
canPause
-true
iff pausable
-
isPaused
boolean isPaused()Indicates whether the scene is paused.- Returns:
true
if paused,false
otherwise
-
setPause
void setPause(boolean pause) Set the pause state. When pause usually the logic loop Useful when resetting.- Parameters:
pause
- the new pause state
-
isLevelScene
default boolean isLevelScene()This method indicates whether the scene encapsulates a level.- Returns:
true
if this scene encapsulates a level,false
otherwise
-
attack
default void attack(boolean active) Will invoked if user wants to attack something.- Parameters:
active
- indicates whether attack is active or not (this means that the Attack-Key is pressed or not)- See Also:
-
setAttackHandler
The handler ofattack(boolean)
.- Parameters:
handler
- the handler ornull
to reset- See Also:
-