Skip to main content

GameManager

Overview

The GameManager class is the core management component of Relic Run, responsible for game state management, event handling, player creation, and debugging features. The class utilizes a singleton pattern to ensure a single global point of control.


Properties and Fields

Singleton and Events

  • Instance: Singleton instance of GameManager.
  • OnRestartGame, OnEndGame, OnGlobalPlayerWeaponDamageModChange: Events for restarting and ending the game, and weapon damage modification.

Game State

  • globalPlayerWeaponDamageMod: Player weapon damage modifier.
  • EntityMoveSpeed: Movement speed for entities.
  • Player, Score, Level: Core game state fields.

Debugging

  • charactersList, WeaponsPlayerAddedDuringSession, damageNumberPrefabs, weaponObjectPoolTransform: Debugging fields for in-game entities.

Configuration

  • cassieStartingWeapon, dialogue, cameraController: Game setting fields.

Developer Tools

  • EnableDevKeys, devKey*: Developer tools for debugging.

Hidden

  • metaProgressionData: Metadata for game progression, not for direct manipulation.

Methods

Lifecycle Methods

  • Awake(): Singleton instantiation and meta progression data loading.
  • Start(): Initializes game state and UI.
  • Update(): Handles developer key inputs.

Core Game Logic

  • AwakeGame(): Initializes game state.
  • RestartGame(): Restarts game state.
  • EndGame(): Finalizes game state.

Player Management

  • CreatePlayer(): Creates a new player and initializes its state.
  • GetStartingCharacterWeapon(): Assigns starting weapon to a new player.

Utility Functions

  • GetDamageNumberPrefab(): Retrieves damage number prefab based on an index.

Audit and Refactor Guidelines for v0.6.0

  • Revisit Singleton Instance for best practices.
  • Consider design patterns for state management (AwakeGame, RestartGame).
  • Refactor CreatePlayer for easier extension with new characters.
  • Modularize developer key handling from Update() method.
  • Enhance error handling and validation in methods like CreatePlayer.