ConfigReader(十四)—— ReadGuideHelpConfig
来源:互联网 发布:匿名者黑页源码 编辑:程序博客网 时间:2024/05/29 02:04
目录为:Assets/Scripts/ConfigReader/目录下
ReadGuideHelpConfig.cs
对应配置文件:
Assets/Resources/Config/HelpTips.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><HelpTips xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <info id="20001"> <tiptimes>1</tiptimes> <tipmatches>5</tipmatches> <Info>商城购买提示</Info> <tippath>Position/Task5</tippath> <tipevent>-5008</tipevent> <tipShowTimes>6</tipShowTimes> </info> <info id="20002"> <tiptimes>2</tiptimes> <tipmatches>5</tipmatches> <Info>血量不足回城提示</Info> <tippath>Position/Task6</tippath> <tipevent>-5009</tipevent> <tipShowTimes>10</tipShowTimes> </info> <info id="20003"> <tiptimes>2</tiptimes> <tipmatches>5</tipmatches> <Info>暴怒提示</Info> <tippath>Position/Task7</tippath> <tipevent>-5010</tipevent> <tipShowTimes>10</tipShowTimes> </info> <info id="20004"> <tiptimes>1</tiptimes> <tipmatches>5</tipmatches> <Info>商店消耗提示</Info> <tippath>Position/Task9</tippath> <tipevent>-5011</tipevent> <tipShowTimes>6</tipShowTimes> </info></HelpTips>
ReadGuideHelpConfig.cs
using System;using UnityEngine;using System.Xml;using System.Collections.Generic;//新手教程相关//对应的配置文件:Assets/Resources/Cofig/HelpTips.xmlpublic class ReadGuideHelpConfig{ XmlDocument xmlDoc = null; //构造函数 public ReadGuideHelpConfig(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 ("HelpTips").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; GuideHelpData helpInfo = new GuideHelpData (); helpInfo.helpId = Convert.ToInt32 (typeName); foreach(XmlElement xEle in infoNodeList[i].ChildNodes) { switch (xEle.Name) { case "tiptimes": helpInfo.helpTimes = Convert.ToInt32 (xEle.InnerText); break; case "tipMatches": helpInfo.helpMatches = Convert.ToInt32 (xEle.InnerText); break; case "tipPath": helpInfo.helpObjPathList = GameMethod.ResolveToStrList (Convert.ToString (xEle.InnerText), ';'); break; case "tipevent": helpInfo.helpTriggerEvent = Convert.ToInt32 (xEle.InnerText); break; case "tipShowTimes": helpInfo.helpShowTime = Convert.ToSingle (xEle.InnerText); break; } } ConfigReader.guideHelpXmlInfoDict.Add (helpInfo.helpId, helpInfo); } }}/*对应的XML格式如下:<info id="20001"> <tiptimes>1</tiptimes> <tipmatches>5</tipmatches> <Info>商城购买提示</Info> <tippath>Position/Task5</tippath> <tipevent>-5008</tipevent> <tipShowTimes>6</tipShowTimes></info>*/public class GuideHelpData{ public int helpId; public int helpTimes; public int helpMatches; public List<string> helpObjPathList; public int helpTriggerEvent; public float helpShowTime;}
阅读全文
0 0
- ConfigReader(十四)—— ReadGuideHelpConfig
- ConfigReader(二十四)—— ReadGuideTimeCtrlTaskConfig
- 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(十五)—— ReadGuideKillHeroTaskConfig
- STM32 程序如何运行
- RN中,你还在担心怎么传Json文件给服务器?来看看Json内容吧
- 贝叶斯分类器
- Cookie/Session机制详解
- JavaScript HTML DOM常用语法
- ConfigReader(十四)—— ReadGuideHelpConfig
- MySQL系列之源码浅析
- flex AIR读取本地资源
- iOS-获取手机健康步数,去除人为添加的数据
- 常用开发工具
- Spark基础随笔:Spark1.6 Idea下远程调试的2种方法
- springboot bean 注解绑定
- SQL生成临时表id自增列
- c++ vector容器