Platformer Pro  2.3.2
A platform game kit for Unity.
PlatformerPro.PlatformerProGameManager Class Reference

The master Game Manager controls loading characters, triggering persistence, and setting up the game ready to play. More...

Inheritance diagram for PlatformerPro.PlatformerProGameManager:
PlatformerPro.PlatformerProMonoBehaviour

Public Member Functions

override void Validate (PlatformerProMonoBehaviour myTarget)
 Validate required components. More...
 
void ForceSave ()
 Force all persistables to save. More...
 
Character GetCharacterForPlayerId (int playerId)
 Gets the character for fiven player identifier. If id = -1 return first active character. Returns null if no character for playerId More...
 
void SpawnNewCharacter (int playerId, string characterId)
 Spawns a new character. Fails if a character with the supplied player id exists. More...
 
void ReplaceCharacter (int playerId, string characterId)
 Replace a character with a different one. More...
 
void SwitchCharacter (int currentPlayerId, int newPlayerId)
 Switches to a new character. Fails if a character with the supplied player id doesn't exist. More...
 

Static Public Member Functions

static void SetCharacterForPlayer (int playerId, string characterId)
 Sets the character to load for a given player; More...
 
static void UnSetCharacterForPlayer (int playerId)
 UnSets the character to load for a given player; More...
 

Public Attributes

List< AvailableCharacterDataavailableCharacters
 List of all available characters. These can be loaded at the start of the game or while the game is in progress. If there is only one character in this list it will be automatically loaded. More...
 
bool enablePersistence = true
 Should we enable saving and loading? More...
 
bool useBinaryFormat = true
 Should we save using binary files (true) or XML files (false). More...
 
PersistenceResetType defaultPersistenceReset
 How do we handle persistence reset? More...
 
bool saveOnAnyChange
 Will we save always, or only when the cahracter dies or leaves a scene. More...
 
bool saveOnAnyChangeEditorOnly
 Save always, but only in the editor. More...
 
float saveRate = 1.0f
 Regardless of how often Save is called, don't save faster than this. More...
 
bool persistObjectsInLevel
 Should we (by default) persist platformer pro object like doors, platforms, items, etc. You can override on invidiual objects. More...
 
PersistableObjectType itemPersistenceType = PersistableObjectType.ACTIVATE_DEACTIVATE
 Should we persist item state by default. More...
 
bool spawnedItemPersistence = false
 Should we persist items spawned in to the scene. More...
 
PersistableEnemyType enemyPersistenceType = PersistableEnemyType.ALIVE_DEAD
 Should we persist enemy state by default. More...
 
GameOverType endGameWhen
 When does the game end. More...
 
bool isMapOrMenu
 Set to true if this is not a normal playable level. More...
 

Static Public Attributes

const int ANY_PLAYER = -1
 Constant for a player id that matches any player. More...
 

Protected Member Functions

virtual void OnCharacterLoaded (Character character)
 Raises the character loaded event. More...
 
virtual void OnCharacterRemoved (Character character)
 Raises the character removed event. More...
 
virtual void OnPhaseChanged (GamePhase phase)
 Raises the phase change event. More...
 
virtual void Init ()
 Initialise this instance. Called form Awake. More...
 
virtual void PostInit ()
 Called from start. Use this to get references, etc. More...
 
virtual void LoadCharacter ()
 Loads the character. More...
 
virtual void DoLoad ()
 Does the load after a delay. More...
 
virtual IEnumerator PostLoad ()
 After start frame tell send events for loaded characters. More...
 
virtual void LoadCharacter (int playerId, string characterId)
 Loads the character with the given id. More...
 
virtual void HandleGameOver (object sender, CharacterEventArgs e)
 Handle game over events More...
 
virtual IEnumerator PostLoad (Character c)
 Send the character loaded event after yielding for a frame. More...
 

Protected Attributes

List< CharacterloadedCharacters
 All the loaded characters. More...
 
float saveTimer
 Track how long until the next save. More...
 
GamePhase gamePhase
 The game loading phase. More...
 

Static Protected Attributes

static bool initialised
 Tracks if we have initialised an instance of the game manager. More...
 
static List< string > charactersToLoad
 List of character ids which should be loaded on Start(). One slot per player. If a slot is null tha given player is not playing. More...
 
static PlatformerProGameManager instance
 Stores the singleton instance. More...
 

Properties

override string Header [get]
 Gets the header string used to describe the component. More...
 
virtual GamePhase GamePhase [get, protected set]
 Gets or sets the game loading phase and send an event when set. More...
 
virtual List< CharacterLoadedCharacters [get]
 Returns all loaded characters. WARNING: For performance reasons this is not a copy. More...
 
virtual PersistableObjectManager PersistableObjectManager [get, protected set]
 Gets or sets the persistable object manager. More...
 
static PlatformerProGameManager Instance [get, protected set]
 Gets a character loader (generally for single character games only). More...
 
- Properties inherited from PlatformerPro.PlatformerProMonoBehaviour
virtual string Header [get]
 Gets the header string used to describe the component. More...
 
