ConfigReader(十七)—— ReadGuideManagerTaskConfig
来源:互联网 发布:json字符串转为map 编辑:程序博客网 时间:2024/06/16 14:27
目录为:Assets/Scripts/ConfigReader/目录下
ReadGuideManagerTaskConfig.cs
对应的配置文件:
Assets/Resources/Config/taskmanager.xml
最后两段:
<info id="90031"> <childtype>17</childtype> <childid>17019</childid> <endtype>2</endtype> <endid>17019</endid> <nexttaskid>90032</nexttaskid> <tasktype>1004</tasktype> </info> <info id="90032"> <childtype>23</childtype> <childid>23001</childid> <endtype>2</endtype> <endid>23001</endid> <tasktype>1004</tasktype> <moduleend>1</moduleend> </info>
ReadGuideManagerTaskConfig.cs
using System;using UnityEngine;using System.Xml;using System.Collections.Generic;//新手指导相关,taskmanager//对应配置文件:Assets/Resources/Config/taskmanager.xmlpublic class ReadGuideManagerTaskConfig{ XmlDocument xmlDoc = null; //构造函数 public ReadGuideManagerTaskConfig(string xmlFilePath) { ResourceUnit xmlfileUnit = ResourcesManager.Instance.loadImmediate (xmlFilePath, ResourceType.ASSET); TextAsset xmlfile = xmlfileUnit.Asset as TextAsset; if (!xmlfile) { Debug.LogError(" error infos: 没有找到指定的xml文件:"+xmlFilePath); } xmlDoc = new XmlDocument (); xmlDoc.LoadXml (xmlfile.text); XmlNodeList infoNodeList = xmlDoc.SelectSingleNode ("taskmanager").ChildNodes; for (int i = 0; i < infoNodeList.Count; i++) { if ((infoNodeList[i] as XmlElement).GetAttributeNode("id") == null) { continue; } string typeName = (infoNodeList [i] as XmlElement).GetAttributeNode ("id").InnerText; GuideMgrInfo mgrInfo = new GuideMgrInfo (); mgrInfo.TaskId = Convert.ToInt32 (typeName); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { switch (xEle.Name) { case "childtype": mgrInfo.ChildTaskType = GameMethod.ResolveToInitList (xEle.InnerText); break; case "childid": mgrInfo.ChildTaskId = GameMethod.ResolveToIntList (xEle.InnerText); break; case "endtype": mgrInfo.TaskEndType = (TaskCheckType)Convert.ToInt32 (xEle.InnerText); break; case "endid": mgrInfo.EndTaskChildId = Convert.ToInt32 (xEle.InnerText); break; case "nexttaskid": mgrInfo.NextTaskId = Convert.ToInt32 (xEle.InnerText); break; case "close": mgrInfo.mToServerType = Convert.ToInt32 (xEle.InnerText); break; case "tasktype": mgrInfo.mTaskType = Convert.ToInt32 (xEle.InnerText); break; //这个node在taskmanager.xml中是最后一个node中才有 case "moduleend": mgrInfo.moduleend = Convert.ToInt32 (xEle.InnerText); break; } } ConfigReader.guideTaskMgrInfoDict.Add (mgrInfo.TaskId, mgrInfo); } }}/*对应xml格式:<info id="90001"> <childtype>17</childtype> <childid>17000</childid> <endtype>2</endtype> <endid>17000</endid> <nexttaskid>90002</nexttaskid> <tasktype>1001</tasktype></info>*/public class GuideMgrInfo{ public int TaskId; public List<int> ChildTaskType; public List<int> ChildTaskId; public TaskCheckType TaskEndType; public int EndTaskChildId; public int NextTaskId; public int mToServerType; public int mTaskType; public bool moduleend;}
阅读全文
0 0
- ConfigReader(十七)—— ReadGuideManagerTaskConfig
- ConfigReader(二十七)—— ReadHeroBuyConfig
- ConfigReader(六十)—— ConfigReader
- Commom(十)—— ConfigReader
- ConfigReader(一)—— MapConfig
- ConfigReader(二)—— MapLoadConfig
- ConfigReader(三)—— ReadAdvancedGuideConfig
- ConfigReader(四)—— ReadBuffConfig
- ConfigReader(五)—— ReadBuySkinConfig
- ConfigReader(六)—— ReadCombineConfig
- ConfigReader(七)—— ReadDailyBonusConfig
- ConfigReader(八)—— ReadDailyTaskConfig
- ConfigReader(九)—— ReadGuideAbsorbTaskConfig
- ConfigReader(十)—— ReadGuideBornNpcTaskConfig
- ConfigReader(十一)—— ReadGuideCameraTaskConfig
- ConfigReader(十二)—— ReadGuideClickButtonTaskConfig
- ConfigReader(十三)—— ReadGuideFlashTaskConfig
- ConfigReader(十四)—— ReadGuideHelpConfig
- list和set
- 常用正则表达式
- Linux网络编程——tcp并发服务器(epoll实现)
- 监控系统cat安装和配置
- clang ThreadSanitizer AddressSanitizer MemorySanitizer
- ConfigReader(十七)—— ReadGuideManagerTaskConfig
- [收藏系列]从开发到部署会用到的 Docker 命令
- grep用法
- 故障:使用Struts2框架,表单提交后,抛异常,得不到自己想要的回复。
- activiti实战六(待办流程)
- Office 使用心得
- 基于jmeter和shell的接口性能自动化
- 什么是存储引擎以及不同存储引擎特点
- VMWare装CenterOS ping不通百度