Ignition / PlayerData
Namespace
Playniax.IgnitionScript can be found in
Assets/Playniax/Framework/Ignition/Framework/Core/Scripts/PlayerData.cs
Class PlayerData
DescriptionPlayerData 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 fields | Description |
---|
int coins | Number of coins collected by the player |
int collectables | Number of collectibles collected by the player |
float fuel = 50 | Current fuel level of the player's vehicle |
int fuelScale = 100 | Maximum fuel capacity of the player's vehicle |
int lives = defaultLives | Remaining lives of the player |
string name = "" | Name of the player character |
int scoreboard | Current score on the scoreboard |
Config custom = new Config() | Custom data storage. |
Public Methods | Description |
---|
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 |