private void parseXMLToGames() { levels = new List <XMLLevel>(); //process groups foreach (XmlElement node in xmlDoc.SelectNodes("//Games/Game")) { int sides = int.Parse(node.SelectSingleNode("sides").InnerText); XmlNodeList xmlGroups = node.SelectNodes("Group"); XMLGroup[] groups = new XMLGroup[xmlGroups.Count]; int index = 0; foreach (XmlElement xmlgroup in xmlGroups) { Debug.Log("game: " + index); string[] g = xmlgroup.InnerText.Split(','); XMLPosition[] positions = new XMLPosition[g.Length]; for (int i = 0; i < g.Length; i++) { string[] v = g[i].Split(' '); positions[i] = new XMLPosition(int.Parse(v[0]), int.Parse(v[1])); } groups[index] = new XMLGroup(positions); index++; } //process the matches XmlNode xmlMatch = node.SelectSingleNode("Match"); string[] m = xmlMatch.InnerText.Split(','); XMLMatch[] matches = new XMLMatch[m.Length]; for (int i = 0; i < matches.Length; i++) { string[] v = m[i].Split(' '); int pos = int.Parse(v[1]); int value = int.Parse(v[2]); XMLMATCHTYPE type = convert(v[0]); matches[i] = new XMLMatch(pos, value, type); } levels.Add(new XMLLevel(sides, groups, matches)); } }
public XMLMatch(int pos, int value, XMLMATCHTYPE type) { this.pos = pos; this.value = value; this.type = type; }