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

Manages respawning and respawn points. More...

Inheritance diagram for PlatformerPro.LevelManager:
PlatformerPro.Persistable PlatformerPro.PlatformerProMonoBehaviour PlatformerPro.ICharacterReference

Public Member Functions

void Exit ()
 Exit the scene. More...
 
virtual void LevelCompleted ()
 Indicates level is complete. More...
 
virtual void LoadScene (string sceneName)
 Load the given scene. More...
 
virtual void EnableRespawnPoint (string respawnPoint)
 Enables a spawn point but doesn't set it as active. More...
 
virtual void ActivateRespawnPoint (string respawnPoint)
 Enables and actiavtes the respawn point. More...
 
virtual void Respawn (Character character)
 Respawn the specified character at the currently active reswpawn point. More...
 
virtual void Respawn (Character character, string respawnPoint)
 Respawn the specified character at the specified respawn point. More...
 
virtual void ClearRespawns ()
 Clear all respawn points (but dont reset level locks). More...
 
virtual void UnlockLevel (string levelKey)
 Unlocks the given level (or object). More...
 
virtual void UnlockLevel (string levelKey, int completeRating)
 Unlocks the given level (or object) and Sets a complete rating (i.e. snumber of stars, percentage, etc). More...
 
virtual void LockLevel (string levelKey)
 Unlocks the given level (or object). More...
 
virtual bool IsUnlocked (string levelKey)
 Check if the given level (or other object) is unlocked. More...
 
virtual int Rating (string levelKey)
 
override void ApplySaveData (object t)
 Applies the save data to the object. More...
 
override System.Type SavedObjectType ()
 Get the type of object this Persistable saves. More...
 
override void ResetSaveData ()
 Resets the save data back to default. More...
 
- Public Member Functions inherited from PlatformerPro.Persistable
virtual System.Type[] GetExtraTypes ()
 Support complex object serialisation by passing additional types to seralizer. More...
 
- Public Member Functions inherited from PlatformerPro.PlatformerProMonoBehaviour
virtual void Validate (PlatformerProMonoBehaviour myTarget)
 Override this method if you want to provide custom validation. The actual code should be surrounded by the if UNITY_EDITOR / endif directive. More...
 

Public Attributes

string levelName
 Name of the current level More...
 
bool unlockLevelOnComplete = true
 Unlock the level name automatically when level completes. More...
 
string sceneToLoadOnLevelComplete
 Should we automatically load another scene on level complete. Leave blank if there is a level complete screen which will do the loading. More...
 
bool clearRespawnsOnComplete = true
 Should we clear all respawn points for this level on level complete? More...
 
string exitMenuScene
 Scene to load when user exits level select. More...
 
bool saveSceneName = false
 Should we save the name of the sceen to the saved scene data? More...
 
- Public Attributes inherited from PlatformerPro.Persistable
bool usePersistenceDefaults = true
 Should we use the persistence defaults or override with our own values. More...
 
bool enablePersistence = true
 Should we enable persistence. More...
 
bool saveOnAnyChange
 Save whenever this value changes (Note: not supported by all objects). More...
 
PersistenceResetType persistenceType
 When do we reset persistence? More...
 

Static Public Attributes

const string PLAYER_PREF_KEY = "LevelManager"
 Const key to append in front of level lock string. More...
 
- Static Public Attributes inherited from PlatformerPro.Persistable
const string BasePlayerPrefId = "PP.Persistent."
 The base player preference identifier. More...
 

Protected Member Functions

virtual void OnRespawned (Character character, int playerId, string respawnPoint)
 Raises the respawned event. More...
 
virtual void OnSceneLoaded ()
 Raises the scene loaded event on Start. More...
 
virtual void OnLevelComplete (string levelName)
 Raises the level complete event. More...
 
virtual void OnWillExitScene (string newLevelName)
 Raises the level complete event. More...
 
virtual void Init ()
 
virtual void HandlePhaseChange (object sender, GamePhaseEventArgs e)
 
virtual void HandleCharacterLoaded (object sender, CharacterEventArgs e)
 Handles the character loaded event by setting the character. More...
 
virtual void DoDestroy ()
 Do the destroy actions. More...
 
- Protected Member Functions inherited from PlatformerPro.Persistable
virtual void OnLoaded ()
 Raises the loaded event. More...
 
