03. Demo Scene

  02. Installation No Comments

Inity comes with a demo scene containing a simple game built utilizing many of the features offered by Inity.

Installing Dependencies

Before installing the demo scene you must first install the Unity UI and Test Framework packages.

To install the packages perform the following steps:

  1. Open the Package Manager using the main menu item Window > Package Manager.
  2. Click the second dropdown menu on the top bar and select All packages.
  3. Find the Test Framework package in the list and select it.
  4. Click the Install button and wait until the package has finished installing.
  5. Next find the Unity UI package in the list and select it.
  6. Click the Install button and wait until this package has also finished installing.

If you do not care to see the unit tests for the demo project, you can also skip installing the Test Framework package, and then untick the folder Assets/Sisus/Inity/Demo/Tests during installation of the Demo package.

Installing The Demo

To install the demo project perform the following steps:

  1. locate the unity package at Assets/Sisus/Inity/Demo Installer in the Project view and double-click it.
  2. In the Import Unity Package dialog that opens select Import.

After installation has finished you can find the demo scene at Assets/Sisus/Inity/Demo/Demo Scene. To try out the demo open the Demo Scene and enter play mode.

Gameplay

You control the yellow cube using the arrow keys and your objective is to collect as many green dots as you can without hitting any of the red cubes.

Scene Overview

The demo scene contains six GameObjects in its hierarchy:

  1. Level: The Level component defines the bounds of the level inside which the player can move and enemies and collectables can spawn. The class is also a service to make it more convenient for other objects to retrieve a reference to it. Nested underneath the GameObject are also the visual elements that make up the level.
  2. Player: Contains the Player, Killable and Movable components. The Player component is responsible for detecting collisions with ICollectable object and the Killable component with IDeadly objects. The Movable component moves the GameObject within the bounds of the level in response to user input.
  3. Enemy Spawner: Contains the SpawnerInitializer which is used to specify the arguments for the SpawnerComponent. The SpawnerComponent is created at runtime, and is actually just a simple wrapper for the Spawner object which actually holds all the logic for spawning the enemies.
  4. Collectable Spawner: Just like Enemy Spawner except configured to spawn instances of the Collectable prefab instead of enemies.
  5. Reset Handler: Houses the ResetHandler component which is used to reset the game state when the player presses the ’R’ key.
  6. UI: Contains the Score and Game Over texts. The Score texts has been hooked to update when the Collectable.Collected UnityEvent is invoked and the Game Over text has been hooked to become active when the Player.Killed UnityEvent is invoked.

All classes in the demo have XML documentation comments, and the best way to learn more about the demo project is to go examine its source code.

The demo also contains a number of unit tests to showcase how Inity can help make your code more easily unit testable. The tests contain some interesting patterns such as testing of coroutines in edit mode and suppression of logging for the duration of the tests.

Leave a Reply

Your email address will not be published. Required fields are marked *