Game Development Reference
In-Depth Information
7. Now, we finished creating the
ServerHiscore
script. Next, we will go to the
UIHiscore
script to add the code that will show all users' scores from the serv-
er. First, we will add the script to initialize the server hi-score table, as shown in
the following highlighted code:
// Unity JavaScript user:
…
…
private var _scrollLocal : Vector2 = Vector2.zero;
var phpUrl : String = "http://www.jatewit.com/Packt/
HiScore.php";
private var _scrollServer : Vector2 = Vector2.zero;
private var _serverHiscore : ServerHiscore;
…
function Awake () {
_localHiscore = GetComponent.<LocalHiscore>();
if (_localHiscore == null) {
_localHiscore =
gameObject.AddComponent.<LocalHiscore>();
}
_serverHiscore = GetComponent.<ServerHiscore>();
if (_serverHiscore == null) {
_serverHiscore =
gameObject.AddComponent.<ServerHiscore>();
}
}
function Start () {
…
_localHiscore.Initialize(maxUser);
_serverHiscore.Initialize(maxUser,phpUrl);
}
// C# user:
…
…
Vector2 _scrollLocal = Vector2.zero;
public string phpUrl = "http://www.jatewit.com/Packt/
HiScore.php";