Project Arrhythmia
A video game developed by Vitamin Games.
Loading...
Searching...
No Matches
GameManager Class Reference

This class manages the main gameplay loop. More...

+ Inheritance diagram for GameManager:

Classes

class  LoadingState
 

Public Types

enum  GameState { Loading , Playing , Reversing , Paused }
 

Public Member Functions

delegate void RestartDelegate ()
 
delegate void RewindDelegate ()
 
delegate void FinishDelegate ()
 
delegate void StartDelegate ()
 
void SetupHighContrastTheme ()
 
void InvokeLevelRewindEvent ()
 
VGLevel FetchLevel ()
 
IEnumerator LoadGame (VGLevel _level)
 This coroutine is responsible for loading a game level. It takes a VGLevel object representing the level to be loaded. The function performs several operations such as loading metadata, audio, data, backgrounds, objects, and tweens related to the level. After all the loading operations are done, it starts the game.
 
void ResetCheckpoints (bool baseOnTime=false)
 This function resets the checkpoints for the current level.
 
void InitCheckpoints (float _songLength)
 This function initializes the checkpoints for the current level.
 
void SetUIVolumeWeightMin (float _time=0.25f)
 
void SetUIVolumeWeight (float _weight, float _time=0.25f)
 
void SyncAllObjects ()
 This function synchronizes all game objects with the current song time.
 
void SpawnPlayers (Vector3 _pos)
 This function is responsible for spawning player objects in the game.
 
int GetPlayerHealthPoints ()
 
Action< int, Vector3 > GetPlayerHitAction ()
 
Action< Vector3 > GetCloseCallAction ()
 
Action< Vector3 > GetPlayerDeathAction ()
 
void RewindToCheckpoint (int _indexForce=-1, bool _instant=false)
 This function is responsible for rewinding the game to a specific checkpoint.
 
void ClearPlayerEvents ()
 
void CallRestartLevel ()
 
IEnumerator ReverseToCheckpointLoop (int _indexForce=-1, bool _instant=false)
 Use to reverse the song's time back to last checkpoint.
 
void DoReverse (float _attack, float _hold, float _release)
 
DataManager.GameData.BeatmapData.Checkpoint GetClosestIndex (List< DataManager.GameData.BeatmapData.Checkpoint > _checkpoints, float _value)
 
void SyncSequenceLoop ()
 This function is responsible for synchronizing a sequence loop with the current song time.
 
void Update ()
 
void LevelCleanUp ()
 
void Pause (bool _showUI=true)
 
void UnPause ()
 
void CheckpointCheck ()
 Checks if a checkpoint has been reached and triggers the checkpoint animation.
 
IEnumerator PlayCheckpointAnimation (int _index=0)
 
void UpdateTimeline ()
 
void UpdateEvents ()
 
void SetupTheme ()
 
void SetupTimelineImages ()
 
void UpdateTheme ()
 
void ClearEvents ()
 
void ForceUpdateTime (float _time)
 
void InitTriggerSequence (float _songLength)
 
void SetupTimeEventTriggers ()
 Setups the time event triggers.
 
void SetupPlayerEventTriggers ()
 Setups the event based event triggers.
 
void SetupLevelEventTriggers ()
 Setups the event based event triggers.
 
void CallEvent (DataManager.GameData.BeatmapData.EventTriggers.Trigger _trigger)
 
void CallEventRaw (DataManager.GameData.BeatmapData.EventTriggers.Trigger _trigger)
 
void TestAudioDuck (Vector3 _lowPass, Vector3 _lowPassRes)
 
- Public Member Functions inherited from SingletonBase< GameManager >
virtual void Awake ()
 
virtual void OnAwake ()
 

Public Attributes

Sequence GameSequence
 
bool IsArcade
 
bool HoldUpdates = false
 
bool IsFinished = false
 
GameState CurGameState = GameState.Loading
 
LoadingState CurLoadingState = new LoadingState()
 
float CurrentSongTime
 
float CurrentSongLength
 
float CurrentSongTimeSmoothed
 
DataManager.BeatmapTheme LiveTheme
 
Sequence TriggerSequence
 
