Game Development Reference
In-Depth Information
obj_localHiScore.SaveGame(TimeScoreUI.int_currentScore,
userName); //Submitting to the local score
//Submitting to server
obj_serverHiScore.SendScore(TimeScoreUI.int_currentScore,
userName);
}
}
//Creating the Local Hi-Score page button
if (GUI.Button(new Rect((Screen.width - 240)*0.5, (Screen.
height*0.1) + 240, 240, 30), "LOCAL HI-SCORE")) {
e_page = Page.LOCALSCORE;
}
//Creating the Server Hi-Score page button
if (GUI.Button(new Rect((Screen.width - 240)*0.5, (Screen.
height*0.1) + 280, 240, 30), "SERVER HI-SCORE")) {
//TODO: Loading the score data from server here
obj_serverHiScore.GetScores();
e_page = Page.SERVERSCORE;
}
10. This will submit and load the score from the server. Then, we go to the
ServerScorePage() funcion and replace the code as follows:
//Loading score from server
private function ServerScorePage() : void {
//Creating the background box
GUI.Box(new Rect(Screen.width*0.1, Screen.height*0.1, Screen.
width * 0.8, Screen.height * 0.8), "SERVER HI-SCORE", GUI.skin.
GetStyle("Box2"));
//TODO: Checking is the loader completed
if (obj_serverHiScore.IsLoaded()) {
var int_numUsers : int = obj_serverHiScore.GetUserLength();
if (int_numUsers >= maxUsers) {
int_numUsers = maxUsers;
}
scrollPositionS = GUI.BeginScrollView (new Rect ((Screen.width
- 320)*0.5, (Screen.height*0.1) + 80, 320, 180), scrollPositionS,
new Rect (0, 0, 300, 30*int_numUsers));
for (var i: int = 0; i < int_numUsers; i++) {
//Setting the number of the user
GUI.Label(new Rect(0, i * 30, 35, 30), (i+1).ToString() +
".");
//TODO: Showing the user name and score here
GUI.Label(new Rect(35, i * 30, 120, 30), obj_
serverHiScore.GetNameData(i));
GUI.Label(new Rect(155, i * 30, 145, 30), GlobalFunction.
addCommasInt(obj_serverHiScore.GetScoreData(i)), GUI.skin.
GetStyle("Score"));
 
Search WWH ::




Custom Search