MechaHamster
An open source project by FPL.
 All Pages
High-Level Overview

MechaHamster has a number of parts and components. This document is intended to make it easier to find the pieces you're looking for!

Downloading Source Code

Source code for MechaHamster is available for download from Github.

If cloning locally using git clone, be sure to use the --recurse-submodules flag to ensure required scripts from submodules are present.

Directory Layout

The bulk of the project exists in the /Assets/Hamster directory. Some other useful paths to know about for the project include:

Path
/Assets/GoogleVRContains prefabs and code from the Google VR SDK for Unity, for running in VR mode on Daydream.
/Assets/Firebase Generated by the Firebase packages, when they are imported.
/Assets/Hamster/Scripts The gameplay code and logic for MechaHAmster.

Code Organization

Entry Point

The main entry point for the game is the MainGame class, which is a MonoBehaviour attached to a top-level GameObject on the scene. It is responsible for setting the objects that run the game, and setting everything in motion.

Game States

MechaHamster uses a state machine to control the program flow between menus, gameplay, transitions, and more. States are managed by a top-level StateManager class, which is located in Assets/Hamster/Scripts/States/StateManager.cs

The BaseState class is in Assets/Hamster/Scripts/States/BaseState.cs. All states derive from this class, and are managed by the StateManager class. The game has exactly one StateManager, created at startup and used throughout the game's execution.

Maps

Each "level" of MechaHamster takes place on a new map. A map is a simple tile-grid, containing a number of GameObjects that represent various level features, such as floors, walls, springs, pits, etc.

The representation for Maps is actually split across two separate classes:

  • LevelMap is the pure data representation of a level. It is purely data, and can be easily serialized, sent over the network, or passed around between objects.
  • GameWorld represents the Unity GameObjects that are represent the world, and is responsible for tracking and managing them. Specifically, GameWorld can accept a LevelMap as input, and spawn the GameObjects to represent it.

MapTiles

Each tile on the map is represented by a GameObject with an attached MonoBehaviour, which derives from MapObject, and controls the specific game logic of that tile. For example, the JumpTile class listens for collision events indicating that the ball has rolled over it, and then plays an animation and launches the ball into the air.

All of the various map tiles and their associated classes can be found in the /Assets/Hamster/Scripts/MapObjects directory.

Google Play Games Services (Experimental)

MechaHamster supports signing in using Google Play Games Services (GPGS) (Android-only). The codebase illustrates using GPGS to introduce achievements.

In order to build MechaHampster with GPGS support, please follow these steps (requires Unity 2017.2 or higher):

  1. Follow the instructions at Authenticate in Unity Using Google Play Games Services
  2. In the Player settings, add the GPGS preprocessor symbol to "Scripting Define Symbols"
  3. In the Google Play console, ensure the achievements match the ones already defined in the game (see Assets/GPGSIds.cs)