bool[] checkpointsActivated = new bool[0]
 
int lastCheckpointState = -1
 
Animator CheckpointAnimator
 
Transform CheckpointTimeline
 
GameObject CheckpointPrefab
 
bool playingCheckpointAnimation = false
 
AudioClip LevelAudio
 
DataManager.MetaData.CamJiggle CameraJiggleLevelOverride = DataManager.MetaData.CamJiggle.PlayerSelected
 
string TrackName
 
string ArtistName
 
string FolderName
 
GameObject TouchControls
 
int ColorID
 
int EndColorID
 
int AlphaColorID
 
Transform playerParent
 
RectTransform songLocationMarker
 
UI_TrackInfoView IntroView
 
Transform Timeline
 
Image[] TimelineImages
 
Image[] GUIImages
 
Image[] GUITransImages
 
bool Paused
 
UI_Window PauseMenu
 
PauseMenu PauseMenuScript
 
VGLevel DEFAULT_LEVEL
 
Dictionary< string, int > hasTriggered = new Dictionary<string, int>()
 
- Public Attributes inherited from SingletonBase< GameManager >
bool DestroySingleton
 

Properties

bool IsEditor [get]
 
bool IsHighContrast [get]
 
float GetSongSpeed [get]
 
- Properties inherited from SingletonBase< GameManager >
static T Inst [get]
 

Events

RestartDelegate levelRestartEvent
 
RewindDelegate levelRewindEvent
 
FinishDelegate levelFinishEvent
 
StartDelegate levelStartEvent
 

Private Member Functions

void Start ()
 
async System.Threading.Tasks.Task IsDoneLoading_Audio ()
 
async System.Threading.Tasks.Task IsDoneLoading_Data ()
 
async System.Threading.Tasks.Task IsDoneLoading_Metadata ()
 
async System.Threading.Tasks.Task IsDoneLoading_Objects ()
 
async System.Threading.Tasks.Task IsDoneLoading_Backgrounds ()
 
async System.Threading.Tasks.Task IsDoneLoading_Tweens ()
 
async System.Threading.Tasks.Task IsDoneLoading ()
 
void SetupCheckpoints ()
 This function sets up the checkpoints for the current level.
 
IEnumerator LoadAudio (VGLevel _level)
 
void LoadMetadata (VGLevel _level)
 
void LoadData (VGLevel _level)
 
IEnumerator LoadObjects (VGLevel _level)
 This coroutine is responsible for loading the objects for a game level.
 
IEnumerator LoadBackgrounds (VGLevel _level)
 
IEnumerator LoadTweens ()
 This coroutine is responsible for loading the tweens for a game level.
 
void PlayGame ()
 This function is responsible for starting the gameplay.
 
void GameLoop ()
 
void OnDestroy ()
 

Private Attributes

float PreviousSongTime
 
bool isReversing = false
 
readonly float[] SONG_SPEEDS = new float[] { 1, 1.2f, 0.8f }
 
DataManager.BeatmapTheme HighContrastTheme
 
Debounce PauseDebounce
 
bool isHighContrast = false
 
float audioTimeVelocity = 0
 
Color theme_workingColor
 
Color theme_workingColorExtra
 
int theme_workingLayer
 
int theme_workingIndex
 

Static Private Attributes

const float INTRO_OFFSET = 0.1f
 
const float MENU_VOLUME_WEIGHT_OUT = 0.25f
 
const float MENU_VOLUME_WEIGHT_IN = 1f
 
const float DampSpeed = 1.0f / 50.0f
 

Detailed Description

This class manages the main gameplay loop.

It is responsible for loading levels, spawning players, synchronizing game objects with the song time, and handling game state changes. It also provides functions for rewinding to checkpoints, reversing the song, and getting the closest checkpoint to a given time.

Member Function Documentation

◆ CheckpointCheck()

GameManager.CheckpointCheck ( )

Checks if a checkpoint has been reached and triggers the checkpoint animation.

This function checks if the current song time has reached any of the checkpoints that have not been activated yet. If a checkpoint is reached, it triggers the checkpoint animation and respawns the players.

◆ InitCheckpoints()

