示例#1
0
        public static WeaponAdornInfo GetWeaponAdornInfo(int nOccupation, int nHandType, int nActionType)
        {
            int             nOrder = WeaponAdornManager.GetWeaponAdornOrder(nOccupation, nHandType, nActionType);
            WeaponAdornInfo result;

            if (nOrder < 0)
            {
                result = null;
            }
            else
            {
                WeaponAdornInfo weaponInfo = null;
                if (!WeaponAdornManager.dictWeaponAdornInfo.TryGetValue(nOrder, out weaponInfo))
                {
                    result = null;
                }
                else
                {
                    result = weaponInfo;
                }
            }
            return(result);
        }
示例#2
0
        public static int VerifyWeaponCanEquip(int nOccupation, int nHandType, int nActionType, Dictionary <int, List <GoodsData> > EquipDict)
        {
            WeaponAdornInfo weaponInfo = WeaponAdornManager.GetWeaponAdornInfo(nOccupation, nHandType, nActionType);
            int             result;

            if (null == weaponInfo)
            {
                result = -1;
            }
            else
            {
                int nWeaponCount          = 0;
                List <GoodsData> listGood = null;
                int i = 11;
                while (i < 22)
                {
                    listGood = null;
                    lock (EquipDict)
                    {
                        if (EquipDict.TryGetValue(i, out listGood))
                        {
                            if (listGood != null && listGood.Count > 0)
                            {
                                if (weaponInfo.listCoexistType.Count < 1)
                                {
                                    return(-5);
                                }
                                nWeaponCount += listGood.Count;
                                bool bCanEquip = false;
                                for (int nCount = 0; nCount < listGood.Count; nCount++)
                                {
                                    bCanEquip = false;
                                    SystemXmlItem systemGoods = null;
                                    if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(listGood[nCount].GoodsID, out systemGoods))
                                    {
                                        return(-1);
                                    }
                                    int nExistHandType   = systemGoods.GetIntValue("HandType", -1);
                                    int nExistActionType = systemGoods.GetIntValue("ActionType", -1);
                                    for (int nCoexistCount = 0; nCoexistCount < weaponInfo.listCoexistType.Count; nCoexistCount++)
                                    {
                                        if (weaponInfo.listCoexistType[nCoexistCount].nHandType == nExistHandType && weaponInfo.listCoexistType[nCoexistCount].nActionType == nExistActionType)
                                        {
                                            bCanEquip = true;
                                            break;
                                        }
                                    }
                                }
                                if (!bCanEquip)
                                {
                                    return(-5);
                                }
                            }
                        }
                    }
IL_19C:
                    i++;
                    continue;
                    goto IL_19C;
                }
                if (nWeaponCount > 1)
                {
                    result = -3;
                }
                else
                {
                    result = 0;
                }
            }
            return(result);
        }
示例#3
0
        public int _CanUsingEquip(GameClient client, GoodsData goodsData, int toBagIndex, SystemXmlItem systemGoods = null)
        {
            if (null == systemGoods)
            {
                if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsData.GoodsID, out systemGoods))
                {
                    return(-1);
                }
            }
            int categoriy = systemGoods.GetIntValue("Categoriy", -1);

            if (!RebornEquip.IsRebornEquip(goodsData.GoodsID))
            {
                if ((categoriy < 0 || categoriy >= 49) && categoriy != 340)
                {
                    return(-2);
                }
            }
            else
            {
                if (categoriy < 30 || categoriy > 38)
                {
                    return(-2);
                }
                int Suit  = systemGoods.GetIntValue("ToReborn", -1);
                int Level = systemGoods.GetIntValue("ToRebornLevel", -1);
                if (client.ClientData.RebornCount < Suit && client.ClientData.RebornLevel < Level)
                {
                    return(-4);
                }
                if (goodsData.GCount <= 0)
                {
                    return(-5);
                }
            }
            int nHandType = systemGoods.GetIntValue("HandType", -1);

            if (categoriy < 22 && categoriy >= 11)
            {
                int nActionType = systemGoods.GetIntValue("ActionType", -1);
                int nRet        = WeaponAdornManager.VerifyWeaponCanEquip(Global.CalcOriginalOccupationID(client), nHandType, nActionType, this.EquipDict);
                if (nRet < 0)
                {
                    return(nRet);
                }
            }
            if (categoriy <= 38 && categoriy >= 37)
            {
                int nRet = RebornEquip.VerifyWeaponCanEquip(client.UsingEquipMgr.EquipDict);
                if (nRet < 0)
                {
                    return(nRet);
                }
            }
            bool             is2Dot2Disable = GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System2Dot2);
            List <GoodsData> list           = null;
            int result;

            if (!this.EquipDict.TryGetValue(categoriy, out list))
            {
                if (categoriy == 23 && !is2Dot2Disable)
                {
                    result = OrnamentManager.getInstance()._CanUsingOrnament(client, toBagIndex, list);
                }
                else if (categoriy == 9 || categoriy == 10)
                {
                    result = this._CanUsingChongWu(categoriy);
                }
                else if (GoodsUtil.CanEquip(categoriy, goodsData.Site))
                {
                    result = 0;
                }
                else
                {
                    result = 0;
                }
            }
            else
            {
                int nCount = list.Count;
                if (categoriy < 22 && categoriy >= 11)
                {
                    if (nHandType == 2 || GameManager.MagicSwordMgr.IsMagicSword(client))
                    {
                        if (nCount >= 2)
                        {
                            return(-3);
                        }
                        return(0);
                    }
                }
                else if (categoriy == 6)
                {
                    if (nCount >= 2)
                    {
                        return(-3);
                    }
                    return(0);
                }
                else if (categoriy == 36)
                {
                    if (nCount >= 2)
                    {
                        return(-3);
                    }
                    return(0);
                }
                else if (categoriy == 9 || categoriy == 10)
                {
                    int nRet = this._CanUsingChongWu(categoriy);
                    if (nRet < 0)
                    {
                        return(nRet);
                    }
                }
                else if (categoriy == 23 && !is2Dot2Disable)
                {
                    return(OrnamentManager.getInstance()._CanUsingOrnament(client, toBagIndex, list));
                }
                result = ((list.Count < 1) ? 0 : -3);
            }
            return(result);
        }
