ConfigReader(七)—— ReadDailyBonusConfig
来源:互联网 发布:为什么jbl淘宝便宜 编辑:程序博客网 时间:2024/05/21 22:50
目录为:Assets/Scripts/ConfigReader/目录下ReadDailyBonusConfig.cs这里主要读取关于日常奖励的Config文件
对应读取的XML文件为:
Assets/Resources/Config/
dailybonus.xml
一部分如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><DailyBonus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <info n32Days="1"> <n32Type>1</n32Type> <n32ItemID>2</n32ItemID> <n32ItemNum>120</n32ItemNum> </info> <info n32Days="2"> <n32Type>1</n32Type> <n32ItemID>100010</n32ItemID> <n32ItemNum>1</n32ItemNum> </info> <info n32Days="3"> <n32Type>1</n32Type> <n32ItemID>130002</n32ItemID> <n32ItemNum>1</n32ItemNum> </info>
ReadDailyBonusConfig.cs
using System;using UnityEngine;using System.Xml;using System.Collections.Generic;//日常奖励配置文件//响应配置Config路径为:Assets/Resources/Config/dailybonus.xmlpublic class ReadDailyBonusConfig{ XmlDocument xmlDoc = null; //构造函数 public ReadDailyBonusConfig(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 ("DailyBonus").ChildNodes; for (int i = 0; i < infoNodeList.Count; i++) { XmlAttribute xmlAttr = (infoNodeList [i] as XmlElement).GetAttributeNode ("n32Days"); if (xmlAttr == null) { continue; } DailyBonusConfigInfo dailyBonusInfo = new DailyBonusConfigInfo (); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { #region 搜索 switch (xEle.Name) { case "n32Type": dailyBonusInfo.n32Type = xEle.InnerText.Split(new char[] { ',' }); break; case "n32ItemID": dailyBonusInfo.n32ItemID = xEle.InnerText.Split(new char[] { ',' }); break; case "n32ItemNum": dailyBonusInfo.n32ItemNum = xEle.InnerText.Split(new char[] { ',' }); break; } #endregion } ConfigReader.dailyBonusXmlInfoDic.Add (Convert.ToUInt32 (xmlAttr.InnerText), dailyBonusInfo); } }}/*相应xml文件格式:<info n32Days="1"> <n32Type>1</n32Type> <n32ItemID>2</n32ItemID> <n32ItemNum>120</n32ItemNum></info>*/public class DailyBonusConfigInfo: System.Object{ public string[] n32Type; public string[] n32ItemID; public string[] n32ItemNum;}
阅读全文
0 0
- ConfigReader(七)—— ReadDailyBonusConfig
- ConfigReader(四十七)—— ReadSkillAccountCfg
- ConfigReader(六十)—— ConfigReader
- Commom(十)—— ConfigReader
- ConfigReader(一)—— MapConfig
- ConfigReader(二)—— MapLoadConfig
- ConfigReader(三)—— ReadAdvancedGuideConfig
- ConfigReader(四)—— ReadBuffConfig
- ConfigReader(五)—— ReadBuySkinConfig
- ConfigReader(六)—— ReadCombineConfig
- ConfigReader(八)—— ReadDailyTaskConfig
- ConfigReader(九)—— ReadGuideAbsorbTaskConfig
- ConfigReader(十)—— ReadGuideBornNpcTaskConfig
- ConfigReader(十一)—— ReadGuideCameraTaskConfig
- ConfigReader(十二)—— ReadGuideClickButtonTaskConfig
- ConfigReader(十三)—— ReadGuideFlashTaskConfig
- ConfigReader(十四)—— ReadGuideHelpConfig
- ConfigReader(十五)—— ReadGuideKillHeroTaskConfig
- 如何应对高并发?
- opencv/opencv_contrib install
- eclipse集成svn
- PCI总线---深入理解PCI总线
- docker导入导出
- ConfigReader(七)—— ReadDailyBonusConfig
- springboot之模板引擎 --- thymeleaf
- Android中的Handler的机制与用法详解
- Oracle 优化——位图、函数等索引介绍
- 【bzoj2428】[HAOI2006]均分数据
- 计算机网络--概述
- docker容器在 断网情况下开机无法自启动
- hdu 2112 HDU Today(SPFA+map)
- 【更新合集】企业级Office套包Spire.Office 更新至V2.16.18 | 附下载