Game Framework
GameFramework.GameStructure.GameManager Class Reference

A core component that holds and manages information about the game. More...

Inheritance diagram for GameFramework.GameStructure.GameManager:
GameFramework.GameObjects.Components.SingletonPersistant< GameManager >

Public Member Functions

override void SaveState ()
 Save GameManager state More...
 
void PlayEffect (AudioClip clip, float pitchLow=1, float pitchHigh=1)
 Plays an audio clip using the first available effect audio source More...
 
Player GetPlayer ()
 Get the current player - Obsolete More...
 
Player GetPlayer (int playerNumber)
 Get the specified player - Obsolete More...
 
void SetPlayerByNumber (int playerNumber)
 Set the current player by player number - Obsolete More...
 

Static Public Member Functions

static string GetIdentifierBase ()
 Safely get the identifier that is defined (see IdentifierBase for further details) More...
 
static T LoadResource< T > (string name, bool fallback=true)
 Load the specified resource taking into account path priorities. More...
 
static string GetIdentifierScene (string sceneName)
 Determin a scene name based upon whether IdentifierBase is set. More...
 
static bool SafeAddListener< T > (Messenger.MessageListenerDelegate handler)
 Shortcut and safe method for adding a listener without needing to test whether a gamemanager is setup. More...
 
static bool SafeRemoveListener< T > (Messenger.MessageListenerDelegate handler)
 Shortcut and safe method for removing a listener without needing to test whether a gamemanager is setup. More...
 
static bool SafeAddListener (Type messageType, Messenger.MessageListenerDelegate handler)
 Shortcut and safe method for adding a listener without needing to test whether a gamemanager is setup. More...
 
static bool SafeRemoveListener (Type messageType, Messenger.MessageListenerDelegate handler)
 Shortcut and safe method for removing a listener without needing to test whether a gamemanager is setup. More...
 
static bool SafeQueueMessage (BaseMessage msg)
 Shortcut and safe method for queueing messages without needing to test whether a gamemanager is setup. More...
 
static bool SafeTriggerMessage (BaseMessage msg)
 Shortcut and safe method for triggering messages without needing to test whether a gamemanager is setup. More...
 
static void LoadSceneWithTransitions (string sceneName)
 Load the specified scene, applying any transitions if the Beautiful Transitions asset is installed. More...
 

Public Attributes

string GameName = ""
 The name of this game More...
 
string PlayWebUrl = ""
 If targeting Andriod, a Google Play url for the game More...
 
string PlayMarketUrl = ""
 If targeting Andriod, a Google Play direct link for the game More...
 
string iOSWebUrl = ""
 If targeting iOS, a link to the App Store page game More...
 
string IdentifierBase
 Set the base identifier to allow for multiple games in a single project More...
 
