Example #1
0
 private void LoadHuangJinBossInfo()
 {
     try
     {
         XElement xmlFile = Global.GetGameResXml(string.Format("Config/HuangJin.xml", new object[0]));
         if (null != xmlFile)
         {
             IEnumerable <XElement> WorldBossXEle = xmlFile.Elements("Boss");
             foreach (XElement xmlItem in WorldBossXEle)
             {
                 if (null != xmlItem)
                 {
                     SystemXmlItem systemXmlItem = new SystemXmlItem
                     {
                         XMLNode = xmlItem
                     };
                     TimerBossData tmpInfo = new TimerBossData();
                     tmpInfo.nRoleID = systemXmlItem.GetIntValue("ID", -1);
                     int[] arrLevel = systemXmlItem.GetIntArrayValue("Level", ',');
                     if (arrLevel == null || arrLevel.Length != 2)
                     {
                         throw new Exception(string.Format("启动时加载xml文件: {0} 失败 Level格式错误", string.Format("Config/HuangJin.xml", new object[0])));
                     }
                     tmpInfo.nReqLevel           = arrLevel[1];
                     tmpInfo.nReqChangeLiveCount = arrLevel[0];
                     this.m_HuangJinBossDict.Add(tmpInfo.nRoleID, tmpInfo);
                 }
             }
         }
     }
     catch (Exception)
     {
         throw new Exception(string.Format("启动时加载xml文件: {0} 失败", string.Format("Config/HuangJin.xml", new object[0])));
     }
 }
Example #2
0
        /// summary
        /// 装入世界BOSS信息
        /// summary
        private void LoadWorldBossInfo()
        {
            // 世界BOSS信息表
            try
            {
                XElement xmlFile = null;
                xmlFile = Global.GetGameResXml(string.Format("Config/Activity/BossInfo.xml"));
                if (null == xmlFile)
                {
                    return;
                }

                IEnumerable <XElement> WorldBossXEle = xmlFile.Elements("Boss");
                foreach (var xmlItem in WorldBossXEle)
                {
                    if (null != xmlItem)
                    {
                        SystemXmlItem systemXmlItem = new SystemXmlItem()
                        {
                            XMLNode = xmlItem,
                        };

                        TimerBossData tmpInfo = new TimerBossData();

                        tmpInfo.nRoleID = systemXmlItem.GetIntValue("ID");
                        int [] arrLevel = systemXmlItem.GetIntArrayValue("Level");
                        if (null == arrLevel || arrLevel.Length != 2)
                        {
                            // 填写错误则抛异常
                            systemXmlItem = null;
                            throw new Exception(string.Format("启动时加载xml文件: {0} 失败 Level格式错误", string.Format("Config/Activity/BossInfo.xml")));
                        }
                        else
                        {
                            tmpInfo.nReqLevel           = arrLevel[1];
                            tmpInfo.nReqChangeLiveCount = arrLevel[0];
                        }

                        systemXmlItem = null;
                        m_WorldBossDict.Add(tmpInfo.nRoleID, tmpInfo);
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception(string.Format("启动时加载xml文件: {0} 失败", string.Format("Config/Activity/BossInfo.xml")));
            }
        }