ConfigReader(五十五)—— ReadSkillMoveConfig

xiaoxiao2021-02-28  10

目录为:Assets/Scripts/ConfigReader/目录下 ReadSkillMoveConfig.cs

对应配置文件: Assets/Resources/Config/SKillCfg_move.xml 部分如下

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <SkillCfg_move xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <info un32ID="170001"> <szName>回城</szName> <n32UseMP>0</n32UseMP> <n32UseHP>0</n32UseHP> <n32UseCP>0</n32UseCP> <bIsCoolDown>1</bIsCoolDown> <bIsCanBreak>1</bIsCanBreak> <bIsCanMove>1</bIsCanMove> <n32TriggerRate>1000</n32TriggerRate> <bIfAffectBuilding>0</bIfAffectBuilding> <bIfAffectHero>1</bIfAffectHero> <bIfAffectMonster>0</bIfAffectMonster> <eMoveType>1</eMoveType> <eMovedTarget>1</eMovedTarget> <eMoveToTarget>0</eMoveToTarget> <n32Angle>0</n32Angle> <n32Distance>0</n32Distance> <n32Speed>0</n32Speed> <n32FlyEffect>0</n32FlyEffect> <n32MoveSound>0</n32MoveSound> <MoveBeginEffect>0</MoveBeginEffect> <MoveEndEffect>0</MoveEndEffect> <MoveAction>free</MoveAction> <EventID>0</EventID> </info> <info/> <info un32ID="170003"> <szName>瞬刺等级1</szName> <n32UseMP>0</n32UseMP> <n32UseHP>0</n32UseHP> <n32UseCP>0</n32UseCP> <bIsCoolDown>1</bIsCoolDown> <bIsCanBreak>1</bIsCanBreak> <bIsCanMove>1</bIsCanMove> <n32TriggerRate>1000</n32TriggerRate> <bIfAffectBuilding>0</bIfAffectBuilding> <bIfAffectHero>1</bIfAffectHero> <bIfAffectMonster>0</bIfAffectMonster> <eMoveType>2</eMoveType> <eMovedTarget>1</eMovedTarget> <eMoveToTarget>2</eMoveToTarget> <n32Angle>0</n32Angle> <n32Distance>4000</n32Distance> <n32Speed>0</n32Speed> <n32FlyEffect>0</n32FlyEffect> <n32MoveSound>0</n32MoveSound> <MoveBeginEffect>disappear_gws</MoveBeginEffect> <MoveEndEffect>appear_gws</MoveEndEffect> <MoveAction>free</MoveAction> <EventID>0</EventID> </info>

ReadSkillMoveConfig.cs

using System; using UnityEngine; using System.Xml; using System.Collections.Generic; //对应配置文件:Assets/Resources/Config/SKillCfg_move.xml public class ReadSkillMoveConfig { XmlDocument xmlDoc = null; //构造函数 public ReadSkillMoveConfig(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 ("SkillCfg_move").ChildNodes; for (int i = 0; i < infoNodeList.Count; i++) { if ((infoNodeList[i] as XmlElement).GetAttributeNode("un32ID") == null) { continue; } string typeName = (infoNodeList [i] as XmlElement).GetAttributeNode ("un32ID").InnerText; SkillMoveConfig skillInfo = new SkillMoveConfig (); skillInfo.id = Convert.ToInt32 (typeName); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { switch (xEle.Name) { case "szName": skillInfo.name = Convert.ToString (xEle.InnerText); break; case "MoveBeginEffect": skillInfo.effectStart = Convert.ToString (xEle.InnerText); break; case "MoveEndEffect": skillInfo.effectEnd = Convert.ToString (xEle.InnerText); break; case "n32Speed": skillInfo.speed = Convert.ToInt32 (xEle.InnerText) 100.0f; break; case "MoveAction": skillInfo.action = Convert.ToString (xEle.InnerText); break; } } ConfigReader.skillMoveInfoDic.Add(skillInfo.id, skillInfo); } } } /* XML格式: <info un32ID="170013"> <szName>主动-推送</szName> <n32UseMP>0</n32UseMP> <n32UseHP>0</n32UseHP> <n32UseCP>0</n32UseCP> <bIsCoolDown>1</bIsCoolDown> <bIsCanBreak>0</bIsCanBreak> <bIsCanMove>1</bIsCanMove> <n32TriggerRate>1000</n32TriggerRate> <bIfAffectBuilding>0</bIfAffectBuilding> <bIfAffectHero>1</bIfAffectHero> <bIfAffectMonster>1</bIfAffectMonster> <eMoveType>3</eMoveType> <eMovedTarget>2</eMovedTarget> <eMoveToTarget>3</eMoveToTarget> <n32Angle>0</n32Angle> <n32Distance>1500</n32Distance> <n32Speed>3000</n32Speed> <n32FlyEffect>0</n32FlyEffect> <n32MoveSound>0</n32MoveSound> <MoveBeginEffect>0</MoveBeginEffect> <MoveEndEffect>0</MoveEndEffect> <MoveAction>free</MoveAction> <EventID>0</EventID> </info> */ public class SkillMoveConfig { public int id; //id public string name; //名字 public string effectStart; //开始特效 public string effectEnd; //结束特效 public float speed; public string action; //public float lifeTime; //生命周期 }
转载请注明原文地址: https://www.6miu.com/read-1600050.html

最新回复(0)