virtual string DocLink [get]
 Gets a link to documentation site. More...
 
virtual string VideoLink [get]
 Gets a link to a youtube video. More...
 
virtual string Deprecated [get]
 If non-null this component is deprecated. The string shows a message indicating how it should be replaced. More...
 

Events

System.EventHandler< CharacterEventArgsCharacterLoaded
 Event fired when a character finishes loading. More...
 
System.EventHandler< CharacterEventArgsCharacterRemoved
 Event fired when a character is removed. More...
 
System.EventHandler< GamePhaseEventArgsPhaseChanged
 Event fired when Game Phase changes. More...
 
System.EventHandler< PersistenceEventArgsDoPendingSaves
 Trigger saves. More...
 

Detailed Description

The master Game Manager controls loading characters, triggering persistence, and setting up the game ready to play.

Member Function Documentation

◆ DoLoad()

virtual void PlatformerPro.PlatformerProGameManager.DoLoad ( )
protectedvirtual

Does the load after a delay.

◆ ForceSave()

void PlatformerPro.PlatformerProGameManager.ForceSave ( )

Force all persistables to save.

◆ GetCharacterForPlayerId()

Character PlatformerPro.PlatformerProGameManager.GetCharacterForPlayerId ( int  playerId)

Gets the character for fiven player identifier. If id = -1 return first active character. Returns null if no character for playerId

Returns
The character for given player identifier.
Parameters
playerIdPlayer identifier.

◆ HandleGameOver()

virtual void PlatformerPro.PlatformerProGameManager.HandleGameOver ( object  sender,
CharacterEventArgs  e 
)
protectedvirtual

Handle game over events

Parameters
senderSender.
eE.

◆ Init()

virtual void PlatformerPro.PlatformerProGameManager.Init ( )
protectedvirtual

Initialise this instance. Called form Awake.

◆ LoadCharacter() [1/2]

virtual void PlatformerPro.PlatformerProGameManager.LoadCharacter ( )
protectedvirtual

Loads the character.

◆ LoadCharacter() [2/2]

virtual void PlatformerPro.PlatformerProGameManager.LoadCharacter ( int  playerId,
string  characterId 
)
protectedvirtual

Loads the character with the given id.

Parameters
playerIdPlayer identifier.
characterIdCharacterId.

◆ OnCharacterLoaded()

virtual void PlatformerPro.PlatformerProGameManager.OnCharacterLoaded ( Character  character)
protectedvirtual

Raises the character loaded event.

◆ OnCharacterRemoved()

virtual void PlatformerPro.PlatformerProGameManager.OnCharacterRemoved ( Character  character)
protectedvirtual

Raises the character removed event.

◆ OnPhaseChanged()

virtual void PlatformerPro.PlatformerProGameManager.OnPhaseChanged ( GamePhase  phase)
protectedvirtual

Raises the phase change event.

Parameters
phaseCompleted phase.

◆ PostInit()

virtual void PlatformerPro.PlatformerProGameManager.PostInit ( )
protectedvirtual

Called from start. Use this to get references, etc.

◆ PostLoad() [1/2]

virtual IEnumerator PlatformerPro.PlatformerProGameManager.PostLoad ( )
protectedvirtual

After start frame tell send events for loaded characters.

Returns
The character loaded events.

◆ PostLoad() [2/2]

virtual IEnumerator PlatformerPro.PlatformerProGameManager.PostLoad ( Character  c)
protectedvirtual

Send the character loaded event after yielding for a frame.

Returns
The load.
Parameters
cC.

◆ ReplaceCharacter()

void PlatformerPro.PlatformerProGameManager.ReplaceCharacter ( int  playerId,
string  characterId 
)

Replace a character with a different one.

Parameters
playerIdPlayer identifier.
characterIdCharacter identifier.

◆ SetCharacterForPlayer()

static void PlatformerPro.PlatformerProGameManager.SetCharacterForPlayer ( int  playerId,
string  characterId 
)
static

Sets the character to load for a given player;

Parameters
playerIdPlayer identifier.
characterIdCharacter identifier.

◆ SpawnNewCharacter()

void PlatformerPro.PlatformerProGameManager.SpawnNewCharacter ( int  playerId,
string  characterId 
)

Spawns a new character. Fails if a character with the supplied player id exists.

Parameters
playerIdPlayer identifier.
characterIdCharacter identifier.

◆ SwitchCharacter()

void PlatformerPro.PlatformerProGameManager.SwitchCharacter ( int  currentPlayerId,
int  newPlayerId 
)

Switches to a new character. Fails if a character with the supplied player id doesn't exist.

Parameters
playerIdPlayer identifier.
characterIdCharacter identifier.

◆ UnSetCharacterForPlayer()

static void PlatformerPro.PlatformerProGameManager.UnSetCharacterForPlayer ( int  playerId)
static

UnSets the character to load for a given player;

Parameters
playerIdPlayer identifier.
characterIdCharacter identifier.

◆ Validate()

override void PlatformerPro.PlatformerProGameManager.Validate ( PlatformerProMonoBehaviour  myTarget)
virtual

Validate required components.

