//The following method is found in GameManager.cs and is called by newly spawned tanks in order to retrieve information regarding what stats their bases and towers provide them with. The method is generically typed in order to allow it to retrieve both integer and floating point values. public T GetTankStat(string baseOrTower, string objectName, string statName) where T : IComparable { foreach (XmlNode node in statsXML.SelectNodes("//" + baseOrTower)) { if (node.Attributes["Name"].Value == objectName) { T returnVar; try { returnVar = (T)Convert.ChangeType(node.Attributes[statName].Value, typeof(T)); //Value successfully converted } catch { print("Value could not be converted, returning default value"); returnVar = (T)Convert.ChangeType(statsXML.SelectSingleNode("/" + baseOrTower + "s/Default").Attributes[statName].Value, typeof(T)); //Value could not be converted, returning default value } return returnVar; } } print(objectName + ": Item " + statName + " not found, returning default value"); return (T)Convert.ChangeType(statsXML.SelectSingleNode("/Components/" + baseOrTower + "s/Default").Attributes[statName].Value, typeof(T)); //Item not found, returning default value }