Class Cutscene
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.cutscenes.Cutscene
- Direct Known Subclasses:
BackstoryCutscene
,BadEndCutscene
,Day2Cutscene
,Day3Cutscene
,Day4Cutscene
,GoodEndCutscene
,IntroCutscene
,LoseCutscene
,MoralDay1Cutscene
,MoralDay2Cutscene
,MoralDay3Cutscene
,MoralDay4Cutscene
Represents a cutscene in the game. A cutscene consists of multiple scenes,
and this class manages scene transitions, asset loading/unloading, and entity management for the cutscene.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List
<AnimatedScene> protected String[]
protected String
protected AnimatedScene
protected int
protected com.badlogic.gdx.utils.Array
<String> protected GameTime
protected String[]
boolean
protected int
protected String[]
protected float
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Creates the cutscene by setting up event listeners and loading the first scene.abstract void
Abstract method to create entities for the cutscene.protected void
Creates entities for the given scene, such as background and animation entities.protected void
createEntitiesForScene
(Scene scene) Creates entities for the given scene, such as background and animation entities.void
dispose()
Disposes of the cutscene by unloading assets and disposing of entities.protected void
Disposes of all entities in the current scene.String[]
Gets the animations for the cutsceneint
Gets the current scene index.String[]
Get the images being held by the cutsceneGets the scenesString[]
Gets the texturesfloat
Gets the start time for the animationsisAtEnd()
boolean
Checks if the cutscene has been completed.protected abstract void
Abstract method to load the assets required for the cutscene.protected void
loadAssetsForScene
(AnimatedScene scene) Loads the assets needed for a specific scene, including textures and animations.protected void
loadAssetsForScene
(Scene scene) Loads the assets needed for a specific scene, including textures and animations.protected void
loadScene
(int sceneIndex) Loads a scene by its index, initializing entities and assets for that scene.protected void
Transitions to the next scene in the cutscene.protected void
void
setAnimations
(String[] animations) Sets the animations for the cutscenesvoid
setCurrentScene
(int newSceneIndex) Sets the current scene index and transitions to the specified scene.void
Sets the images being held by the cutscenevoid
Sets the scenes to a given scenevoid
setTextForScene
(Scene scene) void
setTextForSceneMoral
(Scene scene) void
setTextures
(String[] textures) Sets the textures for the cutscenevoid
setTimeStart
(float timeStart) Sets the start timeprotected abstract void
Abstract method to set up scenes for the cutscene.void
start()
Starts the cutscene by creating the necessary entities.protected void
Unloads the assets used in the cutscene.void
update()
Updates the cutscene, transitioning to the next scene if the current scene's duration has passed.Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Field Details
-
scenes
-
animatedScenes
-
entities
-
cutsceneText
-
currentSceneIndex
protected int currentSceneIndex -
timeStart
protected float timeStart -
currentScene
-
currentText
-
currentAnimatedScene
-
animName
-
isAnimatedScenes
public boolean isAnimatedScenes -
gameTime
-
textures
-
animations
-
images
-
textIndex
protected int textIndex
-
-
Constructor Details
-
Cutscene
protected Cutscene()Constructor for the Cutscene class. Initializes the game time and loads assets and scenes.
-
-
Method Details
-
create
public void create()Creates the cutscene by setting up event listeners and loading the first scene. -
update
public void update()Updates the cutscene, transitioning to the next scene if the current scene's duration has passed. -
nextCutscene
protected void nextCutscene()Transitions to the next scene in the cutscene. If there are no more scenes, it triggers the "cutsceneEnded" event. -
nextCutsceneMoral
protected void nextCutsceneMoral() -
loadScene
protected void loadScene(int sceneIndex) Loads a scene by its index, initializing entities and assets for that scene.- Parameters:
sceneIndex
- Index of the scene to load
-
loadAssetsForScene
Loads the assets needed for a specific scene, including textures and animations.- Parameters:
scene
- The scene for which to load assets
-
loadAssetsForScene
Loads the assets needed for a specific scene, including textures and animations.- Parameters:
scene
- The scene for which to load assets
-
createEntitiesForScene
Creates entities for the given scene, such as background and animation entities.- Parameters:
scene
- The scene for which to create entities
-
setTextForScene
-
setTextForSceneMoral
-
isAtEnd
-
createEntitiesForScene
Creates entities for the given scene, such as background and animation entities.- Parameters:
scene
- The scene for which to create entities
-
disposeEntities
protected void disposeEntities()Disposes of all entities in the current scene. -
setupScenes
protected abstract void setupScenes()Abstract method to set up scenes for the cutscene. This should be implemented by subclasses. -
loadAssets
protected abstract void loadAssets()Abstract method to load the assets required for the cutscene. This should be implemented by subclasses. -
start
public void start()Starts the cutscene by creating the necessary entities. -
dispose
public void dispose()Disposes of the cutscene by unloading assets and disposing of entities. -
unloadAssets
protected void unloadAssets()Unloads the assets used in the cutscene. -
isCompleted
public boolean isCompleted()Checks if the cutscene has been completed. Currently not implemented.- Returns:
- boolean indicating if the cutscene is completed
-
createEntities
public abstract void createEntities()Abstract method to create entities for the cutscene. This should be implemented by subclasses. -
getTimeStart
public float getTimeStart()Gets the start time for the animations- Returns:
- the start time as a float.
-
setTimeStart
public void setTimeStart(float timeStart) Sets the start time- Parameters:
timeStart
- : the time to be set
-
getScenes
Gets the scenes- Returns:
- the scenes being held
-
setScenes
Sets the scenes to a given scene- Parameters:
scenes
- : the scenes to be set to.
-
getTextures
Gets the textures- Returns:
- the textures being held
-
setTextures
Sets the textures for the cutscene- Parameters:
textures
- : the textures being held
-
getImages
Get the images being held by the cutscene- Returns:
- the images being held by the cutscene
-
setImages
Sets the images being held by the cutscene- Parameters:
images
- : the new images to be set
-
getAnimations
Gets the animations for the cutscene- Returns:
- the animations for the cutscenes
-
setAnimations
Sets the animations for the cutscenes- Parameters:
animations
- : the animations being set
-
getCurrentSceneIndex
public int getCurrentSceneIndex()Gets the current scene index. This method returns the index of the scene that is currently being displayed in the cutscene. The index corresponds to the position of the scene in the list of scenes.- Returns:
- the index of the current scene.
-
setCurrentScene
public void setCurrentScene(int newSceneIndex) Sets the current scene index and transitions to the specified scene. This method allows for manually setting the current scene index, which transitions the cutscene to the scene corresponding to the provided index. It first validates the scene index to ensure it's within the valid range. If the index is valid, it disposes of the entities in the current scene, updates the scene index, and loads the new scene.- Parameters:
newSceneIndex
- the index of the scene to switch to. Must be a valid index within the list of scenes.- Throws:
IllegalArgumentException
- if the provided index is outside the range of available scenes.
-