public static Dictionary <int, SkillConfigInfo> ReadSkillConfigFromXml(string xmlFilePath) { Dictionary <int, SkillConfigInfo> skillInfoDic = new Dictionary <int, SkillConfigInfo>(); XmlDocument xmlDoc = null; //TextAsset xmlfile = Resources.Load(xmlFilePath) as TextAsset; //UtilityHelper.LogFormat("begin reading skill xml file from {0}", xmlFilePath); Object asset = Resources.Load(xmlFilePath); ResourceUnit xmlfileUnit = new ResourceUnit(null, 0, asset, null, ResourceType.ASSET); TextAsset xmlfile = xmlfileUnit.Asset as TextAsset; if (!xmlfile) { return(skillInfoDic); } UtilityHelper.Log("read skill xml successful"); xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlfile.text); XmlNodeList infoNodeList = xmlDoc.SelectSingleNode("SkillCfg").ChildNodes; for (int i = 0; i < infoNodeList.Count; i++) {//(XmlNode xNode in infoNodeList) if ((infoNodeList[i] as XmlElement).GetAttributeNode("un32ID") == null) { continue; } string typeName = (infoNodeList[i] as XmlElement).GetAttributeNode("un32ID").InnerText; //Debug.LogError(typeName); SkillConfigInfo skillInfo = new SkillConfigInfo(); skillInfo.id = (int)Convert.ToUInt32(typeName); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { #region 搜索 switch (xEle.Name) { case "Name": { skillInfo.name = Convert.ToString(xEle.InnerText); } break; case "SkillIcon": { skillInfo.icon = Convert.ToString(xEle.InnerText); } break; case "ReleaseRadius": { skillInfo.releaseRadius = Convert.ToInt32(xEle.InnerText); } break; case "EffectRadius": { skillInfo.effectRadius = Convert.ToInt32(xEle.InnerText); } break; case "DamageType": { skillInfo.damageType = Convert.ToInt32(xEle.InnerText); } break; case "TargetType": { skillInfo.targetType = Convert.ToInt32(xEle.InnerText); } break; case "mainValue": { skillInfo.mainValue = Convert.ToInt32(xEle.InnerText); } break; case "ReleaseAction": { skillInfo.action = Convert.ToString(xEle.InnerText); } break; case "ReleaseSound": { skillInfo.sound = Convert.ToString(xEle.InnerText); } break; case "info": skillInfo.info = Convert.ToString(xEle.InnerText); break; } #endregion } skillInfoDic.Add(skillInfo.id, skillInfo); //Debug.LogError("add buff" + buffInfo.BuffID); } return(skillInfoDic); }
public static Dictionary <int, ComboConfigInfo> ReadSkillComboConfigFromXml(string xmlFilePath) { //UtilityHelper.Log("begin reading combo xml file"); //TextAsset xmlfile = Resources.Load(xmlFilePath) as TextAsset; XmlDocument xmlDoc = null; Dictionary <int, ComboConfigInfo> comboInfoDic = new Dictionary <int, ComboConfigInfo>(); Object asset = Resources.Load(xmlFilePath); ResourceUnit xmlfileUnit = new ResourceUnit(null, 0, asset, null, ResourceType.ASSET); TextAsset xmlfile = xmlfileUnit.Asset as TextAsset; if (!xmlfile) { return(comboInfoDic); } UtilityHelper.Log("read combo xml successful"); xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlfile.text); XmlNodeList infoNodeList = xmlDoc.SelectSingleNode("ComboSkill").ChildNodes; for (int i = 0; i < infoNodeList.Count; i++) {//(XmlNode xNode in infoNodeList) if ((infoNodeList[i] as XmlElement).GetAttributeNode("un32ID") == null) { continue; } string typeName = (infoNodeList[i] as XmlElement).GetAttributeNode("un32ID").InnerText; //Debug.LogError(typeName); ComboConfigInfo comboInfo = new ComboConfigInfo(); comboInfo.id = (int)Convert.ToUInt32(typeName); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { #region 搜索 switch (xEle.Name) { case "Name": { comboInfo.name = Convert.ToString(xEle.InnerText); } break; case "skill1": { comboInfo.skill1 = Convert.ToInt32(xEle.InnerText); } break; case "skill2": { comboInfo.skill2 = Convert.ToInt32(xEle.InnerText); } break; case "skill3": { comboInfo.skill3 = Convert.ToInt32(xEle.InnerText); } break; case "effect": { comboInfo.effect = Convert.ToInt32(xEle.InnerText); } break; } #endregion } comboInfoDic.Add(i, comboInfo); //UtilityHelper.LogFormat("add {0} with skill1 = {1}, skill2 = {2}, skill3 = {3}", comboInfo.id, comboInfo.skill1, //comboInfo.skill2, comboInfo.skill3); } return(comboInfoDic); }
public static GridUnit[] ReadScene1LocationFromXml(BattleMap map, string xmlFilePath, int teamKind, int gridCount) { GridUnit[] bornGrids = new GridUnit[gridCount]; int x = 0, y = 0; //GridUnit tmpGrid = new GridUnit(map, 0, 0); XmlDocument xmlDoc = null; //TextAsset xmlfile = Resources.Load(xmlFilePath) as TextAsset; //UtilityHelper.LogFormat("begin reading skill xml file from {0}", xmlFilePath); Object asset = Resources.Load(xmlFilePath); ResourceUnit xmlfileUnit = new ResourceUnit(null, 0, asset, null, ResourceType.ASSET); TextAsset xmlfile = xmlfileUnit.Asset as TextAsset; if (!xmlfile) { return(bornGrids); } UtilityHelper.Log("read scene 1 location xml successful"); xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlfile.text); XmlNodeList infoNodeList = xmlDoc.SelectSingleNode("Locations").ChildNodes; for (int i = 0; i < infoNodeList.Count; i++) {//(XmlNode xNode in infoNodeList) if ((infoNodeList[i] as XmlElement).GetAttributeNode("un32ID") == null) { continue; } string typeName = (infoNodeList[i] as XmlElement).GetAttributeNode("un32ID").InnerText; int id = (int)Convert.ToUInt32(typeName); if (id != teamKind) { continue; } foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { switch (xEle.Name) { case "row": { x = Convert.ToInt32(xEle.InnerText); } break; case "column": { y = Convert.ToInt32(xEle.InnerText); } break; } } //tmpGrid.localPosition = new Vector3((tmpGrid.column + 1)* EGameConstL.Map_GridWidth, -(tmpGrid.row + 1)* EGameConstL.Map_GridOffsetY, 0); //Debug.LogFormat("i = {0}, row = {1}, column = {2}, position = {3}", i, tmpGrid.row, tmpGrid.column, tmpGrid.localPosition); //Debug.LogFormat("i = {0}, row = {1}, column = {2}, position = {3}", i, x, y, map.mapGrids[y, x].localPosition); if (teamKind == 0) { bornGrids[i] = map.mapGrids[y, x]; } else if (teamKind == 1) { bornGrids[i - 1] = map.mapGrids[y, x]; } } return(bornGrids); }