Game Development Reference
In-Depth Information
Prepare for Lift Off
Before we start, we need to know the basic parameters we need to include in the high-
score table. We will need the order number, username, and the user score, as shown in the
following screenshot:
Engage Thrusters
We will start by creaing the UsersData class to contain the user data and funcions, which
will load and save the user data to the local machine using PlayerPref :
1. In Unity, go to Assets | Create | Javascript , name it UsersData and double-click to
open MonoDevelop , and then replace the script as follows (you should remove all
the exising script that is automaically created with Unity):
class UsersData {
//Game Key - to make sure that each object has different key set
public var keylocal : String = "ShooterLocal";
private var s_keyScore : String = "Score";
private var s_keyName : String = "Name";
private var s_name : String;
private var int_score : int;
private var as_randomNames : String[] = ["Antony", "John",
"Will", "Kate", "Jill"]; //To get a random name
//Setting the user name and score
public function Init(name : String, score : int) : void {
int_score = score;
s_name = name;
}
 
Search WWH ::




Custom Search