Game Development Reference
In-Depth Information
C# users) or Create | Javascript (for Unity JavaScript users), and name it His-
core .
8. Double-click on the Hiscore script and add the following code:
// Unity JavaScript user:
#pragma strict
import System.Collections.Generic;
public class Hiscore extends MonoBehaviour {
protected var _hashKey : String =
"UNITYGAMEDEVELOPMENTHOTSHOT";
protected var _privateMaxUser : int;
protected var _users : List.<UserData>;
function get userLength() : int {
return (_users.Count < _privateMaxUser) ?
_users.Count : _privateMaxUser;
}
function Initialize ( maxUser : int ) {
_privateMaxUser = maxUser;
}
function LoadUserData () {
_users = new List.<UserData>();
}
function SaveUserData ( user : UserData ) { }
function GetUserDataAt ( index : int ) : UserData {
return _users[index];
}
function SortByScore () {
_users.Sort();
_users.Reverse();
}
}
Search WWH ::




Custom Search