Game Development Reference
In-Depth Information
Then, we created the
ParseXMLData()
function, which will call the
XMLParser.
Parse()
function to parse the XML string data that returns from the server, and then, we
stored it in the
XMLParser
class as the
UserData
array. Then, we set the
UserData
array to the list of
UserData
using
_users.AddRange(XMLParser.users);
. At
last, we set
_isLoaded
to
true
, which means that the data has been loaded.
Next, we created the
LoadUserData()
function, which is very similar to the
SaveUserData()
function, except that we only send one parameter to PHP, which is
the
action
field to tell PHP that we want
GetScore
. Also, in the
StartCoroutine()
function, we put the callback function in the
WaitingForRe-
sponse()
function, which is
ParseXMLData
. This function will be called after the
loading is completed.
Then, we go back to the
UIHiScore
script and add the
ServerHiScore
object to
show the server hi-score data in the UI.