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 TypeMethodDescriptionvoidAdds a GameElement to the Model.voidAdds a GuiElement to the GameModel.voidapplyToGameElements(Consumer<GameElement> function) Apply function on all game elements.voidapplyToGuiElements(Consumer<GuiElement> function) Apply function on game elements.voidapplyToNonNeutralGameElements(Consumer<GameElement> function) Apply function on game elements (non-neutral).default voidattack(boolean active) Will invoked if user wants to attack something.floatGet the current camera offset.intGet 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.voidinit()Initialize the scene.default booleanThis method indicates whether the scene encapsulates a level.booleanisPaused()Indicates whether the scene is paused.voidInvoke logic.voidRemoves a GameElement from the Model The elements will not directly be removed from the internal data structure to prevent concurrency errors.voidRemoves a GuiElement to the GameModel.default voidrestart()Restart the scene.default voidsetAttackHandler(Consumer<Boolean> handler) The handler ofattack(boolean).voidsetCameraTarget(CameraTarget cameraTarget) Set the camera target.voidsetCanPause(boolean canPause) Set whether the game can pausedvoidsetPause(boolean pause) Set the pause state.default voidstart()Start the scene.booleanToggle 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
nullif noScenes.MAIN_MENU
-
togglePause
boolean togglePause()Toggle pause for the scene. SeesetPause(boolean).- Returns:
trueiff operation is possible,falseotherwise
-
setCanPause
void setCanPause(boolean canPause) Set whether the game can paused- Parameters:
canPause-trueiff pausable
-
isPaused
boolean isPaused()Indicates whether the scene is paused.- Returns:
trueif paused,falseotherwise
-
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:
trueif this scene encapsulates a level,falseotherwise
-
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 ornullto reset- See Also:
-