ConfigReader(二十五)—— ReadGuideTipTaskConfig

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

对应XML配置文件:
Assets/Resources/Config/Title.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Title xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <info id="9001">
        <content>欢迎进入英雄之刃!
我们需要你带领军队摧毁敌方主基地!</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9002">
        <content>请让英雄移动至[CD0000]箭头区域![-]</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9003">
        <content>不好,前方出现敌方小兵,赶快向前迎敌!</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9004">
        <content>请滑动[CD0000]攻击按钮[-]改变攻击目标!</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9005">
        <content>中立单位只能[CD0000]点击屏幕锁定![-]</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9006">
        <content>跟随小兵前进,摧毁敌方箭塔!</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9007">
        <content>击杀敌方英雄积攒怒气,强化技能!</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9008">
        <content>点击左上角的头像按钮释放怒气!</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9009">
        <content>摧毁敌方祭坛,向胜利前进吧!</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9010">
        <content>摧毁敌方主基地,赢得胜利!</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
    <info id="9011">
        <content>锁定目标后点击按钮,可以吸附野怪!</content>
        <site>Guide/Captions_Camera2</site>
        <place>60,250,0</place>
    </info>
</Title>

ReadGuideTipTaskConfig.cs

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

//Guide相关
//对应配置文件:Assets/Resources/Config/Title.xml
public class ReadGuideTipTaskConfig
{
    XmlDocument xmlDoc = null;

    public ReadGuideTipTaskConfig(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 ("Title").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");

            GuideTitleInfo info = new GuideTitleInfo ();
            info.TaskId = Convert.ToInt32 (typeName);

            foreach (XmlElement xEle in infoNodeList[i].ChildNodes)
            {
                switch (xEle.Name)
                {
                case "content":
                    info.mContent = Convert.ToString (xEle.InnerText);
                    break;

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

                case "place":
                    info.LabelPos = GameMethod.ResolveToVector3 (xEle.InnerText);
                    break;
                }
            }

            ConfigReader.guideTitleInfoXmlInfoDict.Add (info.TaskId, info);
        }
    }
}

/*
XML格式:
<info id="9001">
    <content>欢迎进入英雄之刃!
我们需要你带领军队摧毁敌方主基地!</content>
    <site>Guide/Captions_Camera2</site>
    <place>60,250,0</place>
</info>
*/
public class GuideTitleInfo
{
    public int TaskId;
    public string mContent;
    public string mSite;
    public Vector3 LabelPos;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值