示例#4
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])));
     }
 }
示例#5
0
        /// <summary>
        /// 能否佩戴装备
        /// </summary>
        /// <param name="goodsData"></param>
        /// <returns></returns>
        public int _CanUsingEquip(GameClient client, GoodsData goodsData, int toBagIndex, SystemXmlItem systemGoods = null)
        {
            if (null == systemGoods)
            {
                if (!GameManager.SystemGoods.SystemXmlItemDict.TryGetValue(goodsData.GoodsID, out systemGoods))
                {
                    return(-1);
                }
            }

            int categoriy = systemGoods.GetIntValue("Categoriy");

            if (categoriy < 0 || categoriy >= (int)ItemCategories.EquipMax)
            {
                return(-2);
            }

            /*if ((int)ItemCategories.Ring == categoriy || (int)ItemCategories.Bracelet == categoriy)
             * {
             *  //这样的戒指和手镯无法佩戴上,所以也是非法的
             *  if (toBagIndex < 0 || toBagIndex > 1)
             *  {
             *      return -55;
             *  }
             * }*/


            // 校验武器是否能装备,不管是否穿戴过,都要进行验证[7/12/2013 ChenXiaojun]
            int nHandType = systemGoods.GetIntValue("HandType");

            if (categoriy < (int)ItemCategories.HuFu && categoriy >= (int)ItemCategories.WuQi_Jian)
            {
                int nActionType = systemGoods.GetIntValue("ActionType");

                // 进行穿戴类型验证
                int nRet = WeaponAdornManager.VerifyWeaponCanEquip(Global.CalcOriginalOccupationID(client),
                                                                   nHandType,
                                                                   nActionType,
                                                                   EquipDict);

                if (nRet < 0)
                {
                    return(nRet);
                }
            }

            List <GoodsData> list = null;

            if (!EquipDict.TryGetValue(categoriy, out list))
            {
                return(_CanUsingChongWu(categoriy));
            }
            else                    // MU 增加逻辑 [11/19/2013 LiaoWei]
            {
                // 如果是武器
                int nCount = list.Count;
                if (categoriy < (int)ItemCategories.HuFu && categoriy >= (int)ItemCategories.WuQi_Jian)
                {
                    if (nHandType == (int)WeaponHandType.WHT_BOTHTYPE)
                    {
                        if (nCount >= 2)
                        {
                            return(-3);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                }
                // 如果是戒指
                else if (categoriy == (int)ItemCategories.JieZhi)
                {
                    if (nCount >= 2)
                    {
                        return(-3);
                    }
                    else
                    {
                        return(0);
                    }
                }
                // 如果是宠物
                else if (categoriy == (int)ItemCategories.ShouHuChong || categoriy == (int)ItemCategories.ChongWu)
                {
                    int nRet = _CanUsingChongWu(categoriy);
                    if (nRet < 0)
                    {
                        return(nRet);
                    }
                }
            }

            /* if ((int)ItemCategories.Ring == categoriy || (int)ItemCategories.Bracelet == categoriy)
             * {
             *   //蕴神灵戒 只能佩戴一个,特殊处理下
             *   if ((goodsData.GoodsID >= 1305000 && goodsData.GoodsID <= 1305003) && null != list)
             *   {
             *       for (int i = 0; i < list.Count; i++)
             *       {
             *           if ((list[i].GoodsID >= 1305000 && list[i].GoodsID <= 1305003))
             *           {
             *               return -44;
             *           }
             *       }
             *   }
             *
             *   //腾云手镯 只能佩戴一个,特殊处理下
             *   if ((goodsData.GoodsID >= 1303000 && goodsData.GoodsID <= 1303003) && null != list)
             *   {
             *       for (int i = 0; i < list.Count; i++)
             *       {
             *           if ((list[i].GoodsID >= 1303000 && list[i].GoodsID <= 1303003))
             *           {
             *               return -444;
             *           }
             *       }
             *   }
             *
             *   if (list.Count >= 2)
             *   {
             *       return -3;
             *   }
             *
             *   for (int i = 0; i < list.Count; i++)
             *   {
             *       if (toBagIndex == list[i].BagIndex)
             *       {
             *           return -4; //不能重复的使用
             *       }
             *   }
             *
             *   return 0;
             * }*/

            return((list.Count < 1) ? 0 : -3);
        }