Skip to content

Unity Project Architecture

Kevin Prehn edited this page Aug 2, 2018 · 4 revisions

The game is built for Unity 5.6.0 as a 2D project. The code can be broken up into several different categories:

  • Gameplay
  • User Interface
  • World generation
  • Logging

Below is a diagram with an overview of the game loop.

unity game loop diagram

Gameplay

Most of the logic which handles user input happens inside of the GameController's Update() method.

TODO

Game Entity Components

All scripts under GameObject/Components are meant to be reusable scripts for any Virtual Maniupulatives/Game entities which are added into the game.

  • LinkBehavior is for object which can connect to ConnectableEntityBehavior objects.
  • ConnectableEntityBehavior is for any object which a LinkBehavior object can connect to.
  • ValueBehavior is for any object which can have a value attached to it
  • LoggableBehavior is for any object that has a LogID to be printed in log messages
  • ContainerEntityBehavior is for any object which might contain other components. it can be hidden or revealed.

Note that adding these components to new game objects may not make it behave exactly as you want it to. You might still need to create a new behavior script for any new element that you add in to facilitate the behavior of these different components. For an example of this, see the PlatformBehavior script, which is has a ConnectableEntityBehavior, ContainerEntityBehavior, LoggableBehavior, and contains a LinkBehavior object and a ValueBehavior object.

New pull requests can also add any components which may give reusable behavior for any Virtual Manipulatives for data structures.

User Interface

All of the scripts used by the UI/HUD is found under the Scripts/UI folder. HUDBehavior is the main class for all game-related UI elements. The LoginPanelBehavior is used for the HUD which players first see for logging in.

TODO

World Generation

All world generation happens inside of the WorldGenerationBehavior script. The script has an array of JSON level files as TextAsset assets. Each JSON file corresponds to one level, and the order of the array is the order of the levels in the game. The levelFileIndex variable gives the index of the current level that is generated when the game either starts of when the level is reset. When the player completes a level, it increments the levelFileIndex variable and resets the level.

The generator uses JsonUtility to deserialize the JSON level files. All classes found in the Scripts/WorldGeneration folder are plain C# classes that are used by the JsonUtility.

Logging

TODO

Clone this wiki locally