Cutscenes Overview - UQcsse3200/2024-studio-3 GitHub Wiki

Cutscene UML Diagram

Debugging

Each Cutscene implementation can be jumped to manually through the terminal. Use the command:

cutscene + The name of the cutscene

And you will be taken to the specified cutscene implementation if it exists.

The possible cutscene commands are as follows:

cutscene Day2

for more information about the cutscene commands: here

Cutscene.java

The Cutscene component is an abstract class that serves as the foundation for implementing specific cutscenes in the game. It outlines common functionality such as loading assets, transitioning between scenes, managing the entities displayed during a scene, and triggering events when the cutscene ends. Each cutscene, such as the Day2Cutscene, will extend the Cutscene class and provide specific scene data, images, animations, and other custom logic.

Key Responsibilities:

  1. Scene Management: The Cutscene class maintains a list of scenes (List scenes) and manages the transition between these scenes. Each scene contains specific images, animations, and text to display during that scene. The class tracks the current scene using the currentSceneIndex and transitions to the next one when the current scene's duration ends.

  2. Entity Management: The entities list holds all the Entity objects (such as backgrounds, characters, and animations) that are displayed during a scene. The createEntitiesForScene() method is responsible for creating and adding entities to the scene. Once a scene ends, the disposeEntities() method is called to remove and clean up the entities before loading the next scene.

  3. Text Display: The cutsceneText array holds the text that is displayed during the cutscene. This text is updated as the cutscene progresses using the setTextForScene() method, which retrieves the current scene's text and updates the currentText variable.

  4. Asset Loading and Unloading: The loadAssetsForScene() and unloadAssets() methods handle loading and unloading of textures, animations, and other resources for each scene. This ensures that only the necessary assets are in memory during the cutscene.

  5. Scene Transitioning: The update() method checks if the current scene has finished based on its duration. If the scene's time has elapsed, it triggers a transition to the next scene by calling nextCutscene(). If there are no more scenes, it triggers the "cutsceneEnded" event, signaling that the cutscene is complete.

Abstract Methods:

Each subclass (such as Day2Cutscene) is required to implement the following methods:

  • setupScenes(): This method defines the specific scenes for the cutscene. It is responsible for adding scenes with their respective backgrounds, animations, images, and text.
  • loadAssets(): This method specifies which assets (textures, animations) need to be loaded for the entire cutscene.
  • createEntities(): This method is called at the start of the cutscene and is used to create any initial entities that are not tied to specific scenes but are needed for the cutscene as a whole.

Day2Cutscene

The Day2Cutscene class extends the Cutscene class and provides the specifics for a particular cutscene in the game.

Key Features of Day2Cutscene:

  1. Scene Setup: The setupScenes() method creates two scenes, each with its own set of images (e.g., the reporter, the player), text, and a background image. Each scene is also given a duration, which determines how long it will be displayed before transitioning to the next scene.

  2. Asset Loading: The loadAssets() method defines the textures and images that need to be loaded for the Day2Cutscene. These include the background and character images used in the scenes.

  3. Entity Creation: While no additional logic is added in createEntities(), this method provides a place for adding any entities that need to be present throughout the cutscene, outside of individual scenes.

Day3Cutscene

The Day3Cutscene class follows directly from the events of Day 2. The story takes a more intense turn, with a focus on the interaction between the player, the Mafia Boss, and the Health Inspector.

Key Features of Day3Cutscene:

The setupScenes() method creates two scenes:

  1. The first scene features the Mafia Boss warning the player about potential penalties if mistakes are made.
  2. The second scene introduces the Health Inspector, who sets the challenge for the player: five perfect meals with penalties for mistakes. Each scene has its own set of images (e.g., Mafia Boss, Health Inspector, player), text, and a background image. Each scene is given a duration to control how long it is displayed before transitioning to the next scene.

Day4Cutscene

The Day4Cutscene continues the narrative established in Days 2 and 3. The tension rises with the threat of a riot outside the restaurant, and the player must keep calm to handle the situation.

Key Features of Day4Cutscene:

The setupScenes() method creates a single, tense scene where the Mafia Boss warns the player about an impending riot. The player must stay calm while serving customers, or risk even bigger trouble. The scene uses the same Mafia Boss and player images from the previous days, with a new background.

Cutscene Workflow

Here’s a high-level summary of how a cutscene works:

  1. Cutscene Initialization: When a cutscene begins, the Cutscene class initializes the GameTime service, loads the necessary assets, and sets up the scenes.

  2. Scene Loading: Each scene is loaded in sequence, creating and registering the entities (backgrounds, animations, and images) that will be displayed. The currentScene variable is updated with the loaded scene, and the cutscene's text is updated accordingly.

  3. Scene Transition: As the cutscene progresses, the game checks the elapsed time for the current scene. Once the scene's duration has passed, the entities for that scene are disposed of, and the next scene is loaded. This continues until all scenes have been played.

  4. Cutscene End: When all scenes have been displayed, the cutscene triggers the "cutsceneEnded" event, signaling that the cutscene is complete and allowing the game to move on to the next stage (e.g., returning to gameplay or moving to the next cutscene).

Below is the sequence diagram for how a cutscene is loaded into the CutsceneGameArea. This is from the main menu. Similar approach applies from any point within the game Sequence Diagram for loaded in a cutscene

Sequence Overview:

  1. Player Starts the Cutscene:

    • The cutscene is initiated when the player selects an option or performs an action that triggers a cutscene. The player interacts with the MainMenuActions, and this triggers the startCutscene() method.
  2. Transition to Cutscene Screen:

    • Once the cutscene starts, the game transitions to the cutscene screen by calling GdxGame.setScreen(), which sets the screen to CutsceneScreen. This is the main screen where the cutscene will be displayed.
  3. Cutscene Screen Initialization:

    • Several components are created when the CutsceneScreen is initialized:
      • CutsceneArea: This component represents the physical area where the cutscene will take place.
      • CutsceneActions: Handles player interactions, such as pressing the spacebar to skip to the next scene.
      • CutsceneTextDisplay: Manages the text displayed during the cutscene (dialogue and narration).
      • CutsceneScreenDisplay: Manages the overall display of the cutscene and tracks its progress.
  4. Cutscene and Scene Creation:

    • The CutsceneArea initializes the Cutscene itself, which contains a series of scenes. Each scene is created by invoking the Scene.create() method.
    • For each scene, the cutscene loads its visual components using the CutsceneFactory. This includes:
      • Background: The main visual backdrop of the scene.
      • Images: Static images, such as characters or objects, which are loaded and positioned.
      • Animations: Animated elements that may move or change during the scene.
    • Once these visual elements are created, they are registered and loaded into the CutsceneArea, which ensures the correct entities are displayed on screen.
  5. Cutscene Loop (Scene Transitions):

    • While the cutscene is being displayed, the player can interact with the cutscene using input actions, such as pressing the spacebar.
    • When the player presses the spacebar, the CutsceneActions component triggers the nextScene() method in the Cutscene class. This transitions the cutscene to the next scene in the sequence, unloading the current scene’s entities and loading the next scene’s entities.
    • This loop continues for each scene until all scenes in the cutscene are displayed.
  6. Cutscene Completion:

    • Once all scenes are completed, the Cutscene class triggers the cutsceneEnded() event, notifying the CutsceneScreenDisplay that the cutscene is finished.
    • The CutsceneActions then informs the game (GdxGame.setScreen()) to transition away from the cutscene screen and back to the appropriate screen
⚠️ **GitHub.com Fallback** ⚠️