Ignition / PlayerData

Namespace Playniax.Ignition

Script can be found in Assets/Playniax/Framework/Ignition/Framework/Core/Scripts/PlayerData.cs

Class PlayerData

Description

PlayerData can be used to temporarily store data of the game like lives, name or score of the player.

Examples of built-in data fields are: lives, name and scoreboard.

Custom fields can be added to custom and supports floats, integers, booleans and strings.

This information will not be saved, but it will persist and remain available throughout scenes unless manually reset or reset by the EasyGameUI.

Example(s):

Set name of the player : PlayerData.Get(0).name = "Tony";

Increase the score of the player : PlayerData.Get(0).scoreboard += 100;

Custom variable : PlayerData.Get(0).custom.SetBool("invincible", true);

* The zero used with the Get(0) command represents the player's index (where player 1 is 0, player 2 is 1, and so forth).

Public fieldsDescription
int coinsNumber of coins collected by the player
int collectablesNumber of collectibles collected by the player
float fuel = 50Current fuel level of the player's vehicle
int fuelScale = 100Maximum fuel capacity of the player's vehicle
int lives = defaultLivesRemaining lives of the player
string name = ""Name of the player character
int scoreboardCurrent score on the scoreboard
Config custom = new Config()Custom data storage.

Public MethodsDescription
static PlayerData Get(int index = 0)Returns the PlayerData for the player by index.
static PlayerData Get(string name)Returns the PlayerData for the player by name.
static void Reset(int lives)Reset to defaults
static void SetLives(int lives)Set number of lives