|
MechaHamster
An open source project by
FPL.
|
MechaHamster has a number of parts and components. This document is intended to make it easier to find the pieces you're looking for!
Source code for MechaHamster is available for download from Github.
If cloning locally using
git clone, be sure to use the--recurse-submodulesflag to ensure required scripts from submodules are present.
The bulk of the project exists in the /Assets/Hamster directory. Some other useful paths to know about for the project include:
| Path | |
|---|---|
/Assets/GoogleVR | Contains 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. |
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.
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.
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.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.
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):