ConfigReader(四十)—— ReadNpcConfig
来源:互联网 发布:erp开源软件 编辑:程序博客网 时间:2024/05/17 04:31
目录为:Assets/Scripts/ConfigReader/目录下
ReadNpcConfig.cs
对应配置文件:
Assets/Resources/Config/NpcCfg.xml
这个配置文件很大,部分如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><NPCCfg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <info un32ID="20001"> <szNOStr>Beinuyideyuanren_5</szNOStr> <eNpcType>1</eNpcType> <eNpcChildType>3</eNpcChildType> <XuetiaoHeight>4</XuetiaoHeight> <EmitPos>0,1000,0</EmitPos> <HitPos>0,1300,0</HitPos> <eRace>1</eRace> <eAttendantCate>1</eAttendantCate> <eMagicCate>2</eMagicCate> <eAttackWay>1</eAttackWay> <n32AttackDist>230</n32AttackDist> <eAICate>2</eAICate> <un32AITarID>0</un32AITarID> <n32PursueDist>1400</n32PursueDist> <n32GuardDist>1000</n32GuardDist> <eAttackMode>0</eAttackMode> <n32AttackPower>45</n32AttackPower> <n32MagAttackPower>0</n32MagAttackPower> <n32DefenseAbility>0</n32DefenseAbility> <n32MagDefenseAbility>150</n32MagDefenseAbility> <n32MoveSpeed>560</n32MoveSpeed> <n32BaseMoveSpeedScaling>1200</n32BaseMoveSpeedScaling> <n32AttackSpeed>1333</n32AttackSpeed> <n32MaxHP>400</n32MaxHP> <n32MaxMP>0</n32MaxMP> <n32GotExp>60</n32GotExp> <n32ConsumeCP>500</n32ConsumeCP> <n32KillCP>85</n32KillCP> <bIfCanControl>1</bIfCanControl> <eConsumeAtt>13</eConsumeAtt> <n32ConsumeValue>6000</n32ConsumeValue> <n32ConsumePer>0</n32ConsumePer> <n32HPRecover>0</n32HPRecover> <n32MPRecover>0</n32MPRecover> <n32GroupID>1</n32GroupID> <n32CollideRadius>70</n32CollideRadius> <n32IsLocked>1</n32IsLocked> <n32LockRadius>1.3</n32LockRadius> <n32RandomAttack>attack</n32RandomAttack> <un32DeathSould>Beinuyideyuanren5_Dead</un32DeathSould> <un32FreeSound>0</un32FreeSound> <un32SkillType1>1160201</un32SkillType1> <un32SkillType2>1500201</un32SkillType2> <un32SkillType3>1500201</un32SkillType3> <un32SkillType4>1500201</un32SkillType4> <un32SkillType5>0</un32SkillType5> <un32PassSkillID>11200201</un32PassSkillID> <HeadPhoto>11</HeadPhoto> <eCamp>0</eCamp> <un32ShopID>0</un32ShopID> <EffectID>heal_once</EffectID> <un32Script1>Beinuyideyuanren_line_01,Beinuyideyuanren_line_02</un32Script1> <n32Script1Rate>90050,90050</n32Script1Rate> </info>
ReadNpcConfig.cs
using System;using UnityEngine;using System.Xml;using System.Collections.Generic;//这里和ReadHeroConfig那里有一些是相似的//对应配置文件:Assets/Resources/Config/NPCCfg.xml//这个配置文件很大public class ReadNpcConfig{ XmlDocument xmlDoc = null; //构造函数 public ReadNpcConfig (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 ("NPCCfg").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; NpcConfigInfo npcSelectInfo = new NpcConfigInfo (); npcSelectInfo.NpcId = Convert.ToInt32 (typeName); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { switch (xEle.Name) { case "szNOStr": npcSelectInfo.NpcName = Convert.ToString (xEle.InnerText); break; case "eNpcType": npcSelectInfo.NpcType = Convert.ToInt32 (xEle.InnerText); break; case "eNpcChildType": npcSelectInfo.ENPCCateChild = Convert.ToInt32 (xEle.InnerText); break; case "XuetiaoHeight": npcSelectInfo.NpcXueTiaoHeight = Convert.ToSingle (xEle.InnerText); break; case "eRace": npcSelectInfo.NpcRace = Convert.ToInt32 (xEle.InnerText); break; case "eAttendantCate": npcSelectInfo.NpcAttendantCate = Convert.ToInt32 (xEle.InnerText); break; case "eMagicCate": npcSelectInfo.NpcMagicCate = Convert.ToInt32 (xEle.InnerText); break; case "n32AttackDist": npcSelectInfo.NpcAtkDis = Convert.ToSingle (xEle.InnerText); break; case "eAICate": npcSelectInfo.NpcAiCate = Convert.ToInt32 (xEle.InnerText); break; case "un32AITarID": npcSelectInfo.NpcAiTarId = Convert.ToInt32 (xEle.InnerText); break; case "un32PursueDist": npcSelectInfo.NpcPursueDis = Convert.ToSingle (xEle.InnerText); break; case "n32GuardDist": npcSelectInfo.NpcGuardDis = Convert.ToSingle (xEle.InnerText); break; case "eAttackMode": npcSelectInfo.NpcAtkMode = Convert.ToInt32 (xEle.InnerText); break; case "n32AttackPower": npcSelectInfo.NpcAtkPower = Convert.ToSingle (xEle.InnerText); break; case "n32MagAttackPower": npcSelectInfo.NpcMagAtkPower = Convert.ToSingle (xEle.InnerText); break; case "n32DefenseAbility": npcSelectInfo.NpcDef = Convert.ToSingle (xEle.InnerText); break; case "n32MagDefenseAbility": npcSelectInfo.NpcMagDef = Convert.ToSingle (xEle.InnerText); break; case "n32MoveSpeed": npcSelectInfo.NpcMoveSpeed = Convert.ToSingle (xEle.InnerText); break; case "n32BaseMoveSpeedScaling": npcSelectInfo.n32BaseMoveSpeedScaling = Convert.ToSingle (xEle.InnerText); break; case "n32AttackCD": npcSelectInfo.NpcAtkCd = Convert.ToSingle (xEle.InnerText); break; case "n32MaxHP": npcSelectInfo.NpcMaxHp = Convert.ToSingle (xEle.InnerText); break; case "n32MaxMP": npcSelectInfo.NpcMaxMp = Convert.ToSingle (xEle.InnerText); break; case "n32GotExp": npcSelectInfo.NpcGotExp = Convert.ToSingle (xEle.InnerText); break; case "n32ConsumeCP": npcSelectInfo.NpcConsumeCp = Convert.ToSingle (xEle.InnerText); break; case "n32KillCP": npcSelectInfo.NpcKillCp = Convert.ToSingle (xEle.InnerText); break; case "bIfCanControl": npcSelectInfo.NpcCanControl = Convert.ToInt32 (xEle.InnerText); break; case "n32HPRecover": npcSelectInfo.NpcHpRecover = Convert.ToSingle (xEle.InnerText); break; case "n32MPRecover": npcSelectInfo.NpcMpRecover = Convert.ToSingle (xEle.InnerText); break; case "n32CollideRadius": npcSelectInfo.NpcCollideRadius = Convert.ToSingle (xEle.InnerText); break; case "un32WalkSound": npcSelectInfo.NpcWalkSound = Convert.ToString (xEle.InnerText); break; case "un32DeathSould": npcSelectInfo.NpcDeathSould = Convert.ToString (xEle.InnerText); break; case "un32SkillType1": npcSelectInfo.NpcSkillType1 = Convert.ToInt32 (xEle.InnerText); break; case "un32SkillType2": npcSelectInfo.NpcSkillType2 = Convert.ToInt32 (xEle.InnerText); break; case "un32SkillType3": npcSelectInfo.NpcSkillType3 = Convert.ToInt32 (xEle.InnerText); break; case "un32SkillType4": npcSelectInfo.NpcSkillType4 = Convert.ToInt32 (xEle.InnerText); break; case "un32SkillType5": npcSelectInfo.NpcSkillType5 = Convert.ToInt32 (xEle.InnerText); break; case "HeadPhoto": npcSelectInfo.HeadPhoto = Convert.ToInt32 (xEle.InnerText); break; case "eCamp": npcSelectInfo.NpcCamp = Convert.ToInt32 (xEle.InnerText); break; case "un32ShopID": npcSelectInfo.un32ShopID = Convert.ToInt32 (xEle.InnerText); break; case "BuildsDeathEffID": npcSelectInfo.NpcJianTaDeath = Convert.ToString (xEle.InnerText); break; case "n32LockRadius": npcSelectInfo.n32LockRadius = Convert.ToSingle (xEle.InnerText); break; case "n32Script1Rate": npcSelectInfo.n32Script1Rate = Convert.ToString (xEle.InnerText); break; case "n32Script1": npcSelectInfo.un32Script1 = Convert.ToString (xEle.InnerText); break; case "n32AttackSpeed": npcSelectInfo.NpcAttackSpeed = Convert.ToInt32 (xEle.InnerText); break; case "n32IsLocked": npcSelectInfo.CanLock = (Convert.ToInt32 (xEle.InnerText) == 1) ? true : false; break; } } ConfigReader.npcXmlInfoDict.Add (npcSelectInfo.NpcId, npcSelectInfo); } }}/*XML格式:<info un32ID="20006"> <szNOStr>Kulouqishi_5</szNOStr> <eNpcType>1</eNpcType> <eNpcChildType>3</eNpcChildType> <XuetiaoHeight>4</XuetiaoHeight> <EmitPos>0,1200,0</EmitPos> <HitPos>0,1200,0</HitPos> <eRace>4</eRace> <eAttendantCate>1</eAttendantCate> <eMagicCate>2</eMagicCate> <eAttackWay>1</eAttackWay> <n32AttackDist>230</n32AttackDist> <eAICate>2</eAICate> <un32AITarID>0</un32AITarID> <n32PursueDist>1400</n32PursueDist> <n32GuardDist>1000</n32GuardDist> <eAttackMode>0</eAttackMode> <n32AttackPower>90</n32AttackPower> <n32MagAttackPower>0</n32MagAttackPower> <n32DefenseAbility>0</n32DefenseAbility> <n32MagDefenseAbility>0</n32MagDefenseAbility> <n32MoveSpeed>570</n32MoveSpeed> <n32BaseMoveSpeedScaling>1200</n32BaseMoveSpeedScaling> <n32AttackSpeed>1500</n32AttackSpeed> <n32MaxHP>380</n32MaxHP> <n32MaxMP>0</n32MaxMP> <n32GotExp>65</n32GotExp> <n32ConsumeCP>600</n32ConsumeCP> <n32KillCP>93</n32KillCP> <bIfCanControl>1</bIfCanControl> <eConsumeAtt>5</eConsumeAtt> <n32ConsumeValue>35</n32ConsumeValue> <n32ConsumePer>0</n32ConsumePer> <n32HPRecover>0</n32HPRecover> <n32MPRecover>0</n32MPRecover> <n32GroupID>0</n32GroupID> <n32CollideRadius>70</n32CollideRadius> <n32IsLocked>1</n32IsLocked> <n32LockRadius>0.9</n32LockRadius> <n32RandomAttack>attack</n32RandomAttack> <un32DeathSould>Jinglingnan5_Dead</un32DeathSould> <un32FreeSound>0</un32FreeSound> <un32SkillType1>1160501</un32SkillType1> <un32SkillType2>1500501</un32SkillType2> <un32SkillType3>1500501</un32SkillType3> <un32SkillType4>1500501</un32SkillType4> <un32SkillType5>0</un32SkillType5> <un32PassSkillID>11200101</un32PassSkillID> <HeadPhoto>20</HeadPhoto> <eCamp>0</eCamp> <un32ShopID>0</un32ShopID> <un32Script1>Kulouqishi_line_01,Kulouqishi_line_02</un32Script1> <n32Script1Rate>90050,90050</n32Script1Rate> </info>*/public class NpcConfigInfo: System.Object{ #region NPC信息 public string NpcName; public int NpcId; public int NpcType; public int ENPCCateChild; public float NpcXueTiaoHeight; public int NpcRace; public int NpcAttendantCate; public int NpcMagicCate; public float NpcAtkDis; public int NpcAiCate; public int NpcAiTarId; public float NpcPursueDis; public float NpcGuardDis; public int NpcAtkMode; public float NpcAtkPower; public float NpcMagAtkPower; public float NpcDef; public float NpcMagDef; public float NpcMoveSpeed; public float n32BaseMoveSpeed; public float n32BaseMoveSpeedScaling; public float NpcAtkCd; public float NpcMaxHp; public float NpcMaxMp; public float NpcGotExp; public float NpcConsumeCp; public float NpcKillCp; public int NpcCanControl; public float NpcHpRecover; public float NpcMpRecover; public float NpcCollideRadius; public string NpcWalkSound; public string NpcDeathSould; public int NpcSkillType1; public int NpcSkillType2; public int NpcSkillType3; public int NpcSkillType4; public int NpcSkillType5; public int HeadPhoto; public int NpcCamp; public int un32ShopID; public string NpcJianTaDeath; public float n32LockRadius; public string n32Script1Rate; public string un32Script1; public int NpcAttackSpeed; public bool CanLock; #region}
阅读全文
0 0
- ConfigReader(四十)—— ReadNpcConfig
- ConfigReader(四十三)—— ReadRandomNameConfig
- ConfigReader(四十七)—— ReadSkillAccountCfg
- 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
- Kolakosiki序列问题
- MySql的函数和事件(navicat界面操作)
- html-javascript前端页面刷新重载的方法汇总
- 聚类
- 代码触发,手动触发touchstart事件,touch事件,click事件,自定义事件
- ConfigReader(四十)—— ReadNpcConfig
- Centos6.5安装Nginx
- BZOJ2734 [HNOI2012]集合选数
- 让Android 设备通过USB 转RJ45有线网卡上网
- centos 实现ssh远程连接docker
- 正则表达式的思维导图解读
- java web 发送邮件
- Android 解决键盘把布局顶上去的冲突的问题
- 时间戳转日期