protected bool LoadFromXmlFile(string tFileName) { TextAsset tTextAsset = null; tTextAsset = Resources.Load <TextAsset>(tFileName) as TextAsset; if (null == tTextAsset) { return(false); } mpTxtString.text = tTextAsset.text; XmlDocument tDoc = new XmlDocument(); tDoc.LoadXml(tTextAsset.text); CStageInfo tStageInfo = null; CUnitInfo tUnitInfo = null; XmlElement tElementRoot = tDoc["response"]; mStageInfoBundle.stage_info = new List <CStageInfo>(); foreach (XmlElement tElementStageInfoList in tElementRoot.ChildNodes) { foreach (XmlElement tElementStageInfo in tElementStageInfoList.ChildNodes) { tStageInfo = null; tStageInfo = new CStageInfo(); tStageInfo.id = Convert.ToInt32(tElementStageInfo.ChildNodes[0].InnerText); tStageInfo.total_enemy_count = Convert.ToInt32(tElementStageInfo.ChildNodes[1].InnerText); if (tElementStageInfo.ChildNodes[2].ChildNodes.Count > 0) { tStageInfo.unit_info = new List <CUnitInfo>(); foreach (XmlElement tElementUnitInfo in tElementStageInfo.ChildNodes[2]) { tUnitInfo = null; tUnitInfo = new CUnitInfo(); tUnitInfo.x = Convert.ToInt32(tElementUnitInfo.ChildNodes[0].InnerText); tUnitInfo.y = Convert.ToInt32(tElementUnitInfo.ChildNodes[1].InnerText); tStageInfo.unit_info.Add(tUnitInfo); } } mStageInfoBundle.stage_info.Add(tStageInfo); } } return(false); }
public class CUnit // TypeDefIndex: 3973 public static float Calc_AttackSpeed(CUnitInfo info); // 0x8CDF91
protected bool LoadStageXmlFile(string tFileName) { TextAsset tTextAsset = null; tTextAsset = Resources.Load <TextAsset>(tFileName) as TextAsset; if (null == tTextAsset) { return(false); } XmlDocument tDoc = new XmlDocument(); tDoc.LoadXml(tTextAsset.text); CStageInfo tStageInfo = null; CUnitInfo tUnitINfo = null; XmlElement tElementRoot = tDoc["response"]; mStageInfoBundle.mStageInfoList = new List <CStageInfo>(); foreach (XmlElement tElementStageInfoList in tElementRoot.ChildNodes) { foreach (XmlElement tElementStageInfo in tElementStageInfoList.ChildNodes) { tStageInfo = null; tStageInfo = new CStageInfo(); tStageInfo.mId = System.Convert.ToInt32(tElementStageInfo.ChildNodes[0].InnerText); tStageInfo.mEnemyCount = System.Convert.ToInt32(tElementStageInfo.ChildNodes[1].InnerText); if (tElementStageInfo.ChildNodes[2].ChildNodes.Count > 0) { tStageInfo.mUnitInfoList = new List <CUnitInfo>(); foreach (XmlElement tElementUnitInfo in tElementStageInfo.ChildNodes[2]) { tUnitINfo = null; tUnitINfo = new CUnitInfo(); tUnitINfo.mX = System.Convert.ToInt32(tElementUnitInfo.ChildNodes[0].InnerText); tUnitINfo.mY = System.Convert.ToInt32(tElementUnitInfo.ChildNodes[1].InnerText); tUnitINfo.mZ = System.Convert.ToInt32(tElementUnitInfo.ChildNodes[2].InnerText); tStageInfo.mUnitInfoList.Add(tUnitINfo); } } mStageInfoBundle.mStageInfoList.Add(tStageInfo); } } foreach (CStageInfo tRyuStageINfo in this.mStageInfoBundle.mStageInfoList) { Debug.Log("stage_info id : " + tRyuStageINfo.mId.ToString()); Debug.Log("stage_info total Enemy Count : " + tRyuStageINfo.mEnemyCount.ToString()); foreach (CUnitInfo tRyuUnitInfo in tRyuStageINfo.mUnitInfoList) { Debug.Log("unit_info x: " + tRyuUnitInfo.mX.ToString()); Debug.Log("unit_info y: " + tRyuUnitInfo.mY.ToString()); } Debug.Log("---------------------------------"); } return(true); }