Game Development Reference
In-Depth Information
4. Then, we will create the ConvertStringtoInt() funcion, which will convert
the string type to integer type as well as create the Name() , Score() , and
UserLength() funcions as follows:
//Converting string to int
private static int ConvertStringtoInt( string s) {
int j;
bool result = System.Int32.TryParse(s, out j);
if (true == result) {
return j;
} else {
Debug.Log("Error...");
return 0;
}
}
//Getting user name from index
public static string Name ( int index) {
return names[index];
}
//Getting user score from index
public static int Score ( int index) {
return scores[index];
}
//Getting user length
public static int UserLength () {
return userLength;
}
}
Objective Complete - Mini Debriefing
In this secion, we basically just created the C# XMLParser script, to parse the XML string
that we loaded from the server, and then we stored the user's data in this class to use it at a
later stage.
First, we used the static keyword for this class, because we want it to be accessible from
the enire project. Then, we created the XmlDocument and XmlNode parameters to hold the
XML data that we want to parse. Then, we have one array of string and one array of int
to store the users' name and score. And the last parameter is to store the length of the users
that we got from the XML data.
 
Search WWH ::




Custom Search