Game Development Reference
In-Depth Information
7. Now, we will go back to the HiScore.js script to add some code in it and make it
work. In the HiScore.js script before the Awake() funcion, add the highlighted
code as follows:
private var obj_localHiScore : LocalHiScore; //Creating the
LocalHiScore Object
private var obj_serverHiScore : ServerHiScore; //Creating the
ServerHiScore Object
public function Start() : void {
//Initializing
8. Go inside the Start() funcion and type the highlighted code:
public function Start() : void {
//Initializing
e_page = Page.GAMEOVER;
int_items = 10;
scrollPosition = Vector2.zero;
b_isClickRestart = false;
b_isClickSubmit = false;
//Creating a Local Hiscore Object
obj_localHiScore = new LocalHiScore();
//Setting the maximum scores to show on the table & loading the
local high score data here
obj_localHiScore.SetMaxUser(int_items);
//Creating a Server Hiscore Object
obj_serverHiScore = GetComponent.<ServerHiScore>();
}
9. Now we have the ServerHiScore object created, we need to go to the
GameoverPage() funcion inside the SERVER HI-SCORE buton page code,
and type the following highlighted code:
if (b_isClickSubmit == false) {
GUI.Label(new Rect((Screen.width - 300)*0.5, (Screen.
height*0.1) + 80, 300, 25), "Enter Your Name", GUI.skin.
GetStyle("Text1"));
//Creating the input text field to get the player name
userName = GUI.TextField(new Rect((Screen.width - 240)*0.5,
(Screen.height*0.1) + 120, 240, 40), userName, 8);
//Submit button
if (GUI.Button(new Rect((Screen.width - 240)*0.5, (Screen.
height*0.1) + 200, 240, 30), "SUBMIT")) {
b_isClickSubmit = true;
//TODO: Submitting both local and server high score here
 
Search WWH ::




Custom Search