ConfigReader(十七)—— ReadGuideManagerTaskConfig

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

对应的配置文件:
Assets/Resources/Config/taskmanager.xml

最后两段:

<info id="90031">
        <childtype>17</childtype>
        <childid>17019</childid>
        <endtype>2</endtype>
        <endid>17019</endid>
        <nexttaskid>90032</nexttaskid>
        <tasktype>1004</tasktype>
    </info>
    <info id="90032">
        <childtype>23</childtype>
        <childid>23001</childid>
        <endtype>2</endtype>
        <endid>23001</endid>
        <tasktype>1004</tasktype>
        <moduleend>1</moduleend>
    </info>

ReadGuideManagerTaskConfig.cs

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

//新手指导相关,taskmanager
//对应配置文件:Assets/Resources/Config/taskmanager.xml
public class ReadGuideManagerTaskConfig
{
    XmlDocument xmlDoc = null;

    //构造函数
    public ReadGuideManagerTaskConfig(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 ("taskmanager").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;

            GuideMgrInfo mgrInfo = new GuideMgrInfo ();
            mgrInfo.TaskId = Convert.ToInt32 (typeName);

            foreach (XmlElement xEle in infoNodeList[i].ChildNodes)
            {
                switch (xEle.Name)
                {
                case "childtype":
                    mgrInfo.ChildTaskType = GameMethod.ResolveToInitList (xEle.InnerText);
                    break;

                case "childid":
                    mgrInfo.ChildTaskId = GameMethod.ResolveToIntList (xEle.InnerText);
                    break;

                case "endtype":
                    mgrInfo.TaskEndType = (TaskCheckType)Convert.ToInt32 (xEle.InnerText);
                    break;

                case "endid":
                    mgrInfo.EndTaskChildId = Convert.ToInt32 (xEle.InnerText);
                    break;

                case "nexttaskid":
                    mgrInfo.NextTaskId = Convert.ToInt32 (xEle.InnerText);
                    break;

                case "close":
                    mgrInfo.mToServerType = Convert.ToInt32 (xEle.InnerText);
                    break;

                case "tasktype":
                    mgrInfo.mTaskType = Convert.ToInt32 (xEle.InnerText);
                    break;

                //这个node在taskmanager.xml中是最后一个node中才有
                case "moduleend":
                    mgrInfo.moduleend = Convert.ToInt32 (xEle.InnerText);
                    break;
                }
            }

            ConfigReader.guideTaskMgrInfoDict.Add (mgrInfo.TaskId, mgrInfo);
        }
    }
}

/*
对应xml格式:
<info id="90001">
    <childtype>17</childtype>
    <childid>17000</childid>
    <endtype>2</endtype>
    <endid>17000</endid>
    <nexttaskid>90002</nexttaskid>
    <tasktype>1001</tasktype>
</info>
*/
public class GuideMgrInfo
{
    public int TaskId;
    public List<int> ChildTaskType;
    public List<int> ChildTaskId;
    public TaskCheckType TaskEndType;
    public int EndTaskChildId;
    public int NextTaskId;
    public int mToServerType;
    public int mTaskType;
    public bool moduleend;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值