Game Development Reference
In-Depth Information
Engage thrusters
Let's create the
ServerHiScore
script first using the following steps:
1. Navigate to
Chapter8
|
Scripts
|
C#
|
Hiscore
(for C# users) or
Chapter8
|
Scripts
|
Javascript
|
Hiscore
(for Unity JavaScript users) and right-click and go
to
Create
|
C# Script
(for C# users) or
Create
|
Javascript
. Name it
Server-
Hiscore
and double-click to open the
ServerHiscore
file.
2. First, we will start coding at the beginning of the
ServerHiscore
script, as
shown in the following code:
//Unity JavaScript user:
#pragma strict
class ServerHiscore extends Hiscore
{
private var _wwwForm : WWWForm;
private var _isLoaded : boolean;
private var _phpUrl : String;
function get isLoaded () : boolean {
return _isLoaded;
}
function Initialize ( maxUser : int , phpUrl :
String ) {
super.Initialize(maxUser);
_phpUrl = phpUrl;
}
}
// C# user:
using UnityEngine;
using System.Collections;
public class ServerHiscore : Hiscore
{
public delegate void CallBackFunction ( string data
);
WWWForm _wwwForm;