|
P3-SDK 0.9
P3 Software Development Kit
|
Player Data is data that describes the player's state during a game. It is reset at the beginning of each game, and data is typically saved whenever the player makes something happen in the game. It is often used to hold things like the player's score as well as the state of various properties in the modes the player has activated. The data might be used for display or summary information, just as it could be used to restore the previous mode state if a player restarts the same mode during the game.
Player Data is stored inside of Player instances in the form of AttributeValues. Data is stored through calls to the player's SaveData(key, value) methods, where the key is a string, and the value can be an int, long, float, double, bool, or string.
Data is retrieved by getting the associated AttributeValue and converting it to the correct type. It's prudent to make sure the associated AttributeValue actually exists before trying to read it:
To streamline the retrieval process by skipping the ContainsKey check, the type conversion, and the default assignment, helper methods are provided to do all of that in one command. The type of the second parameter (the default value) determines the return type of the GetData method.