ConfigReader(十九)—— ReadGuideObstructTaskConfig
来源:互联网 发布:mac os 刷新dns 编辑:程序博客网 时间:2024/06/05 11:56
目录为:Assets/Scripts/ConfigReader/目录下
ReadGuideObstructTaskConfig.cs
对应的XML文件:
Assets/Resources/Config/obstruct.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><obstruct xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <info id="1001"> <centerpoint>22.5;60.5;140</centerpoint> <targetpoint>29;60.5;146</targetpoint> <text>点击按钮完成吸附任务进入下一步。</text> <time>5</time> <path>Guide/Tips_Window1</path> <count>3</count> </info> <info id="1002"> <centerpoint>97.5;60.5;112.5</centerpoint> <targetpoint>110;60.5;124</targetpoint> <text>请先完成任务后进入下一步。</text> <time>5</time> <path>Guide/Tips_Window1</path> <count>3</count> </info> <info id="1003"> <centerpoint>22.5;60.5;140</centerpoint> <targetpoint>29;60.5;146</targetpoint> <text>请先完成任务后进入下一步。</text> <time>5</time> <path>Guide/Tips_Window1</path> <count>3</count> </info></obstruct>
ReadGuideObstructTaskConfig.cs
using System;using UnityEngine;using System.Xml;using System.Collections.Generic;//Guide相关//对应的配置文件:Assets/Resources/Config/obstruct.xmlpublic class ReadGuideObstructTaskConfig{ XmlDocument xmlDoc = null; //构造函数 public ReadGuideObstructTaskConfig(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 ("obstruct").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; //Guide那部分定义 CObstructTask obstructInfo = new CObstructTask (); obstructInfo.TaskId = Convert.ToInt32 (typeName); obstructInfo.TaskType = GuideTaskType.ObstructTask; Vector3 center = new Vector3 (); Vector3 target = new Vector3 (); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { switch (xEle.Name) { case "centerpoint": center = GameMethod.ResolveToVector3 (Convert.ToString (xEle.InnerText), ';'); break; case "targetpoint": target = GameMethod.ResolveToVector3 (Convert.ToString (xEle.InnerText), ';'); break; case "text": obstructInfo.ObsTip = Convert.ToString (xEle.InnerText); break; case "time": obstructInfo.ObsShowTime = Convert.ToSingle (xEle.InnerText); break; case "path": obstructInfo.ObsPath = Convert.ToString (xEle.InnerText); break; case "count": obstructInfo.ObsCount = Convert.ToInt32 (xEle.InnerText); break; } } obstructInfo.ObsCenter = center; //算center到target的距离 obstructInfo.ObsDistance = Vector3.Distance (center, target); CTaskBase.obstructTaskDic.Add (obstructInfo.TaskId, obstructInfo); } }}/*XML格式放在这里:<info id="1001"> <centerpoint>22.5;60.5;140</centerpoint> <targetpoint>29;60.5;146</targetpoint> <text>点击按钮完成吸附任务进入下一步。</text> <time>5</time> <path>Guide/Tips_Window1</path> <count>3</count> </info>*/
阅读全文
0 0
- ConfigReader(十九)—— ReadGuideObstructTaskConfig
- ConfigReader(二十九)—— ReadHeroHeadConfig
- 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
- SVN 用户权限管理
- php数组操作相关函数reset()list()
- logger使用
- c++中如何只保留float型的小数点后两位?
- SAP请求传输事务代码
- ConfigReader(十九)—— ReadGuideObstructTaskConfig
- 谈谈用户体验中的表单设计-理论篇
- Linux下jdk安装及配置
- Linux 下利用corn添加定时任务
- Django日志配置
- 递归查找和非递归查找
- Butterknife(黄油刀使用)一分钟集成
- c#语言-找一找一个二维数组中的鞍点
- 平稳切换nginx版本