ConfigReader(二十五)—— ReadGuideTipTaskConfig
来源:互联网 发布:mac浏览器兼容模式 编辑:程序博客网 时间:2024/06/05 14:31
目录为:Assets/Scripts/ConfigReader/目录下
ReadGuideTipTaskConfig.cs
对应XML配置文件:
Assets/Resources/Config/Title.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Title xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <info id="9001"> <content>欢迎进入英雄之刃!我们需要你带领军队摧毁敌方主基地!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9002"> <content>请让英雄移动至[CD0000]箭头区域![-]</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9003"> <content>不好,前方出现敌方小兵,赶快向前迎敌!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9004"> <content>请滑动[CD0000]攻击按钮[-]改变攻击目标!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9005"> <content>中立单位只能[CD0000]点击屏幕锁定![-]</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9006"> <content>跟随小兵前进,摧毁敌方箭塔!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9007"> <content>击杀敌方英雄积攒怒气,强化技能!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9008"> <content>点击左上角的头像按钮释放怒气!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9009"> <content>摧毁敌方祭坛,向胜利前进吧!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9010"> <content>摧毁敌方主基地,赢得胜利!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info> <info id="9011"> <content>锁定目标后点击按钮,可以吸附野怪!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place> </info></Title>
ReadGuideTipTaskConfig.cs
using System;using UnityEngine;using System.Xml;using System.Collections.Generic;//Guide相关//对应配置文件:Assets/Resources/Config/Title.xmlpublic class ReadGuideTipTaskConfig{ XmlDocument xmlDoc = null; public ReadGuideTipTaskConfig(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 ("Title").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"); GuideTitleInfo info = new GuideTitleInfo (); info.TaskId = Convert.ToInt32 (typeName); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { switch (xEle.Name) { case "content": info.mContent = Convert.ToString (xEle.InnerText); break; case "site": info.mSite = Convert.ToString (xEle.InnerText); break; case "place": info.LabelPos = GameMethod.ResolveToVector3 (xEle.InnerText); break; } } ConfigReader.guideTitleInfoXmlInfoDict.Add (info.TaskId, info); } }}/*XML格式:<info id="9001"> <content>欢迎进入英雄之刃!我们需要你带领军队摧毁敌方主基地!</content> <site>Guide/Captions_Camera2</site> <place>60,250,0</place></info>*/public class GuideTitleInfo{ public int TaskId; public string mContent; public string mSite; public Vector3 LabelPos;}
阅读全文
0 0
- ConfigReader(二十五)—— ReadGuideTipTaskConfig
- ConfigReader(十五)—— ReadGuideKillHeroTaskConfig
- ConfigReader(二)—— MapLoadConfig
- ConfigReader(二十)—— ReadGuidePathTaskConfig
- ConfigReader(二十一)—— ReadGuidePopTipTaskConfig
- ConfigReader(二十二)—— ReadGuideRewardTaskConfig
- ConfigReader(二十三)—— ReadGuideTaskConfig
- ConfigReader(二十四)—— ReadGuideTimeCtrlTaskConfig
- ConfigReader(二十六)—— ReadGuideVoiceTaskConfig
- ConfigReader(二十七)—— ReadHeroBuyConfig
- ConfigReader(二十八)—— ReadHeroConfig
- ConfigReader(二十九)—— ReadHeroHeadConfig
- ConfigReader(六十)—— ConfigReader
- Commom(十)—— ConfigReader
- ConfigReader(一)—— MapConfig
- ConfigReader(三)—— ReadAdvancedGuideConfig
- ConfigReader(四)—— ReadBuffConfig
- ConfigReader(五)—— ReadBuySkinConfig
- Lucene教程
- BDCTF2017-初赛第一阶段writeup
- canvas translate()方法实例及效果
- HTM(皮质学习)Youtube课程学习笔记四(episode 7)
- flume的安装与使用
- ConfigReader(二十五)—— ReadGuideTipTaskConfig
- Android数据存储—SharedPreferences的保存和读取
- js禁止拷贝等方法
- html页面传递中文参数发生乱码问题
- 浅谈面向对象设计模式:观察者模式
- std::string::substr
- EasyRTMP 1.3.17.1014版本更新
- Es6知识点回顾
- Web安全