MyDebug.DebugLevelType DebugLevel = MyDebug.DebugLevelType.Warning
 The amount of debug logging that should be shown (only applies in editor mode and debug builds. More...
 
bool SecurePreferences
 Whether secured preferences should be used. More...
 
string PreferencesPassPhrase
 If using secure prefs then a pass phase to use when securing preferences. More...
 
bool AutoConvertUnsecurePrefs
 If using secure prefs then whether to migrate old unsecure values. More...
 
float ReferencePhysicalScreenHeightInInches = 4f
 Physical size the game is designed against. Can be used later with PhysicalScreenHeightMultiplier for screen scaling More...
 
float DisplayChangeCheckDelay = 0.5f
 How often to check for orientation and resolution changes More...
 
int DefaultLives = 3
 Game Structure setup More...
 
int PlayerCount = 1
 The number of local players to setup More...
 
bool AutoCreateWorlds = false
 Whether to automatically setup wolds using default values. More...
 
int NumberOfAutoCreatedWorlds = 0
 The number of standard worlds that should be automatically created by the framework. More...
 
bool LoadWorldDatafromResources = false
 
GameItem.UnlockModeType WorldUnlockMode
 How we plan on letting users unlock worlds. More...
 
int CoinsToUnlockWorlds = 10
 The default number of coins to unlock worlds (can be overriden by json configuration files or code). More...
 
MinMax[] WorldLevelNumbers
 What levels numbers are assigned to each world. More...
 
bool AutoCreateLevels = false
 Whether to automatically setup levels using default values. More...
 
int NumberOfAutoCreatedLevels = 10
 The number of standard levels that should be automatically created by the framework. More...
 
bool LoadLevelDatafromResources = false
 Whether to try and load data from a resources file. More...
 
GameItem.UnlockModeType LevelUnlockMode
 How we plan on letting users unlock levels. More...
 
int CoinsToUnlockLevels = 10
 The default number of coins to unlock levels (can be overriden by json configuration files or code). More...
 
bool AutoCreateCharacters = false
 Whether to automatically setup characters using default values. More...
 
int NumberOfAutoCreatedCharacters = 10
 The number of standard characters that should be automatically created by the framework. More...
 
bool LoadCharacterDatafromResources = false
 Whether to try and load data from a resources file. More...
 
GameItem.UnlockModeType CharacterUnlockMode
 How we plan on letting users unlock characters. More...
 
int CoinsToUnlockCharacters = 10
 The default number of coins to unlock characters (can be overriden by json configuration files or code). More...
 
string[] SupportedLanguages
 A list of localisation languages that we support More...
 

Protected Member Functions

override void GameSetup ()
 Main setup routine More...
 
- Protected Member Functions inherited from GameFramework.GameObjects.Components.SingletonPersistant< GameManager >
override void GameSetup ()
 Extended GameSetup. If you override in your own class be sure to call the base instance. More...
 

Properties

bool IsInitialised [get, set]
 Whether Game Manager is setup and initialised More...
 
bool IsUnlocked [get, set]
 Whether the game is unlocked. More...
 
bool IsUserInteractionEnabled [get, set]
 
bool IsSplashScreenShown [get, set]
 General purpose property you can use for controlling the state of your game. More...
 
int TimesGamePlayed [get, set]
 The number of times that the game has been played More...
 
int TimesLevelsPlayed [get, set]
 The total number of times that levels have been played More...
 
int TimesPlayedForRatingPrompt [get, set]
 The number of times that levels have been played for use with a rating prompt More...
 
AudioSource BackGroundAudioSource [get, set]
 An AudioSource for playing background music. More...
 
AudioSource[] EffectAudioSources [get, set]
 AudioSources for playing sound effects. More...
 
float BackGroundAudioVolume [get, set]
 The background audio volume More...
 
float EffectAudioVolume [get, set]
 The effect audio volume More...
 
Vector3 WorldBottomLeftPosition [get]
 The world bottom left position as seen from the main camera (correct always for othograpthic camera, otherwise correct at camera z position for perspective camera) More...
 
Vector3 WorldTopRightPosition [get]
 The world bottom top right position as seen from the main camera (correct always for othograpthic camera, otherwise correct at camera z position for perspective camera) More...
 
Vector3 WorldBottomLeftPositionXYPlane [get]
 The world bottom left position on the xy plane (z=0) as seen from the main camera (correct always and same as WorldBottomLeftPosition for othograpthic camera) More...
 
Vector3 WorldTopRightPositionXYPlane [get]
 The world bottom top right position on the xy plane (z=0) as seen from the main camera (correct always and same as WorldBottomLeftPosition for othograpthic camera) More...
 
Vector3 WorldSize [get]
 The visible world size as seen from the main camera More...
 
float AspectRatioMultiplier [get]
 A multiplier for the current aspect ratio based on a 4:3 default More...
 
float PhysicalScreenHeightMultiplier [get]
 A multiplier for the screen height based upon ReferencePhysicalScreenHeightInInches More...
 
CharacterGameItemManager Characters [get, set]
 GameItemManager containing the current Characters More...
 
WorldGameItemManager Worlds [get, set]
 GameItemManager containing the current Worlds More...
 
LevelGameItemManager Levels [get, set]
 GameItemManager containing the current Levels More...
 
PlayerGameItemManager Players [get, set]
 GameItemManager containing the current Players More...
 
Player Player [get, set]
 The current Player. More...
 
static Messenger Messenger [get]
 

Events

Action< Vector2 > OnResolutionChange
 May be deprecated in the future. Listen for OnResolutionChangeMessage instead More...
 
Action< DeviceOrientation > OnOrientationChange
 May be deprecated in the future. Listen for OnOrientationChangeMessage instead More...
 

Detailed Description

A core component that holds and manages information about the game.

GameManager is where you can setup the structure of your game and holdes other key information and functionality relating to Preferences, GameStructure, Display, Localisation, Audio, Messaging and more. Please see the online help for full information.

Member Function Documentation

override void GameFramework.GameStructure.GameManager.GameSetup ( )
protected

Main setup routine

static string GameFramework.GameStructure.GameManager.GetIdentifierBase ( )
static

Safely get the identifier that is defined (see IdentifierBase for further details)

Returns
static string GameFramework.GameStructure.GameManager.GetIdentifierScene ( string  sceneName)
static

Determin a scene name based upon whether IdentifierBase is set.

Parameters
sceneName
Returns
Player GameFramework.GameStructure.GameManager.GetPlayer ( )

Get the current player - Obsolete

Returns
Player GameFramework.GameStructure.GameManager.GetPlayer ( int  playerNumber)

Get the specified player - Obsolete

Parameters
playerNumberplayer number 0 being the first player
Returns
static T GameFramework.GameStructure.GameManager.LoadResource< T > ( string  name,
bool  fallback = true 
)
static

Load the specified resource taking into account path priorities.

When loading a resource it will be first tried loaded from a folder prefixed with IdentifierBase (if set), otherwise it will fall back to the named resource, and if that is not found to the named resource from a folder named Default

Template Parameters
T
Parameters
name
fallback
Returns
Type Constraints
T :UnityEngine.Object 
static void GameFramework.GameStructure.GameManager.LoadSceneWithTransitions ( string  sceneName)
static

Load the specified scene, applying any transitions if the Beautiful Transitions asset is installed.

Parameters
sceneName
void GameFramework.GameStructure.GameManager.PlayEffect ( AudioClip  clip,
float  pitchLow = 1,
float  pitchHigh = 1 
)

Plays an audio clip using the first available effect audio source

If no available audio sources are available then a new one will be created.

Parameters
clip
pitchLow
pitchHigh
static bool GameFramework.GameStructure.GameManager.SafeAddListener ( Type  messageType,
Messenger.MessageListenerDelegate  handler 
)
static

Shortcut and safe method for adding a listener without needing to test whether a gamemanager is setup.

As GameManager can be destroyed before other components when you shut down your game, it is important to

Parameters
messageType
handler
Returns
static bool GameFramework.GameStructure.GameManager.SafeAddListener< T > ( Messenger.MessageListenerDelegate  handler)
static

Shortcut and safe method for adding a listener without needing to test whether a gamemanager is setup.

As GameManager can be destroyed before other components when you shut down your game, it is important to

Parameters
handler
Returns
Type Constraints
T :BaseMessage 
static bool GameFramework.GameStructure.GameManager.SafeQueueMessage ( BaseMessage  msg)
static

Shortcut and safe method for queueing messages without needing to test whether a gamemanager is setup.

Parameters
msg
Returns
static bool GameFramework.GameStructure.GameManager.SafeRemoveListener ( Type  messageType,
Messenger.MessageListenerDelegate  handler 
)
static

Shortcut and safe method for removing a listener without needing to test whether a gamemanager is setup.

Parameters
messageType
handler
Returns
static bool GameFramework.GameStructure.GameManager.SafeRemoveListener< T > ( Messenger.MessageListenerDelegate  handler)
static

Shortcut and safe method for removing a listener without needing to test whether a gamemanager is setup.

Parameters
handler
Returns
Type Constraints
T :BaseMessage 
static bool GameFramework.GameStructure.GameManager.SafeTriggerMessage ( BaseMessage  msg)
static

Shortcut and safe method for triggering messages without needing to test whether a gamemanager is setup.

Parameters
msg
Returns
override void GameFramework.GameStructure.GameManager.SaveState ( )

Save GameManager state

void GameFramework.GameStructure.GameManager.SetPlayerByNumber ( int  playerNumber)

Set the current player by player number - Obsolete

Parameters
playerNumber

Member Data Documentation

bool GameFramework.GameStructure.GameManager.AutoConvertUnsecurePrefs

If using secure prefs then whether to migrate old unsecure values.

For existing games you should set this to true if you want to keep their current progress. For new games set to false for performance as there will be nothing to convert.

bool GameFramework.GameStructure.GameManager.AutoCreateCharacters = false

Whether to automatically setup characters using default values.

bool GameFramework.GameStructure.GameManager.AutoCreateLevels = false

Whether to automatically setup levels using default values.

bool GameFramework.GameStructure.GameManager.AutoCreateWorlds = false

Whether to automatically setup wolds using default values.

GameItem.UnlockModeType GameFramework.GameStructure.GameManager.CharacterUnlockMode

How we plan on letting users unlock characters.

int GameFramework.GameStructure.GameManager.CoinsToUnlockCharacters = 10

The default number of coins to unlock characters (can be overriden by json configuration files or code).

int GameFramework.GameStructure.GameManager.CoinsToUnlockLevels = 10

The default number of coins to unlock levels (can be overriden by json configuration files or code).

int GameFramework.GameStructure.GameManager.CoinsToUnlockWorlds = 10

The default number of coins to unlock worlds (can be overriden by json configuration files or code).

MyDebug.DebugLevelType GameFramework.GameStructure.GameManager.DebugLevel = MyDebug.DebugLevelType.Warning

The amount of debug logging that should be shown (only applies in editor mode and debug builds.

int GameFramework.GameStructure.GameManager.DefaultLives = 3

Game Structure setup

float GameFramework.GameStructure.GameManager.DisplayChangeCheckDelay = 0.5f

How often to check for orientation and resolution changes

string GameFramework.GameStructure.GameManager.GameName = ""

The name of this game

string GameFramework.GameStructure.GameManager.IdentifierBase

Set the base identifier to allow for multiple games in a single project

This property is used by the LoadResource and GetIdentifierScene methods to determine a unique name based upon the base identifier this will not be necessary in most cases, however is used in the extras bundle to allow for multiple games and demos within a single project

string GameFramework.GameStructure.GameManager.iOSWebUrl = ""

If targeting iOS, a link to the App Store page game

GameItem.UnlockModeType GameFramework.GameStructure.GameManager.LevelUnlockMode

How we plan on letting users unlock levels.

bool GameFramework.GameStructure.GameManager.LoadCharacterDatafromResources = false

Whether to try and load data from a resources file.

bool GameFramework.GameStructure.GameManager.LoadLevelDatafromResources = false

Whether to try and load data from a resources file.

bool GameFramework.GameStructure.GameManager.LoadWorldDatafromResources = false

int GameFramework.GameStructure.GameManager.NumberOfAutoCreatedCharacters = 10

The number of standard characters that should be automatically created by the framework.

int GameFramework.GameStructure.GameManager.NumberOfAutoCreatedLevels = 10

The number of standard levels that should be automatically created by the framework.

int GameFramework.GameStructure.GameManager.NumberOfAutoCreatedWorlds = 0

The number of standard worlds that should be automatically created by the framework.

int GameFramework.GameStructure.GameManager.PlayerCount = 1

The number of local players to setup

string GameFramework.GameStructure.GameManager.PlayMarketUrl = ""

If targeting Andriod, a Google Play direct link for the game

string GameFramework.GameStructure.GameManager.PlayWebUrl = ""

If targeting Andriod, a Google Play url for the game

string GameFramework.GameStructure.GameManager.PreferencesPassPhrase

If using secure prefs then a pass phase to use when securing preferences.

This should ideally be a random string of 10 or more characters. Note that advanced hackers may be able to find this pass phrase in you executable. For optimum security some sort of online lookup would be needed so no pass phrase is stored locally.

float GameFramework.GameStructure.GameManager.ReferencePhysicalScreenHeightInInches = 4f

Physical size the game is designed against. Can be used later with PhysicalScreenHeightMultiplier for screen scaling

bool GameFramework.GameStructure.GameManager.SecurePreferences

Whether secured preferences should be used.

string [] GameFramework.GameStructure.GameManager.SupportedLanguages

A list of localisation languages that we support

MinMax [] GameFramework.GameStructure.GameManager.WorldLevelNumbers

What levels numbers are assigned to each world.

These are used for internal lookup and references for e.g. in-app purchase. Enter a range but keep the numbers unique. You might also want to leave room to expand these later. e.g. (1-10), (101,110)

GameItem.UnlockModeType GameFramework.GameStructure.GameManager.WorldUnlockMode

How we plan on letting users unlock worlds.

Property Documentation

float GameFramework.GameStructure.GameManager.AspectRatioMultiplier
get

A multiplier for the current aspect ratio based on a 4:3 default

AudioSource GameFramework.GameStructure.GameManager.BackGroundAudioSource
getset

An AudioSource for playing background music.

This is automatically set as the first AudioSource on the same game object as GameManager is present

float GameFramework.GameStructure.GameManager.BackGroundAudioVolume
getset

The background audio volume

Automatically adjusts the BackGroundAudioSource if present

CharacterGameItemManager GameFramework.GameStructure.GameManager.Characters
getset

GameItemManager containing the current Characters

AudioSource [] GameFramework.GameStructure.GameManager.EffectAudioSources
getset

AudioSources for playing sound effects.

Thse are automatically set as the secend and subsequent AudioSources on the same game object as GameManager is present

float GameFramework.GameStructure.GameManager.EffectAudioVolume
getset

The effect audio volume

Automatically adjusts all EffectAudioSources if present

bool GameFramework.GameStructure.GameManager.IsInitialised
getset

Whether Game Manager is setup and initialised

THis is set to true once the GameSetup function is complete.

bool GameFramework.GameStructure.GameManager.IsSplashScreenShown
getset

General purpose property you can use for controlling the state of your game.

bool GameFramework.GameStructure.GameManager.IsUnlocked
getset

Whether the game is unlocked.

Some games support the concept of unlocking the game to remove ads or enabling extra features. This field can be used control this behaviour such as only enabling certain features and can be linked to in app purchase.

bool GameFramework.GameStructure.GameManager.IsUserInteractionEnabled
getset
LevelGameItemManager GameFramework.GameStructure.GameManager.Levels
getset

GameItemManager containing the current Levels

Messenger GameFramework.GameStructure.GameManager.Messenger
staticget
float GameFramework.GameStructure.GameManager.PhysicalScreenHeightMultiplier
get

A multiplier for the screen height based upon ReferencePhysicalScreenHeightInInches

Player GameFramework.GameStructure.GameManager.Player
getset

The current Player.

PlayerChangedMessage is sent whenever this value changes outside of initialisation.

PlayerGameItemManager GameFramework.GameStructure.GameManager.Players
getset

GameItemManager containing the current Players

int GameFramework.GameStructure.GameManager.TimesGamePlayed
getset

The number of times that the game has been played

AUtomatically updated by GameManager,

int GameFramework.GameStructure.GameManager.TimesLevelsPlayed
getset

The total number of times that levels have been played

AUtomatically updated by LevelManager,

int GameFramework.GameStructure.GameManager.TimesPlayedForRatingPrompt
getset

The number of times that levels have been played for use with a rating prompt

AUtomatically updated by LevelManager, this is similar to TImesLevelsPlayed but if they click 'remind me later' then this will be reset to 0.

Vector3 GameFramework.GameStructure.GameManager.WorldBottomLeftPosition
get

The world bottom left position as seen from the main camera (correct always for othograpthic camera, otherwise correct at camera z position for perspective camera)

Vector3 GameFramework.GameStructure.GameManager.WorldBottomLeftPositionXYPlane
get

The world bottom left position on the xy plane (z=0) as seen from the main camera (correct always and same as WorldBottomLeftPosition for othograpthic camera)

WorldGameItemManager GameFramework.GameStructure.GameManager.Worlds
getset

GameItemManager containing the current Worlds

Vector3 GameFramework.GameStructure.GameManager.WorldSize
get

The visible world size as seen from the main camera

Vector3 GameFramework.GameStructure.GameManager.WorldTopRightPosition
get

The world bottom top right position as seen from the main camera (correct always for othograpthic camera, otherwise correct at camera z position for perspective camera)

Vector3 GameFramework.GameStructure.GameManager.WorldTopRightPositionXYPlane
get

The world bottom top right position on the xy plane (z=0) as seen from the main camera (correct always and same as WorldBottomLeftPosition for othograpthic camera)

Event Documentation

Action<DeviceOrientation> GameFramework.GameStructure.GameManager.OnOrientationChange

May be deprecated in the future. Listen for OnOrientationChangeMessage instead

Action<Vector2> GameFramework.GameStructure.GameManager.OnResolutionChange

May be deprecated in the future. Listen for OnResolutionChangeMessage instead


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