示例#1
0
        public EnumBuffUnitType GetBuffUnitType(int[] buffIds)
        {
            EnumBuffUnitType val = EnumBuffUnitType.None;

            foreach (int buffId in buffIds)
            {
                if (s_dicBuffIdx4PlayerProp.ContainsKey(buffId))
                {
                    val |= EnumBuffUnitType.PlayerProp;
                }
                if (s_dicBuffIdx4ManagerShow.ContainsKey(buffId))
                {
                    val |= EnumBuffUnitType.ManagerShow;
                }
            }
            return(val);
        }
示例#2
0
        /// <summary>
        /// 获取源Buff
        /// </summary>
        /// <param name="managerId">经理Id</param>
        /// <param name="unitType">Buff细分类型</param>
        /// <param name="syncFlag">缓存标记</param>
        /// <returns></returns>
        public List <NbManagerbuffpoolEntity> GetBuffSource(Guid managerId, EnumBuffUnitType unitType = EnumBuffUnitType.None, bool syncFlag = true, DTOBuffPoolView rawPools = null)
        {
            if (null == rawPools)
            {
                rawPools = GetRawPools(managerId, "", syncFlag);
            }
            if (null == rawPools || null == rawPools.BuffPools)
            {
                return(null);
            }
            if (unitType == EnumBuffUnitType.None)
            {
                return(rawPools.BuffPools);
            }
            DateTime dtNow = DateTime.Now;

            return(rawPools.BuffPools.FindAll(i => (i.BuffUnitType & (int)unitType) > 0 && (i.ExpiryTime > dtNow || (i.ExpiryTime == DATEInfi && i.RemainTimes != 0))));
        }
示例#3
0
        /// <summary>
        /// 获取多个Buff
        /// </summary>
        /// <param name="managerId">经理Id</param>
        /// <param name="unitType">Buff细分类型</param>
        /// <param name="fillSource">是否填充源</param>
        /// <param name="syncFlag">缓存标记</param>
        /// <param name="buffCodes">Buff枚举</param>
        /// <returns></returns>
        public DTOBuffValue[] GetBuffValues(Guid managerId, EnumBuffUnitType unitType = EnumBuffUnitType.None, bool fillSource = false, bool syncFlag = true, params EnumBuffCode[] buffCodes)
        {
            if (null == buffCodes || buffCodes.Length == 0)
            {
                return(null);
            }
            int          cnt    = buffCodes.Length;
            var          arr    = new DTOBuffValue[cnt];
            int          buffId = 0;
            DTOBuffValue obj    = null;
            Dictionary <int, DTOBuffValue> dic = null;
            bool multiFlag = cnt > 1;

            if (multiFlag)
            {
                dic = new Dictionary <int, DTOBuffValue>(cnt);
                for (int i = 0; i < buffCodes.Length; ++i)
                {
                    buffId = (int)buffCodes[i];
                    if (!dic.TryGetValue(buffId, out obj))
                    {
                        obj         = new DTOBuffValue(buffId);
                        dic[buffId] = obj;
                    }
                    arr[i] = obj;
                }
            }
            else
            {
                buffId = (int)buffCodes[0];
                obj    = new DTOBuffValue(buffId);
                arr[0] = obj;
            }
            var pools = GetBuffSource(managerId, unitType, syncFlag);

            if (null == pools || pools.Count == 0)
            {
                return(arr);
            }
            int[]    buffIds = null;
            DateTime dtNow   = DateTime.Now;

            foreach (var item in pools)
            {
                if (item.ExpiryTime <= dtNow)
                {
                    continue;
                }
                buffIds = BuffCache.Instance().GetBaseBuffArray(item.BuffMap);
                if (null == buffIds)
                {
                    continue;
                }
                foreach (int val in buffIds)
                {
                    if (!multiFlag && val != buffId ||
                        multiFlag && !dic.TryGetValue(val, out obj))
                    {
                        continue;
                    }
                    obj.Point   += (double)item.BuffVal;
                    obj.Percent += (double)item.BuffPer;
                    if (fillSource)
                    {
                        if (null == obj.SrcList)
                        {
                            obj.SrcList = new List <DTOBuffSource>();
                        }
                        obj.SrcList.Add(new DTOBuffSource()
                        {
                            Idx        = item.Id,
                            SkillCode  = item.SkillCode,
                            SkillLevel = item.SkillLevel,
                            Point      = (double)item.BuffVal,
                            Percent    = (double)item.BuffPer,
                            ExpiryTime = ShareUtil.GetTimeTick(item.ExpiryTime),
                        });
                    }
                    if (!multiFlag)
                    {
                        break;
                    }
                }
            }
            if (multiFlag)
            {
                dic.Clear();
            }
            return(arr);
        }