Game Development Reference
In-Depth Information
//Checking to see if the value already exist
var s_newKey : String = keylocal + s_keyName + index.
ToString();
if (PlayerPrefs.HasKey(s_newKey)) {
return PlayerPrefs.GetString(keylocal + s_keyName + index.
ToString());
} else {
//If no key exist return random name;
var int_random : int = Random.Range(0, as_randomNames.
length);
return as_randomNames[int_random];
}
}
}
4. Next, we will coninue creaing the next script, so let's create the LocalHiScore
script and replace it as follows:
class LocalHiScore {
private var int_maxUser : int;
private var int_minScore : int;
private var as_users : UsersData[]; //To get all loader data
name
}
5. Here, we set up the LocalHiScore script to have class keyword, which is
similar to the UsersData script, because we don't need this class to inherit from
MonoBehaviour . We also set up all necessary parameters for this class. Next, we
will add the setup funcion and load funcion to this class. Let's add the following
highlighted code:
class LocalHiScore {
private var int_maxUser : int;
private var int_minScore : int;
private var as_users : UsersData[]; //To get all loader data
name
//Setting the maximum user to display on the menu
//Loading the user data and store it in here
public function SetMaxUser (maxUser : int ) : void
int_maxUser = maxUser;
//Loading all the users data from the local machine
LoadGameLocal();
}
public function LoadGameLocal () : void {
 
Search WWH ::




Custom Search