public void GetDestroyableInfoFromXML() { destroyableInfoDictionary = new Dictionary<string, DestroyableInfo>(); TextAsset xmlAsset = Resources.Load("Info/DestroyableInfo") as TextAsset; XmlDocument xmlDoc = new XmlDocument(); if (xmlAsset) xmlDoc.LoadXml(xmlAsset.text); foreach (XmlNode node in xmlDoc.ChildNodes[0]) { int rewardEnergy = 0; int cost = 0; foreach (XmlNode childVal in node.ChildNodes) { switch (childVal.Name) { case "rewardEnergy": rewardEnergy = int.Parse(childVal.InnerText); break; case "cost": cost = int.Parse(childVal.InnerText); break; } } DestroyableInfo destroyableInfo = new DestroyableInfo(cost, rewardEnergy); destroyableInfoDictionary.Add(node.Name, destroyableInfo); } }
protected void Start() { library = GameObject.FindObjectOfType<Library>(); destroyableInfo = Info.GetDestroyableInfo(this.GetType().Name); if(destroyableInfo == null) destroyableInfo = Info.GetDestroyableInfo("Light"); }
protected void Start() { library = GameObject.FindObjectOfType <Library>(); destroyableInfo = Info.GetDestroyableInfo(this.GetType().Name); if (destroyableInfo == null) { destroyableInfo = Info.GetDestroyableInfo("Light"); } }
public void GetDestroyableInfoFromXML() { destroyableInfoDictionary = new Dictionary <string, DestroyableInfo>(); TextAsset xmlAsset = Resources.Load("Info/DestroyableInfo") as TextAsset; XmlDocument xmlDoc = new XmlDocument(); if (xmlAsset) { xmlDoc.LoadXml(xmlAsset.text); } foreach (XmlNode node in xmlDoc.ChildNodes[0]) { int rewardEnergy = 0; int cost = 0; foreach (XmlNode childVal in node.ChildNodes) { switch (childVal.Name) { case "rewardEnergy": rewardEnergy = int.Parse(childVal.InnerText); break; case "cost": cost = int.Parse(childVal.InnerText); break; } } DestroyableInfo destroyableInfo = new DestroyableInfo(cost, rewardEnergy); destroyableInfoDictionary.Add(node.Name, destroyableInfo); } }