Beispiel #1
0
        public static int RollWingGoodsExcellenceProperty(int MergeID)
        {
            int nRet = 0;

            double[] ExcellenceArr = GameManager.systemParamsList.GetParamValueDoubleArrayByName("WingMergeExcellencePropertyRandomID", ',');
            int      result;

            if (ExcellenceArr == null || ExcellenceArr.Length != 3)
            {
                result = nRet;
            }
            else
            {
                int nIndex = -1;
                if (MergeID == 4)
                {
                    nIndex = 0;
                }
                else if (MergeID == 5)
                {
                    nIndex = 1;
                }
                else if (MergeID == 6)
                {
                    nIndex = 2;
                }
                if (nIndex == -1)
                {
                    result = nRet;
                }
                else
                {
                    int nIndex2 = (int)ExcellenceArr[nIndex];
                    if (nIndex2 == -1)
                    {
                        result = nRet;
                    }
                    else
                    {
                        ExcellencePropertyGroupItem excellencePropertyGroupItem = GameManager.GoodsPackMgr.GetExcellencePropertyGroupItem(nIndex2);
                        if (excellencePropertyGroupItem == null || excellencePropertyGroupItem.ExcellencePropertyItems == null || excellencePropertyGroupItem.Max == null || excellencePropertyGroupItem.Max.Length <= 0)
                        {
                            result = nRet;
                        }
                        else
                        {
                            int nNum       = 0;
                            int rndPercent = Global.GetRandomNumber(1, 100001);
                            int i;
                            for (i = 0; i < excellencePropertyGroupItem.ExcellencePropertyItems.Length; i++)
                            {
                                if (rndPercent > excellencePropertyGroupItem.ExcellencePropertyItems[i].BasePercent && rndPercent <= excellencePropertyGroupItem.ExcellencePropertyItems[i].BasePercent + excellencePropertyGroupItem.ExcellencePropertyItems[i].SelfPercent)
                                {
                                    nNum = excellencePropertyGroupItem.ExcellencePropertyItems[i].Num;
                                    break;
                                }
                            }
                            List <int> idList = new List <int>();
                            if (nNum > 0 && nNum <= excellencePropertyGroupItem.Max.Length)
                            {
                                int nCount = 0;
                                do
                                {
                                    int nProp = Global.GetRandomNumber(0, excellencePropertyGroupItem.Max.Length);
                                    if (idList.IndexOf(nProp) < 0)
                                    {
                                        idList.Add(nProp);
                                        nCount++;
                                    }
                                }while (nCount != nNum);
                            }
                            i = 0;
                            while (i < idList.Count && i < excellencePropertyGroupItem.Max.Length)
                            {
                                nRet |= Global.GetBitValue(excellencePropertyGroupItem.Max[idList[i]]);
                                i++;
                            }
                            result = nRet;
                        }
                    }
                }
            }
            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 翅膀的卓越属性roll一下
        /// </summary>
        /// <param name="client"></param>
        /// <param name="mergeItemID"></param>
        public static int RollWingGoodsExcellenceProperty(int MergeID)
        {
            int nRet = 0;

            double[] ExcellenceArr = null;
            ExcellenceArr = GameManager.systemParamsList.GetParamValueDoubleArrayByName("WingMergeExcellencePropertyRandomID");

            if (ExcellenceArr == null || ExcellenceArr.Length != 3)
            {
                return(nRet);
            }

            int nIndex = -1;

            if (MergeID == (int)WINGMERGEINFO.WINGMERGE_FIRST_LEVEL_ID)
            {
                nIndex = 0;
            }
            else if (MergeID == (int)WINGMERGEINFO.WINGMERGE_SECOND_LEVEL_ID)
            {
                nIndex = 1;
            }
            else if (MergeID == (int)WINGMERGEINFO.WINGMERGE_THIRD_LEVEL_ID)
            {
                nIndex = 2;
            }

            if (nIndex == -1)
            {
                return(nRet);
            }

            int nIndex1 = -1;

            nIndex1 = (int)ExcellenceArr[nIndex];

            if (nIndex1 == -1)
            {
                return(nRet);
            }

            //根据物品掉落卓越ID获取缓存项
            ExcellencePropertyGroupItem excellencePropertyGroupItem = GameManager.GoodsPackMgr.GetExcellencePropertyGroupItem(nIndex1);

            if (excellencePropertyGroupItem == null || null == excellencePropertyGroupItem.ExcellencePropertyItems ||
                null == excellencePropertyGroupItem.Max || excellencePropertyGroupItem.Max.Length <= 0)
            {
                return(nRet);
            }

            //int nCur = 0;
            //int nMax = excellencePropertyGroupItem.Max;

            int nNum       = 0;
            int rndPercent = Global.GetRandomNumber(1, 100001);

            for (int i = 0; i < excellencePropertyGroupItem.ExcellencePropertyItems.Length; i++)
            {
                /*int rndPercent = Global.GetRandomNumber(1, 10001);
                 * int percent = (int)(excellencePropertyGroupItem.ExcellencePropertyItems[i].Percent * 10000);
                 * if (rndPercent <= percent)
                 * {
                 *  nRet |= Global.GetBitValue(excellencePropertyGroupItem.ExcellencePropertyItems[i].ID);
                 *
                 ++nCur;
                 *
                 *  if (nCur >= nMax)
                 *      break;
                 * }*/
                if (rndPercent > excellencePropertyGroupItem.ExcellencePropertyItems[i].BasePercent &&
                    rndPercent <= (excellencePropertyGroupItem.ExcellencePropertyItems[i].BasePercent + excellencePropertyGroupItem.ExcellencePropertyItems[i].SelfPercent))
                {
                    nNum = excellencePropertyGroupItem.ExcellencePropertyItems[i].Num;
                    break;
                }
            }

            List <int> idList = new List <int>();

            if (nNum > 0 && nNum <= excellencePropertyGroupItem.Max.Length)
            {
                int nCount = 0;
                while (true)
                {
                    int nProp = 0;
                    nProp = Global.GetRandomNumber(0, excellencePropertyGroupItem.Max.Length);
                    if (idList.IndexOf(nProp) < 0)
                    {
                        idList.Add(nProp);
                        ++nCount;
                    }

                    if (nCount == nNum)
                    {
                        break;
                    }
                }
            }

            for (int i = 0; i < idList.Count && i < excellencePropertyGroupItem.Max.Length; i++)
            {
                nRet |= Global.GetBitValue(excellencePropertyGroupItem.Max[idList[i]]);
            }

            return(nRet);
        }