Parameters
myTarget

Reimplemented from PlatformerPro.PlatformerProMonoBehaviour.

Member Data Documentation

◆ ANY_PLAYER

const int PlatformerPro.PlatformerProGameManager.ANY_PLAYER = -1
static

Constant for a player id that matches any player.

◆ availableCharacters

List<AvailableCharacterData> PlatformerPro.PlatformerProGameManager.availableCharacters

List of all available characters. These can be loaded at the start of the game or while the game is in progress. If there is only one character in this list it will be automatically loaded.

◆ charactersToLoad

List<string> PlatformerPro.PlatformerProGameManager.charactersToLoad
staticprotected

List of character ids which should be loaded on Start(). One slot per player. If a slot is null tha given player is not playing.

◆ defaultPersistenceReset

PersistenceResetType PlatformerPro.PlatformerProGameManager.defaultPersistenceReset

How do we handle persistence reset?

◆ enablePersistence

bool PlatformerPro.PlatformerProGameManager.enablePersistence = true

Should we enable saving and loading?

◆ endGameWhen

GameOverType PlatformerPro.PlatformerProGameManager.endGameWhen

When does the game end.

◆ enemyPersistenceType

PersistableEnemyType PlatformerPro.PlatformerProGameManager.enemyPersistenceType = PersistableEnemyType.ALIVE_DEAD

Should we persist enemy state by default.

◆ gamePhase

GamePhase PlatformerPro.PlatformerProGameManager.gamePhase
protected

The game loading phase.

◆ initialised

bool PlatformerPro.PlatformerProGameManager.initialised
staticprotected

Tracks if we have initialised an instance of the game manager.

◆ instance

PlatformerProGameManager PlatformerPro.PlatformerProGameManager.instance
staticprotected

Stores the singleton instance.

◆ isMapOrMenu

bool PlatformerPro.PlatformerProGameManager.isMapOrMenu

Set to true if this is not a normal playable level.

◆ itemPersistenceType

PersistableObjectType PlatformerPro.PlatformerProGameManager.itemPersistenceType = PersistableObjectType.ACTIVATE_DEACTIVATE

Should we persist item state by default.

◆ loadedCharacters

List<Character> PlatformerPro.PlatformerProGameManager.loadedCharacters
protected

All the loaded characters.

◆ persistObjectsInLevel

bool PlatformerPro.PlatformerProGameManager.persistObjectsInLevel

Should we (by default) persist platformer pro object like doors, platforms, items, etc. You can override on invidiual objects.

◆ saveOnAnyChange

bool PlatformerPro.PlatformerProGameManager.saveOnAnyChange

Will we save always, or only when the cahracter dies or leaves a scene.

◆ saveOnAnyChangeEditorOnly

bool PlatformerPro.PlatformerProGameManager.saveOnAnyChangeEditorOnly

Save always, but only in the editor.

◆ saveRate

float PlatformerPro.PlatformerProGameManager.saveRate = 1.0f

Regardless of how often Save is called, don't save faster than this.

◆ saveTimer

float PlatformerPro.PlatformerProGameManager.saveTimer
protected

Track how long until the next save.

◆ spawnedItemPersistence

bool PlatformerPro.PlatformerProGameManager.spawnedItemPersistence = false

Should we persist items spawned in to the scene.

◆ useBinaryFormat

bool PlatformerPro.PlatformerProGameManager.useBinaryFormat = true

Should we save using binary files (true) or XML files (false).

Property Documentation

◆ GamePhase

virtual GamePhase PlatformerPro.PlatformerProGameManager.GamePhase
getprotected set

Gets or sets the game loading phase and send an event when set.

◆ Header

override string PlatformerPro.PlatformerProGameManager.Header
get

Gets the header string used to describe the component.

The header.

◆ Instance

PlatformerProGameManager PlatformerPro.PlatformerProGameManager.Instance
staticgetprotected set

Gets a character loader (generally for single character games only).

Returns
A character loader or null if none found.

◆ LoadedCharacters

virtual List<Character> PlatformerPro.PlatformerProGameManager.LoadedCharacters
get

Returns all loaded characters. WARNING: For performance reasons this is not a copy.

◆ PersistableObjectManager

virtual PersistableObjectManager PlatformerPro.PlatformerProGameManager.PersistableObjectManager
getprotected set

Gets or sets the persistable object manager.

The persistable object manager.

Event Documentation

◆ CharacterLoaded

System.EventHandler<CharacterEventArgs> PlatformerPro.PlatformerProGameManager.CharacterLoaded

Event fired when a character finishes loading.

◆ CharacterRemoved

System.EventHandler<CharacterEventArgs> PlatformerPro.PlatformerProGameManager.CharacterRemoved

Event fired when a character is removed.

◆ DoPendingSaves

System.EventHandler<PersistenceEventArgs> PlatformerPro.PlatformerProGameManager.DoPendingSaves

Trigger saves.

◆ PhaseChanged

System.EventHandler<GamePhaseEventArgs> PlatformerPro.PlatformerProGameManager.PhaseChanged

Event fired when Game Phase changes.


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