示例#1
0
 public static void LoadWeaponAdornInfo()
 {
     try
     {
         XElement xmlFile = Global.GetGameResXml(string.Format("Config/WeaponAdorn.xml", new object[0]));
         if (null != xmlFile)
         {
             IEnumerable <XElement> ChgOccpXEle = xmlFile.Elements("Weapons").Elements <XElement>();
             foreach (XElement xmlItem in ChgOccpXEle)
             {
                 if (null != xmlItem)
                 {
                     WeaponAdornInfo tmpInfo     = new WeaponAdornInfo();
                     int             nOccupation = (int)Global.GetSafeAttributeLong(xmlItem, "Occupation");
                     tmpInfo.nOccupationLimit = nOccupation;
                     string strWeaponType = Global.GetSafeAttributeStr(xmlItem, "Type");
                     if (!string.IsNullOrEmpty(strWeaponType.Trim()))
                     {
                         string[] strFields = strWeaponType.Split(new char[]
                         {
                             ','
                         });
                         if (strFields != null && strFields.Length == 2)
                         {
                             tmpInfo.tagWeaponTypeInfo.nHandType   = Convert.ToInt32(strFields[0]);
                             tmpInfo.tagWeaponTypeInfo.nActionType = Convert.ToInt32(strFields[1]);
                         }
                     }
                     string strCoexistType = Global.GetSafeAttributeStr(xmlItem, "CoexistType");
                     if (!string.IsNullOrEmpty(strCoexistType.Trim()))
                     {
                         string[] strFields = strCoexistType.Split(new char[]
                         {
                             '|'
                         });
                         if (strFields != null && strFields.Length > 0)
                         {
                             for (int i = 0; i < strFields.Length; i++)
                             {
                                 string[] strWeaponTypes = strFields[i].Split(new char[]
                                 {
                                     ','
                                 });
                                 if (strWeaponTypes != null && strWeaponTypes.Length == 2)
                                 {
                                     WeaponTypeAndACTInfo tmpCoexistType = new WeaponTypeAndACTInfo();
                                     tmpCoexistType.nHandType   = Convert.ToInt32(strWeaponTypes[0]);
                                     tmpCoexistType.nActionType = Convert.ToInt32(strWeaponTypes[1]);
                                     tmpInfo.listCoexistType.Add(tmpCoexistType);
                                 }
                             }
                         }
                     }
                     int nOrder = WeaponAdornManager.GetWeaponAdornOrder(nOccupation, tmpInfo.tagWeaponTypeInfo.nHandType, tmpInfo.tagWeaponTypeInfo.nActionType);
                     if (nOrder > 0)
                     {
                         WeaponAdornManager.dictWeaponAdornInfo.Add(nOrder, tmpInfo);
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
         throw new Exception(string.Format("启动时加载xml文件: {0} 失败", string.Format("Config/WeaponAdorn.xml", new object[0])));
     }
 }
示例#2
0
        /// <summary>
        // 装入武器配带限制信息
        /// </summary>
        public static void LoadWeaponAdornInfo()
        {
            try
            {
                XElement xmlFile = null;
                xmlFile = Global.GetGameResXml(string.Format("Config/WeaponAdorn.xml"));
                if (null == xmlFile)
                {
                    return;
                }

                string [] strFields = null;
                IEnumerable <XElement> ChgOccpXEle = xmlFile.Elements("Weapons").Elements();
                foreach (var xmlItem in ChgOccpXEle)
                {
                    if (null != xmlItem)
                    {
                        WeaponAdornInfo tmpInfo     = new WeaponAdornInfo();
                        int             nOccupation = (int)Global.GetSafeAttributeLong(xmlItem, "Occupation");
                        tmpInfo.nOccupationLimit = nOccupation;

                        // 解析武器类型信息
                        string strWeaponType = Global.GetSafeAttributeStr(xmlItem, "Type");
                        if (!string.IsNullOrEmpty(strWeaponType.Trim()))
                        {
                            strFields = strWeaponType.Split(',');
                            if (null != strFields && strFields.Length == 2)
                            {
                                tmpInfo.tagWeaponTypeInfo.nHandType   = Convert.ToInt32(strFields[0]);
                                tmpInfo.tagWeaponTypeInfo.nActionType = Convert.ToInt32(strFields[1]);
                            }
                        }

                        // 与本武器可同时佩戴的武器类型列表信息
                        string strCoexistType = Global.GetSafeAttributeStr(xmlItem, "CoexistType");
                        if (!string.IsNullOrEmpty(strCoexistType.Trim()))
                        {
                            strFields = strCoexistType.Split('|');
                            if (null != strFields && strFields.Length > 0)
                            {
                                for (int i = 0; i < strFields.Length; i++)
                                {
                                    string[] strWeaponTypes = strFields[i].Split(',');
                                    if (null != strWeaponTypes && strWeaponTypes.Length == 2)
                                    {
                                        WeaponTypeAndACTInfo tmpCoexistType = new WeaponTypeAndACTInfo();
                                        tmpCoexistType.nHandType   = Convert.ToInt32(strWeaponTypes[0]);
                                        tmpCoexistType.nActionType = Convert.ToInt32(strWeaponTypes[1]);
                                        tmpInfo.listCoexistType.Add(tmpCoexistType);
                                    }
                                }
                            }
                        }

                        int nOrder = GetWeaponAdornOrder(nOccupation, tmpInfo.tagWeaponTypeInfo.nHandType, tmpInfo.tagWeaponTypeInfo.nActionType);
                        if (nOrder > 0)
                        {
                            dictWeaponAdornInfo.Add(nOrder, tmpInfo);
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception(string.Format("启动时加载xml文件: {0} 失败", string.Format("Config/WeaponAdorn.xml")));
            }
        }