Skip to content

Game: Temporary page

Tiffany Chong edited this page Jul 23, 2020 · 23 revisions

Global Variables at SourceAcademyGame

The game has two global singletons - SourceAcademyGame and GameGlobalAPI

SourceAcademyGame

SourceAcademyGame is a Phaser.Game instance, meaning it is persistent across different Phaser.Scenes. This is good for storing things we want to persist across scenes - such as sounds and user data.

The following are some key global managers and what they do.

Manager Description
Sound Manager Manager global volume, in charge of switching background music and playing sound effects
Save Manager Keeps track of taking game snapshots and contacting the server to send them over
User State Manager Keeps track of collectibles, achievements, assessments completed by the user

The following are some global variables and what they do.

Variable Description
accountInfo User account info such as his refresh and bearer tokens
setStorySimState A setter for the state of Story Simulator, so that the game engine can have control over React variables
awardsMapping A Map that provides information on how to render each award
currentSceneRef A reference to the current Phaser.Scene, so that we could perform scene related functionalities
gameType Whether we are using Story Simulator or actual game
gameChapters Details of each chapter, its title, background image, and corresponding .txts
ssChapterSimFilenames List of checkpoint files that you want to simulate in Chapter Simulator
isUsingMock When testing out engine, use this to use mock .txts or actual .txts that are specified by Story writers

GameGlobalAPI

Is only usable when the scene is GameManager scene.

It contains all API's of gameManager's managers. Somewhat similar to Service Locator pattern where we use a global object to supply us with services we need.

Clone this wiki locally