ConfigReader(五十四)—— ReadSkillManager

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

读取技能信息

对应配置文件:
Assets/Resources/Config/SkillCfg_manager.xml
配置文件非常大,部分如下

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SkillCfg_manager xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <info un32ID="1100001">
        <szName>回城</szName>
        <CameraType>0</CameraType>
        <SkillType>5</SkillType>
        <bIsInstant>1</bIsInstant>
        <bIfNormalAttack>0</bIfNormalAttack>
        <bIsConsumeSkill>0</bIsConsumeSkill>
        <eSummonEffect>0</eSummonEffect>
        <eEffectiveAttackWay>0</eEffectiveAttackWay>
        <eReleaseWay>0</eReleaseWay>
        <n32UpgradeLevel>1</n32UpgradeLevel>
        <n32UseMP>0</n32UseMP>
        <n32UseHP>0</n32UseHP>
        <n32UseCP>0</n32UseCP>
        <n32PrepareAction>free</n32PrepareAction>
        <n32PrepareTime>5000</n32PrepareTime>
        <n32PrepareEffect>backtocity</n32PrepareEffect>
        <n32PrepareSound>huicheng</n32PrepareSound>
        <n32ReleaseAction>0</n32ReleaseAction>
        <n32ReleaseSound>0</n32ReleaseSound>
        <n32ReleaseTime>0</n32ReleaseTime>
        <n32CoolDown>0</n32CoolDown>
        <n32SkillLastTime>0</n32SkillLastTime>
        <n32ReleaseDistance>100</n32ReleaseDistance>
        <eUseWay>1</eUseWay>
        <n32TriggerRate>1000</n32TriggerRate>
        <bIfAffectBuilding>0</bIfAffectBuilding>
        <bIfAffectHero>1</bIfAffectHero>
        <bIfAffectMonster>0</bIfAffectMonster>
        <eTargetType>1</eTargetType>
        <bIsCheckTargetSta>0</bIsCheckTargetSta>
        <SkillIcon>0</SkillIcon>
        <info>0</info>
        <EventID>170001</EventID>
    </info>
    <info/>
    <info un32ID="1100101">
        <szName>女妖攻击</szName>
        <CameraType>0</CameraType>
        <SkillType>2</SkillType>
        <bIsInstant>0</bIsInstant>
        <bIfNormalAttack>1</bIfNormalAttack>
        <bIsConsumeSkill>0</bIsConsumeSkill>
        <eSummonEffect>0</eSummonEffect>
        <eEffectiveAttackWay>0</eEffectiveAttackWay>
        <eReleaseWay>2</eReleaseWay>
        <n32UpgradeLevel>1</n32UpgradeLevel>
        <n32UseMP>0</n32UseMP>
        <n32UseHP>0</n32UseHP>
        <n32UseCP>0</n32UseCP>
        <n32PrepareAction>0</n32PrepareAction>
        <n32PrepareTime>0</n32PrepareTime>
        <n32PrepareEffect>0</n32PrepareEffect>
        <n32PrepareSound>0</n32PrepareSound>
        <n32ReleaseAction>attack</n32ReleaseAction>
        <n32ReleaseSound>0</n32ReleaseSound>
        <n32ReleaseTime>433</n32ReleaseTime>
        <n32CoolDown>967</n32CoolDown>
        <n32SkillLastTime>0</n32SkillLastTime>
        <n32ReleaseDistance>0</n32ReleaseDistance>
        <eUseWay>1</eUseWay>
        <n32TriggerRate>1000</n32TriggerRate>
        <bIfAffectBuilding>1</bIfAffectBuilding>
        <bIfAffectHero>1</bIfAffectHero>
        <bIfAffectMonster>1</bIfAffectMonster>
        <eTargetType>4</eTargetType>
        <bIsCheckTargetSta>1</bIsCheckTargetSta>
        <SkillIcon>0</SkillIcon>
        <info>0</info>
        <EventID>130004</EventID>
    </info>

ReadSkillManager.cs

using System;
using UnityEngine;
using System.Xml;
using System.Collections.Generic;

//读取技能信息
//对应配置文件:Assets/Resources/Config/SkillCfg_manager.xml
//这配置文件超大
public class ReadSkillManager
{
    XmlDocument xmlDoc = null;

