Game Development Reference
In-Depth Information
Creating the UserData and Hiscore scripts
In the first section, we will create the
UserData
script, which will collect the username
and score. This script will inherit from the
IComparable<T>
interface, which is a cus-
tom comparison method in the .NET library that a value type or class implements to create
a type-specific comparison method to order instances. This class will have the
Com-
pareTo()
function, which will be used to sort users by their score. Then, we will add the
UserData
object in the
UIHiscore
script and set up the input text field for the player's
name.
Note
For more information about the
IComparable<T>
interface, visit the following links:
Then, we will create the
Hiscore
script, which will be the super class of both the
LocalHiscore
and
ServerHiscore
scripts. The
Hiscore
script will include the
necessary variables such as the array of the
UserData
,
Save
and
Load
functions,
Sort
function, and so on.