Exemple #1
0
        /// <summary>
        /// 是否禁止使用道具
        /// </summary>
        public bool ForbidUseGoods(uint goodsId)
        {
            uint goodsType    = GoodsHelper.GetGoodsType(goodsId);
            uint goodsSubType = GoodsHelper.GetGoodsSubType(goodsId);

            return(DBInstanceTypeControl.Instance.ForbidUseGoods(InstanceManager.Instance.InstanceType, InstanceManager.Instance.InstanceSubType, goodsType, goodsSubType));
        }
        Dictionary <string, bool> mGoodsSettingInfoConditionsCache = null;    // 条件缓存
        bool CheckMeetGoodsSettingInfoCondition(uint goodsId, HookGoodsSettingInfo hookGoodsSettingInfo, Dictionary <uint, HookGoodsSettingInfo> hookGoodsSettingInfos, string cacheKeyPrefix)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(cacheKeyPrefix);
            sb.Append("_");
            sb.Append(goodsId);
            sb.Append("_");
            sb.Append(hookGoodsSettingInfo.Id);
            string cacheKey = sb.ToString();

            if (mGoodsSettingInfoConditionsCache == null)
            {
                mGoodsSettingInfoConditionsCache = new Dictionary <string, bool>();
                mGoodsSettingInfoConditionsCache.Clear();
            }
            if (mGoodsSettingInfoConditionsCache.ContainsKey(cacheKey) == true)
            {
                return(mGoodsSettingInfoConditionsCache[cacheKey]);
            }

            bool ret = false;

            switch (hookGoodsSettingInfo.Type)
            {
            case HookGoodsSettingInfo.EType.OtherAll:
            {
                Dictionary <uint, HookGoodsSettingInfo> otherAllHookGoodsSettingInfos = new Dictionary <uint, HookGoodsSettingInfo>();
                otherAllHookGoodsSettingInfos.Clear();
                foreach (HookGoodsSettingInfo otherHookGoodsSettingInfo in hookGoodsSettingInfos.Values)
                {
                    if (otherHookGoodsSettingInfo.Type != HookGoodsSettingInfo.EType.OtherAll)
                    {
                        otherAllHookGoodsSettingInfos.Add(otherHookGoodsSettingInfo.Id, otherHookGoodsSettingInfo);
                    }
                }
                ret = true;
                foreach (HookGoodsSettingInfo otherHookGoodsSettingInfo in otherAllHookGoodsSettingInfos.Values)
                {
                    if (CheckMeetGoodsSettingInfoCondition(goodsId, otherHookGoodsSettingInfo, otherAllHookGoodsSettingInfos, "other_all_hook_goods_setting") == true)
                    {
                        ret = false;
                        break;
                    }
                }
                break;
            }

            case HookGoodsSettingInfo.EType.GoodsIds:
            {
                if (hookGoodsSettingInfo.Params.Contains(goodsId) == true)
                {
                    ret = true;
                    break;
                }
                break;
            }

            case HookGoodsSettingInfo.EType.GoodsType:
            {
                uint goodsType    = GoodsHelper.GetGoodsType(goodsId);
                uint goodsSubType = GoodsHelper.GetGoodsSubType(goodsId);
                if (hookGoodsSettingInfo.Params.Count >= 2)
                {
                    if (goodsType == hookGoodsSettingInfo.Params[0] && goodsSubType == hookGoodsSettingInfo.Params[1])
                    {
                        ret = true;
                        break;
                    }
                }
                break;
            }

            case HookGoodsSettingInfo.EType.EquipCertainColor:
            {
                uint goodsType = GoodsHelper.GetGoodsType(goodsId);
                if (goodsType == GameConst.GIVE_TYPE_EQUIP)
                {
                    uint color = GoodsHelper.GetGoodsColorTypeByTypeId(goodsId);
                    if (color == hookGoodsSettingInfo.Params[0])
                    {
                        ret = true;
                        break;
                    }
                }
                break;
            }

            case HookGoodsSettingInfo.EType.EquipUponCertainColor:
            {
                uint goodsType = GoodsHelper.GetGoodsType(goodsId);
                if (goodsType == GameConst.GIVE_TYPE_EQUIP)
                {
                    uint color = GoodsHelper.GetGoodsColorTypeByTypeId(goodsId);
                    if (color >= hookGoodsSettingInfo.Params[0])
                    {
                        ret = true;
                        break;
                    }
                }
                break;
            }

            case HookGoodsSettingInfo.EType.EquipPoses:
            {
                uint pos = xc.Equip.EquipHelper.GetEquipPosByGid(goodsId);
                foreach (uint param in hookGoodsSettingInfo.Params)
                {
                    if (pos == param)
                    {
                        ret = true;
                        break;
                    }
                }
                break;
            }

            default:
                break;
            }

            mGoodsSettingInfoConditionsCache.Add(cacheKey, ret);
            return(ret);
        }