    //构造函数
    public ReadSkillManager(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_manager").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;
            SkillManagerConfig skillInfo = new SkillManagerConfig ();
            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 "bIfNormalAttack":
                    skillInfo.isNormalAttack = Convert.ToInt32 (xEle.InnerText);
                    break;

                case "n32PrepareAction":
                    skillInfo.yAnimation = Convert.ToString (xEle.InnerText);
                    break;

                case "n32PrepareTime":
                    skillInfo.yTime = Convert.ToInt32 (xEle.InnerText) / 1000.0f;
                    break;

                case "n32PrepareEffect":
                    skillInfo.yEffect = Convert.ToString (xEle.InnerText);
                    break;

                case "n32ReleaseSound":
                    skillInfo.rSound = Convert.ToString (xEle.InnerText);
                    break;

                case "n32ReleaseAction":
                    skillInfo.rAnimation = Convert.ToString (xEle.InnerText);
                    break;

                case "n32ReleaseEffect":
                    skillInfo.rEffect = Convert.ToString (xEle.InnerText);
                    break;

                case "n32PrepareSound":
                    skillInfo.ySound = Convert.ToString (xEle.InnerText);
                    break;

                case "eUseWay":
                    skillInfo.useWay = Convert.ToInt32 (xEle.InnerText);
                    break;

                case "eTargetType":
                    skillInfo.targetType = Convert.ToInt32 (xEle.InnerText);
                    break;

                case "SkillIcon":
                    skillInfo.skillIcon = Convert.ToString (xEle.InnerText);
                    break;

                case "info":
                    skillInfo.info = Convert.ToString (xEle.InnerText);
                    break;

                case "n32CoolDown":
                    skillInfo.coolDown = Convert.ToInt32 (xEle.InnerText);
                    break;

                case "n32ReleaseDistance":
                    skillInfo.range = Convert.ToInt32 (xEle.InnerText) / 100.0f;
                    break;

                case "eSummonEffect":
                    skillInfo.absorbRes = Convert.ToString (xEle.InnerText);
                    break;

                case "bIsConsumeSkill":
                    skillInfo.isAbsorb = Convert.ToInt32 (xEle.InnerText);
                    break;

                case "n32UpgradeLevel":
                    skillInfo.n32UpgradeLevel = Convert.ToInt32 (xEle.InnerText);
                    break;

                case "n32UseMP":
                    skillInfo.mpUse = Convert.ToSingle (xEle.InnerText);
                    break;

                case "n32UseHP":
                    skillInfo.hpUse = Convert.ToSingle (xEle.InnerText);
                    break;

                case "n32UseCP":
                    skillInfo.cpUse = Convert.ToSingle (xEle.InnerText);
                }
            }

            ConfigReader.skillManagerInfoDic.Add (skillInfo.id, skillInfo);
        }
    }
}

/*
XML格式:
<info un32ID="1202801">
        <szName>战斗渴望等级1</szName>
        <CameraType>0</CameraType>
        <SkillType>1</SkillType>
        <bIsInstant>0</bIsInstant>
        <bIfNormalAttack>0</bIfNormalAttack>
        <bIsConsumeSkill>0</bIsConsumeSkill>
        <eSummonEffect>0</eSummonEffect>
        <eEffectiveAttackWay>0</eEffectiveAttackWay>
        <eReleaseWay>0</eReleaseWay>
        <n32UpgradeLevel>1</n32UpgradeLevel>
        <n32UseMP>70</n32UseMP>
        <n32UseHP>0</n32UseHP>
        <n32UseCP>0</n32UseCP>
        <n32PrepareAction>0</n32PrepareAction>
        <n32PrepareTime>0</n32PrepareTime>
        <n32PrepareEffect>0</n32PrepareEffect>
        <n32PrepareSound>0</n32PrepareSound>
        <n32ReleaseAction>skill2</n32ReleaseAction>
        <n32ReleaseSound>0</n32ReleaseSound>
        <n32ReleaseTime>470</n32ReleaseTime>
        <n32CoolDown>20000</n32CoolDown>
        <n32SkillLastTime>770</n32SkillLastTime>
        <n32ReleaseDistance>0</n32ReleaseDistance>
        <eUseWay>1</eUseWay>
        <n32TriggerRate>1000</n32TriggerRate>
        <bIfAffectBuilding>0</bIfAffectBuilding>
        <bIfAffectHero>1</bIfAffectHero>
        <bIfAffectMonster>0</bIfAffectMonster>
        <eTargetType>1</eTargetType>
        <bIsCheckTargetSta>0</bIsCheckTargetSta>
        <SkillIcon>53</SkillIcon>
        <info>激发自身潜力,瞬间恢复100(+5%最大生命值)点生命并增加每秒3%的生命回复和30%的攻击速度,持续6秒</info>
        <EventID>121180:0;160185:0;160189:0</EventID>
    </info>
*/
public class SkillManagerConfig
{
    public int id;  //id
    public string name; //名字    
    //public int releaseWay;    //释放方法
    public int isNormalAttack;  //是否普通攻击
    public string yAnimation;   //吟唱动画
    public string ySound;   //吟唱声音
    public string yEffect;  //吟唱效果
    public string rAnimation;   //释放动画
    public string rSound;   //释放声音
    public string rEffect;  //吟唱效果
    public int useWay;  //使用方法
    public int targetType;  //目标类型
    public string skillIcon;
    public string info;
    public int coolDown;
    public float range;
    public string absorbRes;
    public int isAbsorb;
    public int n32UpgradeLevel;
    public float yTime; //吟唱时间
    public float mpUse;
    public float hpUse;
    public float cpUse;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值