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

Very simple class for managing a basic score or statistic. More...

Public Member Functions

void AddScore (int amount)
 Adds to the score. Use a negative number to subtract. More...
 
void ResetScore ()
 Resets the score. More...
 

Static Public Member Functions

static ScoreManager GetInstanceForType (string scoreType)
 Get the instance More...
 
static void PersistScores (string scoreType, bool persist)
 Call this to change persistence for the given score manager. By default scores are not saved so will be reset when player exits the game. More...
 

Public Attributes

string scoreType
 The type of the score. More...
 
bool saveScoreToPreferences
 Should we save the score? More...
 

Protected Member Functions

void OnScoreChanged (int change)
 Raises the score changed event. More...
 
void Init (string scoreType)
 Init the instance. More...
 
virtual void Save ()
 Save the score to player prefs, override if you want to save elsewhere. More...
 
virtual void Load ()
 Load the score from player prefs, override if you want to load from elsewhere. More...
 

Static Protected Member Functions

static ScoreManager CreateNewScoreManager (string scoreType)
 Creates the score manager. More...
 

Protected Attributes

int currentScore
 Stores the current score. More...
 
ScoreEventArgs scoreEventArgs
 Cached copy of the score event args. More...
 

Static Protected Attributes

const string PP_SCORE_ID = "PP_SCOREMANAGER"
 Uniqifier for the save player prefs key. More...
 
static List< ScoreManagerinstances
 The score managers. More...
 
static List< string > instanceTypes
 The score manager types corresponds to the order of score managers. More...
 

Properties

int Score [get]
 Gets the score. More...
 

Events

System.EventHandler< ScoreEventArgsScoreChanged
 Occurs when score changes. More...
 

Detailed Description

Very simple class for managing a basic score or statistic.

Member Function Documentation

◆ AddScore()

void PlatformerPro.ScoreManager.AddScore ( int  amount)

Adds to the score. Use a negative number to subtract.

Parameters
amountAmount.

◆ CreateNewScoreManager()

static ScoreManager PlatformerPro.ScoreManager.CreateNewScoreManager ( string  scoreType)
staticprotected

Creates the score manager.

◆ GetInstanceForType()

static ScoreManager PlatformerPro.ScoreManager.GetInstanceForType ( string  scoreType)
static

Get the instance

◆ Init()

void PlatformerPro.ScoreManager.Init ( string  scoreType)
protected

Init the instance.

Parameters
scoreTypeScore type.

◆ Load()

virtual void PlatformerPro.ScoreManager.Load ( )
protectedvirtual

Load the score from player prefs, override if you want to load from elsewhere.

◆ OnScoreChanged()

void PlatformerPro.ScoreManager.OnScoreChanged ( int  change)
protected

Raises the score changed event.

Parameters
changeChange.

◆ PersistScores()

static void PlatformerPro.ScoreManager.PersistScores ( string  scoreType,
bool  persist 
)
static

Call this to change persistence for the given score manager. By default scores are not saved so will be reset when player exits the game.

Parameters
scoreTypeScore type.
persistIf set to true then persist, otherwise don't.

◆ ResetScore()

void PlatformerPro.ScoreManager.ResetScore ( )

Resets the score.

◆ Save()

virtual void PlatformerPro.ScoreManager.Save ( )
protectedvirtual

Save the score to player prefs, override if you want to save elsewhere.

Member Data Documentation

◆ currentScore

int PlatformerPro.ScoreManager.currentScore
protected

Stores the current score.

◆ instances

List<ScoreManager> PlatformerPro.ScoreManager.instances
staticprotected

The score managers.

◆ instanceTypes

List<string> PlatformerPro.ScoreManager.instanceTypes
staticprotected

The score manager types corresponds to the order of score managers.

◆ PP_SCORE_ID

const string PlatformerPro.ScoreManager.PP_SCORE_ID = "PP_SCOREMANAGER"
staticprotected

Uniqifier for the save player prefs key.

◆ saveScoreToPreferences

bool PlatformerPro.ScoreManager.saveScoreToPreferences

Should we save the score?

◆ scoreEventArgs

ScoreEventArgs PlatformerPro.ScoreManager.scoreEventArgs
protected

Cached copy of the score event args.

◆ scoreType

string PlatformerPro.ScoreManager.scoreType

The type of the score.

Property Documentation

◆ Score

int PlatformerPro.ScoreManager.Score
get

Gets the score.

The score.

Event Documentation

◆ ScoreChanged

System.EventHandler<ScoreEventArgs> PlatformerPro.ScoreManager.ScoreChanged

Occurs when score changes.


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