//读取路径配置表 public ArrayList loadPathXmlToArray() { //保存路径 string filepath = "Config/Map/MapPath"; string _result = Resources.Load(filepath).ToString(); ArrayList PathList = new ArrayList(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(_result); XmlNodeList nodeList = xmlDoc.SelectSingleNode("PathList").ChildNodes; foreach (XmlElement recipe in nodeList) { MapPathManager.Path _path = new MapPathManager.Path(); //读取node内属性,把string转化为对应的属性 if (recipe.GetAttribute("Map") != "") { _path.Map = int.Parse(recipe.GetAttribute("Map")); } if (recipe.GetAttribute("Name") != "") { _path.Name = recipe.GetAttribute("Name"); } if (recipe.GetAttribute("Next") != "") { string str_next = recipe.GetAttribute("Next"); if (str_next != "") { string[] str_temp = str_next.Split(','); _path.Next = new int[str_temp.Length]; for (int i = 0; i < _path.Next.Length; i++) { _path.Next[i] = int.Parse(str_temp[i]); } } } if (recipe.GetAttribute("Pre") != "") { string str_pre = recipe.GetAttribute("Pre"); if (str_pre != "") { string[] str_temp = str_pre.Split(','); _path.Pre = new int[str_temp.Length]; for (int i = 0; i < _path.Pre.Length; i++) { _path.Pre[i] = int.Parse(str_temp[i]); } } } if (recipe.GetAttribute("Price") != "") { _path.Price = int.Parse(recipe.GetAttribute("Price")); } else { _path.Price = 0; } //添加进itemList中 PathList.Add(_path); } return(PathList); }
void InitPlayerInfoData() { playerinfo.Languege = "zh"; playerinfo.MineCount = 0; playerinfo.Money = 0; playerinfo.MapInfoList = new ArrayList(); playerinfo.MaterialInfoList = new MaterialInfo(); playerinfo.MaterialInfoList.Items = new ArrayList(); playerinfo.MaterialInfoList.Minds = new ArrayList(); playerinfo.MaterialInfoList.SpecialItems = new ArrayList(); playerinfo.MaterialInfoList.Propertys = new ArrayList(); playerinfo.SenceInfoList = new ArrayList(); playerinfo.CompleteEvents = new ArrayList(); playerinfo.QuestList = new ArrayList(); playerinfo.CompleteQuests = new ArrayList(); //初始材料 foreach (Materiral.Items m in Materiral.GetItemList()) { ItemsInfo _m = new ItemsInfo(); _m.ID = m.ID; _m.PutCount = 0; _m.SellCount = 0; _m.RecipeCount = 0; _m.CollectCount = 0; playerinfo.MaterialInfoList.Items.Add(_m); } foreach (Materiral.Minds m in Materiral.GetMindList()) { MindsInfo _m = new MindsInfo(); _m.ID = m.ID; _m.PutCount = 0; _m.SellCount = 0; _m.RecipeCount = 0; _m.CollectCount = 0; playerinfo.MaterialInfoList.Minds.Add(_m); } foreach (Materiral.SpecialItem m in Materiral.GetSpecialItemList()) { SpecialItemsInfo _m = new SpecialItemsInfo(); _m.ID = m.ID; _m.PutCount = 0; _m.SellCount = 0; _m.RecipeCount = 0; _m.CollectCount = 0; playerinfo.MaterialInfoList.SpecialItems.Add(_m); } foreach (Materiral.Property m in Materiral.GetPropertyList()) { PropertysInfo _m = new PropertysInfo(); _m.ID = m.ID; _m.RecipeCount = 0; playerinfo.MaterialInfoList.Propertys.Add(_m); } //初始化场景数据 for (int i = 0; i <= 1; i++) { SenceInfo s = new SenceInfo(); s.ID = i; s.InCount = 0; playerinfo.SenceInfoList.Add(s); } ////初始化地图路点数据 XmlTool xt = new XmlTool(); ArrayList _list = xt.loadPathXmlToArray(); MapPathManager.Path[] PathList = new MapPathManager.Path[_list.Count]; _list.CopyTo(PathList); xt = null; _list.Clear(); foreach (MapPathManager.Path p in PathList) { MapInfo m = new MapInfo(); m.ID = p.Map; m.InCount = 0; playerinfo.MapInfoList.Add(m); } }