virtual void ConfigureEventListeners ()
 Init this instance. More...
 
virtual void DoPendingSaves (object sender, PersistenceEventArgs e)
 Trigger any pending saves. More...
 
virtual void PhaseChange (object sender, GamePhaseEventArgs e)
 Handle a change of game phase, look for persistence event and apply. More...
 
virtual void HandleRespawn (object sender, CharacterEventArgs e)
 Handle a change of game phase, look for persistence event and apply. More...
 
virtual void HandleWillExitScene (object sender, SceneEventArgs e)
 Handles the will exit scene event More...
 
virtual void HandleGameOver (object sender, CharacterEventArgs e)
 Handles the game over event More...
 
virtual void HandleDied (object sender, DamageInfoEventArgs e)
 Handles the died event. More...
 

Static Protected Member Functions

static void CreateNewLevelManager ()
 Creates the level manager. More...
 
- Static Protected Member Functions inherited from PlatformerPro.Persistable
static object LoadSavedDataXml (Persistable p)
 Does the actual load and returns raw object. More...
 
static object LoadSavedDataBinary (Persistable p)
 Does the actual load and returns raw object. More...
 

Protected Attributes

string activeRespawnPoint
 The currently active respawn point identifier. More...
 
List< string > enabledRespawnPoints
 List of all enabled respawn points. More...
 
List< LevelLockDatalevelLockData
 The level lock data. More...
 
Character character
 Character to use for persistence events. Generally this is for resetting locks on game over. More...
 
string lastEnteredScene
 Stores the SceneManager name of the last entered scene. More...
 
- Protected Attributes inherited from PlatformerPro.Persistable
bool loaded
 Have we loaded the data yet? More...
 
bool readyToSave
 Are we ready to save on the next save tick? More...
 
Persistable latestSaveData
 Data to save when we trigger the next save tick. More...
 

Static Protected Attributes

static bool sceneLoadedEvent
 Have we called the scene loaded event for this scene? Used to ensure we only call scene loaded once when the first character is loaded. More...
 
static LevelManager instance
 The instance. More...
 

Properties

bool IsActive [get]
 Has a respawn point been set? More...
 
string ActiveRespawnPoint [get]
 Return the active resapwn point More...
 
List< string > EnabledRespawnPoints [get]
 Get a copy of the list of enabled respawn points. More...
 
override string PlayerPrefsIdentifier [get]
 The player preference identifier. More...
 
static LevelManager Instance [get, protected set]
 Gets a reference to this object. More...
 
static string PreviousLevel [get, set]
 Keeps track of the previous level. More...
 
override Character Character [get, set]
 Gets the character. More...
 
override object SaveData [get]
 Gets the data to save. More...
 
override string Identifier [get]
 Get a unique identifier to use when saving the data (for example this could be used for part of the file name or player prefs name). More...
 
- Properties inherited from PlatformerPro.Persistable
virtual string PlayerPrefsIdentifier [get]
 The player preference identifier. More...
 
virtual bool EnablePersistence [get]
 Gets the value for persistence type taking in to account defaults. More...
 
virtual PersistenceResetType PersistenceType [get]
 Gets the value for persistence type taking in to account defaults. More...
 
virtual bool SaveOnChange [get]
 Gets the value for save on change type taking in to account defaults. More...
 
abstract Character Character [get, set]
 Gets the character. More...
 
abstract object SaveData [get]
 Gets the data to save. More...
 
abstract string Identifier [get]
 Get a unique identifier to use when saving the data (for example this could be used for part of the file name or player prefs name). 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...
 
- Properties inherited from PlatformerPro.ICharacterReference
Character Character [get, set]
 Get the character. More...
 

Events

System.EventHandler< SceneEventArgsSceneLoaded
 Event for scene load. More...
 
System.EventHandler< RespawnEventArgsRespawned
 Event for character respawn. More...
 
System.EventHandler< LevelEventArgsLevelComplete
 Event for level completed. More...
 
System.EventHandler< SceneEventArgsWillExitScene
 Sent when we will exit a scene. More...
 
- Events inherited from PlatformerPro.Persistable
System.EventHandler< EmptyEventArgsLoaded
 Sent when this persistable is loaded. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from PlatformerPro.Persistable
static void Save (Persistable p)
 Save the given persistable. More...
 
static void SaveXml (Persistable p)
 Save the given persistable in XML format. More...
 
static void SaveBinary (Persistable p)
 Save the given persistable in XML format. More...
 
static void Load (Persistable p)
 Load the given persistable. More...
 
static void Reset (Persistable p)
 Resets the given persistable. More...
 

Detailed Description

Manages respawning and respawn points.

Member Function Documentation

◆ ActivateRespawnPoint()

virtual void PlatformerPro.LevelManager.ActivateRespawnPoint ( string  respawnPoint)
virtual

Enables and actiavtes the respawn point.

Parameters
respawnPointRespawn point.

◆ ApplySaveData()

override void PlatformerPro.LevelManager.ApplySaveData ( object  t)
virtual

Applies the save data to the object.

Implements PlatformerPro.Persistable.

◆ ClearRespawns()

virtual void PlatformerPro.LevelManager.ClearRespawns ( )
virtual

Clear all respawn points (but dont reset level locks).

◆ CreateNewLevelManager()

static void PlatformerPro.LevelManager.CreateNewLevelManager ( )
staticprotected

Creates the level manager.

◆ DoDestroy()

virtual void PlatformerPro.LevelManager.DoDestroy ( )
protectedvirtual

Do the destroy actions.

◆ EnableRespawnPoint()

virtual void PlatformerPro.LevelManager.EnableRespawnPoint ( string  respawnPoint)
virtual

Enables a spawn point but doesn't set it as active.

◆ Exit()

void PlatformerPro.LevelManager.Exit ( )

Exit the scene.

◆ HandleCharacterLoaded()

virtual void PlatformerPro.LevelManager.HandleCharacterLoaded ( object  sender,
CharacterEventArgs  e 
)
protectedvirtual

Handles the character loaded event by setting the character.

◆ HandlePhaseChange()

virtual void PlatformerPro.LevelManager.HandlePhaseChange ( object  sender,
GamePhaseEventArgs  e 
)
protectedvirtual

◆ Init()

virtual void PlatformerPro.LevelManager.Init ( )
protectedvirtual

◆ IsUnlocked()

virtual bool PlatformerPro.LevelManager.IsUnlocked ( string  levelKey)
virtual

Check if the given level (or other object) is unlocked.

◆ LevelCompleted()

virtual void PlatformerPro.LevelManager.LevelCompleted ( )
virtual

Indicates level is complete.

◆ LoadScene()

virtual void PlatformerPro.LevelManager.LoadScene ( string  sceneName)
virtual

Load the given scene.

◆ LockLevel()

virtual void PlatformerPro.LevelManager.LockLevel ( string  levelKey)
virtual

Unlocks the given level (or object).

◆ OnLevelComplete()

virtual void PlatformerPro.LevelManager.OnLevelComplete ( string  levelName)
protectedvirtual

Raises the level complete event.

Parameters
levelNameName of complete level.

◆ OnRespawned()

virtual void PlatformerPro.LevelManager.OnRespawned ( Character  character,
int  playerId,
string  respawnPoint 
)
protectedvirtual

Raises the respawned event.

Parameters
respawnPointRespawn point.

◆ OnSceneLoaded()

virtual void PlatformerPro.LevelManager.OnSceneLoaded ( )
protectedvirtual

Raises the scene loaded event on Start.

◆ OnWillExitScene()

virtual void PlatformerPro.LevelManager.OnWillExitScene ( string  newLevelName)
protectedvirtual

Raises the level complete event.

Parameters
newLevelNameRespawn point.

◆ Rating()

virtual int PlatformerPro.LevelManager.Rating ( string  levelKey)
virtual

◆ ResetSaveData()

override void PlatformerPro.LevelManager.ResetSaveData ( )
virtual

Resets the save data back to default.

Implements PlatformerPro.Persistable.

◆ Respawn() [1/2]

virtual void PlatformerPro.LevelManager.Respawn ( Character  character)
virtual

Respawn the specified character at the currently active reswpawn point.

Parameters
characterCharacter.

◆ Respawn() [2/2]

virtual void PlatformerPro.LevelManager.Respawn ( Character  character,
string  respawnPoint 
)
virtual

Respawn the specified character at the specified respawn point.

Parameters
characterCharacter.
respawnPointRespawn point.

◆ SavedObjectType()

override System.Type PlatformerPro.LevelManager.SavedObjectType ( )
virtual

Get the type of object this Persistable saves.

Implements PlatformerPro.Persistable.

◆ UnlockLevel() [1/2]

virtual void PlatformerPro.LevelManager.UnlockLevel ( string  levelKey)
virtual

Unlocks the given level (or object).

◆ UnlockLevel() [2/2]

virtual void PlatformerPro.LevelManager.UnlockLevel ( string  levelKey,
int  completeRating 
)
virtual

Unlocks the given level (or object) and Sets a complete rating (i.e. snumber of stars, percentage, etc).

Member Data Documentation

◆ activeRespawnPoint

string PlatformerPro.LevelManager.activeRespawnPoint
protected

The currently active respawn point identifier.

◆ character

Character PlatformerPro.LevelManager.character
protected

Character to use for persistence events. Generally this is for resetting locks on game over.

◆ clearRespawnsOnComplete

bool PlatformerPro.LevelManager.clearRespawnsOnComplete = true

Should we clear all respawn points for this level on level complete?

◆ enabledRespawnPoints

List<string> PlatformerPro.LevelManager.enabledRespawnPoints
protected

List of all enabled respawn points.

◆ exitMenuScene

string PlatformerPro.LevelManager.exitMenuScene

Scene to load when user exits level select.

◆ instance

LevelManager PlatformerPro.LevelManager.instance
staticprotected

The instance.

◆ lastEnteredScene

string PlatformerPro.LevelManager.lastEnteredScene
protected

Stores the SceneManager name of the last entered scene.

◆ levelLockData

List<LevelLockData> PlatformerPro.LevelManager.levelLockData
protected

The level lock data.

◆ levelName

string PlatformerPro.LevelManager.levelName

Name of the current level

◆ PLAYER_PREF_KEY

const string PlatformerPro.LevelManager.PLAYER_PREF_KEY = "LevelManager"
static

Const key to append in front of level lock string.

◆ saveSceneName

bool PlatformerPro.LevelManager.saveSceneName = false

Should we save the name of the sceen to the saved scene data?

◆ sceneLoadedEvent

bool PlatformerPro.LevelManager.sceneLoadedEvent
staticprotected

Have we called the scene loaded event for this scene? Used to ensure we only call scene loaded once when the first character is loaded.

◆ sceneToLoadOnLevelComplete

string PlatformerPro.LevelManager.sceneToLoadOnLevelComplete

Should we automatically load another scene on level complete. Leave blank if there is a level complete screen which will do the loading.

◆ unlockLevelOnComplete

bool PlatformerPro.LevelManager.unlockLevelOnComplete = true

Unlock the level name automatically when level completes.

Property Documentation

◆ ActiveRespawnPoint

string PlatformerPro.LevelManager.ActiveRespawnPoint
get

Return the active resapwn point

◆ Character

override Character PlatformerPro.LevelManager.Character
getset

Gets the character.

◆ EnabledRespawnPoints

List<string> PlatformerPro.LevelManager.EnabledRespawnPoints
get

Get a copy of the list of enabled respawn points.

◆ Identifier

override string PlatformerPro.LevelManager.Identifier
get

Get a unique identifier to use when saving the data (for example this could be used for part of the file name or player prefs name).

◆ Instance

LevelManager PlatformerPro.LevelManager.Instance
staticgetprotected set

Gets a reference to this object.

◆ IsActive

bool PlatformerPro.LevelManager.IsActive
get

Has a respawn point been set?

◆ PlayerPrefsIdentifier

override string PlatformerPro.LevelManager.PlayerPrefsIdentifier
get

The player preference identifier.

◆ PreviousLevel

string PlatformerPro.LevelManager.PreviousLevel
staticgetset

Keeps track of the previous level.

◆ SaveData

override object PlatformerPro.LevelManager.SaveData
get

Gets the data to save.

Event Documentation

◆ LevelComplete

System.EventHandler<LevelEventArgs> PlatformerPro.LevelManager.LevelComplete

Event for level completed.

◆ Respawned

System.EventHandler<RespawnEventArgs> PlatformerPro.LevelManager.Respawned

Event for character respawn.

◆ SceneLoaded

System.EventHandler<SceneEventArgs> PlatformerPro.LevelManager.SceneLoaded

Event for scene load.

◆ WillExitScene

System.EventHandler<SceneEventArgs> PlatformerPro.LevelManager.WillExitScene

Sent when we will exit a scene.


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