void GameManager.InitCheckpoints ( float _songLength)

This function initializes the checkpoints for the current level.

It takes a float representing the length of the song. The function creates a GameObject for each checkpoint in the beatmap data, sets its parent to the CheckpointTimeline, and positions it based on the checkpoint's time in the song.

Parameters
_songLengthThe length of the song for the current level.

◆ LoadGame()

IEnumerator GameManager.LoadGame ( VGLevel _level)

This coroutine is responsible for loading a game level. It takes a VGLevel object representing the level to be loaded. The function performs several operations such as loading metadata, audio, data, backgrounds, objects, and tweens related to the level. After all the loading operations are done, it starts the game.

Parameters
_levelThe level to be loaded.

◆ LoadObjects()

IEnumerator GameManager.LoadObjects ( VGLevel _level)
private

This coroutine is responsible for loading the objects for a game level.

It takes a VGLevel object representing the level to be loaded. The function initializes the trigger sequence and spawn and kill sequence for the level's objects. It then iterates over each beatmap object in the game data, initializing its data, parent chain, and visual. If an error occurs during this process, it is logged and the function continues to the next object.

Parameters
_levelThe level whose objects are to be loaded.

◆ LoadTweens()

IEnumerator GameManager.LoadTweens ( )
private

This coroutine is responsible for loading the tweens for a game level.

It iterates over each beatmap object in the game data and initializes its keyframes. If an error occurs during this process, it is logged and the function continues to the next object. After all beatmap objects have been processed, the function initializes the keyframes for the events.

◆ PlayGame()

void GameManager.PlayGame ( )
private

This function is responsible for starting the gameplay.

It sets the UI volume weight to 0, logs the start of the game, and checks if the game is in high contrast mode. It then calls several setup functions to prepare the game level. It also sets up the intro view with the track name, artist name, practice mode status, and main color. Finally, it inserts callbacks into the kill sequence to show and hide the intro background at specific times.

◆ ResetCheckpoints()

void GameManager.ResetCheckpoints ( bool baseOnTime = false)

This function resets the checkpoints for the current level.

It takes an optional boolean parameter that determines whether the reset is based on time. If the game data or beatmap data is null, or if there are no checkpoints, the function returns immediately.

Parameters
baseOnTimeAn optional parameter that determines whether the reset is based on time. Default value is false.

◆ RewindToCheckpoint()

void GameManager.RewindToCheckpoint ( int _indexForce = -1,
bool _instant = false )

This function is responsible for rewinding the game to a specific checkpoint.

It takes an integer representing the index of the checkpoint to rewind to. The function sets the current song time to the time of the checkpoint, resets all game objects, and synchronizes them with the new song time.

Parameters
checkpointIndexThe index of the checkpoint to rewind to.

◆ SetupCheckpoints()

void GameManager.SetupCheckpoints ( )
private

This function sets up the checkpoints for the current level.

It resets the current checkpoints and initializes new ones based on the length of the level audio.

◆ SpawnPlayers()

void GameManager.SpawnPlayers ( Vector3 _pos)

This function is responsible for spawning player objects in the game.

It iterates over each player in the game data and spawns a player object for them. The player object is initialized with the player's data, and its position is set based on the player's spawn position. If the player has a spawn animation, it is played.

◆ SyncAllObjects()

void GameManager.SyncAllObjects ( )

This function synchronizes all game objects with the current song time.

It iterates over each game object in the beatmap and checks if it should be active based on the current song time. If the song time is outside the object's start time and length, and the object is currently active, it deactivates the object. If the song time is within the object's start time and length, and the object is currently inactive, it activates the object.

◆ SyncSequenceLoop()

void GameManager.SyncSequenceLoop ( )

This function is responsible for synchronizing a sequence loop with the current song time.

It takes a SequenceLoop object and checks if it should be active based on the current song time. If the song time is outside the loop's start time and length, and the loop is currently active, it deactivates the loop. If the song time is within the loop's start time and length, and the loop is currently inactive, it activates the loop.

Parameters
sequenceLoopThe sequence loop to be synchronized.

The documentation for this class was generated from the following file: