Skip to content

Cutscene Implementation

Jonoym edited this page Sep 13, 2021 · 4 revisions

Cutscene Implementation

Text Box Design

The Text Box is stored in the game as a UI component that is retrievable with the use of ServiceLocators, Entities, UI. A global access of the Text Box has been decided since the text box can be triggered in many locations - game start, enemy kill, map positions, etc. There is also a single text box UI component which will be constantly changed instead of instantiating a new one when it needs to be displayed.

Game Areas

Depending on the game area, a text box will appear on game start to introduce the location, enemies and storyline. The opening of the text box will be triggered by the method setRandomFirstEncounter(RandomDialogueSet) when the game spawns all of the entities that populate the map. This method call will open the text box to be displayed as well as change it to the correct set of messages.

RandomDialogueSet is an enum containing sets of messages that relate to specific NPCs within the game. For more: RandomDialogueSet

Entity Triggers

The triggers that involve cutscenes will be spawned at specific locations in the GameArea as well. These triggers are all within the CutsceneTriggerFactory class and can control the player to walk, attack and open cutscenes. Each trigger is an entity that takes the components from TouchComponent and multiple components can be added to one entity. The types of triggers will depend on the NPC the trigger will take the form of, and the type of movement or action required.

To find out more about CutsceneTriggerFactory: Cutscene Trigger Factory

Implementing

To add a cutscene trigger to the game, it needs to be done in the GameArea of the desired map. Each entity will need to be placed at specific positions in the map and this will usually require some testing for the X and Y positions.

The types of cutscenes and their method calls are shown below:

createDialogueTrigger()

To create the dialogue trigger, the entity will require the parameters:

  • RandomDialogueSet: randomDialogueSet: a set of dialogue chosen from RandomDialogueSet enum
  • DialogueSet: dialogueSet: the type of selection chosen from DialogueSet

This entity will cause the text box to open when the player has collided with the entity.

createLokiTrigger()

To create the dialogue trigger in the form of a Loki NPC, the entity will require the parameters:

  • RandomDialogueSet: randomDialogueSet: a set of dialogue chosen from RandomDialogueSet enum
  • DialogueSet: dialogueSet: the type of selection chosen from DialogueSet

This entity will cause the text box to open when the player has collided with the entity.

createAttackTrigger()

To create the dialogue trigger, the entity will require the parameters:

  • int: repeats: the number of attacks the player will perform
  • int: lastKeyPressed: the direction in the form of a letter (W, A, S, D) of the attack

This entity will cause the player to attack a repeated amount of times in the direction specified.

createMoveTrigger()

To create the dialogue trigger, the entity will require the parameters:

  • Vector2: direction: the number of attacks the player will perform
  • int: x: the maximum direction the player will walk in the x direction
  • int: y: the minimum direction the player will walk in the y direction

This entity will cause the player to move in the direction specified when the player has collided with the entity.

Example Implementation

Here is an example entity spawn of a Dialogue Trigger in the form of a Prisoner and a Dialogue Trigger in the form of Loki.

Each of the Dialogue Triggers require the set RandomDialogueSet.TUTORIAL and RandomDialogueSet.LOKI_OPENING. The types of dialogue selection is also passed in as DialogueSet.ORDERED and DialogueSet.BOSS_DEFEATED_BEFORE.

        Entity trigger = CutsceneTriggerFactory.createDialogueTrigger(RandomDialogueSet.TUTORIAL,
                DialogueSet.ORDERED);
        spawnEntityAt(trigger, TEST_TRIGGER, true, true);

        Entity trigger3 = CutsceneTriggerFactory.createLokiTrigger(RandomDialogueSet.LOKI_OPENING,
                DialogueSet.BOSS_DEFEATED_BEFORE);
        spawnEntityAt(trigger3, new Vector2(7f, 9.5f), true, true);

Table of Contents

Home

Design Document

Design Document

Design Document

Game Engine

Getting Started

Entities and Components

Item Drops from Entities

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Map Generation

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally