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

public abstract class Cutscene extends Component
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 Details

    • scenes

      protected List<Scene> scenes
    • animatedScenes

      protected List<AnimatedScene> animatedScenes
    • entities

      protected List<Entity> entities
    • cutsceneText

      protected com.badlogic.gdx.utils.Array<String> cutsceneText
    • currentSceneIndex

      protected int currentSceneIndex
    • timeStart

      protected float timeStart
    • currentScene

      public Scene currentScene
    • currentText

      public String currentText
    • currentAnimatedScene

      protected AnimatedScene currentAnimatedScene
    • animName

      protected String animName
    • isAnimatedScenes

      public boolean isAnimatedScenes
    • gameTime

      protected GameTime gameTime
    • textures

      protected String[] textures
    • animations

      protected String[] animations
    • images

      protected String[] 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.
      Overrides:
      create in class Component
    • update

      public void update()
      Updates the cutscene, transitioning to the next scene if the current scene's duration has passed.
      Overrides:
      update in class Component
    • 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

      protected void loadAssetsForScene(Scene scene)
      Loads the assets needed for a specific scene, including textures and animations.
      Parameters:
      scene - The scene for which to load assets
    • loadAssetsForScene

      protected void loadAssetsForScene(AnimatedScene scene)
      Loads the assets needed for a specific scene, including textures and animations.
      Parameters:
      scene - The scene for which to load assets
    • createEntitiesForScene

      protected void createEntitiesForScene(Scene scene)
      Creates entities for the given scene, such as background and animation entities.
      Parameters:
      scene - The scene for which to create entities
    • setTextForScene

      public void setTextForScene(Scene scene)
    • setTextForSceneMoral

      public void setTextForSceneMoral(Scene scene)
    • isAtEnd

      public Boolean isAtEnd()
    • createEntitiesForScene

      protected void createEntitiesForScene(AnimatedScene scene)
      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.
      Overrides:
      dispose in class Component
    • 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

      public List<Scene> getScenes()
      Gets the scenes
      Returns:
      the scenes being held
    • setScenes

      public void setScenes(List<Scene> scenes)
      Sets the scenes to a given scene
      Parameters:
      scenes - : the scenes to be set to.
    • getTextures

      public String[] getTextures()
      Gets the textures
      Returns:
      the textures being held
    • setTextures

      public void setTextures(String[] textures)
      Sets the textures for the cutscene
      Parameters:
      textures - : the textures being held
    • getImages

      public String[] getImages()
      Get the images being held by the cutscene
      Returns:
      the images being held by the cutscene
    • setImages

      public void setImages(String[] images)
      Sets the images being held by the cutscene
      Parameters:
      images - : the new images to be set
    • getAnimations

      public String[] getAnimations()
      Gets the animations for the cutscene
      Returns:
      the animations for the cutscenes
    • setAnimations

      public void setAnimations(String[] animations)
      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.