コード例 #1
0
        /// <summary>
        /// 打开杨公宝库的处理
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static YangGongBKItem OpenYangGongBK(GameClient client, bool isBaoWuBinding)
        {
            YangGongBKItem yangGongBKItem = null;

            int yangGongFallID1 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID1");
            int yangGongFallID2 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID2");
            int yangGongFallID3 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID3");
            int yangGongFallID4 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID4");
            int yangGongFallID5 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID5");
            int yangGongFallID6 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID6");
            int yangGongFallID7 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID7");
            int yangGongFallID8 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID8");

            if (yangGongFallID1 <= 0 || yangGongFallID2 <= 0 || yangGongFallID3 <= 0 || yangGongFallID4 <= 0)
            {
                return(yangGongBKItem);
            }
            if (yangGongFallID5 <= 0 || yangGongFallID6 <= 0 || yangGongFallID7 <= 0 || yangGongFallID8 <= 0)
            {
                return(yangGongBKItem);
            }

            List <FallGoodsItem> gallGoodsItemList1 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID1, 1, false);
            List <FallGoodsItem> gallGoodsItemList2 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID2, 1, false);
            List <FallGoodsItem> gallGoodsItemList3 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID3, 1, false);
            List <FallGoodsItem> gallGoodsItemList4 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID4, 1, false);
            List <FallGoodsItem> gallGoodsItemList5 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID5, 1, true);
            List <FallGoodsItem> gallGoodsItemList6 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID6, 1, true);
            List <FallGoodsItem> gallGoodsItemList7 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID7, 1, true);
            List <FallGoodsItem> gallGoodsItemList8 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID8, 1, true);

            if (null == gallGoodsItemList1 || null == gallGoodsItemList2 || null == gallGoodsItemList3 || null == gallGoodsItemList4)
            {
                return(yangGongBKItem);
            }
            if (null == gallGoodsItemList5 || null == gallGoodsItemList6 || null == gallGoodsItemList7 || null == gallGoodsItemList8)
            {
                return(yangGongBKItem);
            }

            if (1 != gallGoodsItemList1.Count || 1 != gallGoodsItemList2.Count || 1 != gallGoodsItemList3.Count || 1 != gallGoodsItemList4.Count)
            {
                return(yangGongBKItem);
            }
            if (1 != gallGoodsItemList5.Count || 1 != gallGoodsItemList6.Count || 1 != gallGoodsItemList7.Count || 1 != gallGoodsItemList8.Count)
            {
                return(yangGongBKItem);
            }

            gallGoodsItemList1.AddRange(gallGoodsItemList2);
            gallGoodsItemList1.AddRange(gallGoodsItemList3);
            gallGoodsItemList1.AddRange(gallGoodsItemList4);
            gallGoodsItemList1.AddRange(gallGoodsItemList5);
            gallGoodsItemList1.AddRange(gallGoodsItemList6);
            gallGoodsItemList1.AddRange(gallGoodsItemList7);
            gallGoodsItemList1.AddRange(gallGoodsItemList8);

            gallGoodsItemList1 = Global.RandomSortList <FallGoodsItem>(gallGoodsItemList1); //随机打乱
            List <GoodsData> goodsDataList = GameManager.GoodsPackMgr.GetGoodsDataListFromFallGoodsItemList(gallGoodsItemList1);

            List <GoodsData> tempGoodsDataList = new List <GoodsData>();

            for (int i = 0; i < goodsDataList.Count; i++)
            {
                tempGoodsDataList.Add(goodsDataList[i]);
            }

            yangGongBKItem = new YangGongBKItem()
            {
                FallGoodsItemList = gallGoodsItemList1,
                GoodsDataList     = goodsDataList,
                IsBaoWuBinding    = isBaoWuBinding,
                TempGoodsDataList = tempGoodsDataList,
            };

            return(yangGongBKItem);
        }
コード例 #2
0
        public static int ClickYangGongBK(GameClient client, YangGongBKItem yangGongBKItem, out GoodsData goodsData)
        {
            goodsData = null;
            if (null == YangGongBKManager.YangGongBKNumPercents)
            {
                YangGongBKManager.YangGongBKNumPercents = GameManager.systemParamsList.GetParamValueDoubleArrayByName("YangGongBKNumPercents", ',');
            }
            int result;

            if (YangGongBKManager.YangGongBKNumPercents == null || YangGongBKManager.YangGongBKNumPercents.Length != 4)
            {
                result = -1000;
            }
            else
            {
                List <FallGoodsItem> fallGoodsItemList = yangGongBKItem.FallGoodsItemList;
                List <GoodsData>     goodsDataList     = yangGongBKItem.GoodsDataList;
                if (fallGoodsItemList == null || null == goodsDataList)
                {
                    result = -200;
                }
                else if (fallGoodsItemList.Count != goodsDataList.Count)
                {
                    result = -200;
                }
                else
                {
                    double numPercent = YangGongBKManager.YangGongBKNumPercents[yangGongBKItem.ClickBKNum];
                    int    findIndex  = -1;
                    for (int i = 0; i < fallGoodsItemList.Count; i++)
                    {
                        int randNum = Global.GetRandomNumber(1, 10001);
                        int percent = fallGoodsItemList[i].SelfPercent;
                        if (fallGoodsItemList[i].IsGood)
                        {
                            percent = (int)((double)percent * numPercent);
                        }
                        if (randNum <= percent)
                        {
                            if (!yangGongBKItem.PickUpDict.ContainsKey(goodsDataList[i].Id))
                            {
                                findIndex = i;
                                break;
                            }
                        }
                    }
                    if (-1 == findIndex)
                    {
                        int maxIndex   = -1;
                        int maxPercent = 0;
                        for (int i = 0; i < fallGoodsItemList.Count; i++)
                        {
                            if (!yangGongBKItem.PickUpDict.ContainsKey(goodsDataList[i].Id))
                            {
                                if (fallGoodsItemList[i].SelfPercent > maxPercent)
                                {
                                    maxIndex   = i;
                                    maxPercent = fallGoodsItemList[i].SelfPercent;
                                }
                            }
                        }
                        findIndex = maxIndex;
                    }
                    if (findIndex < 0)
                    {
                        result = -300;
                    }
                    else
                    {
                        goodsData = goodsDataList[findIndex];
                        result    = findIndex;
                    }
                }
            }
            return(result);
        }
コード例 #3
0
        /// <summary>
        /// 从杨公宝库的处理中选宝的操作
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public static int ClickYangGongBK(GameClient client, YangGongBKItem yangGongBKItem, out GoodsData goodsData)
        {
            goodsData = null;
            if (null == YangGongBKNumPercents)
            {
                YangGongBKNumPercents = GameManager.systemParamsList.GetParamValueDoubleArrayByName("YangGongBKNumPercents");
            }

            if (null == YangGongBKNumPercents || YangGongBKNumPercents.Length != 4)
            {
                return(-1000);
            }

            List <FallGoodsItem> fallGoodsItemList = yangGongBKItem.FallGoodsItemList;
            List <GoodsData>     goodsDataList     = yangGongBKItem.GoodsDataList;

            //List<GoodsData> tempGoodsDataList = yangGongBKItem.TempGoodsDataList;
            if (null == fallGoodsItemList || null == goodsDataList)
            {
                return(-200);
            }

            if (fallGoodsItemList.Count != goodsDataList.Count)
            {
                return(-200);
            }

            /*int findIndex = Global.GetRandomNumber(0, tempGoodsDataList.Count);
             * if (findIndex < 0)
             * {
             *  return -300;
             * }
             *
             * goodsData = tempGoodsDataList[findIndex];
             * tempGoodsDataList.RemoveAt(findIndex);
             * return findIndex;*/

            double numPercent = YangGongBKNumPercents[yangGongBKItem.ClickBKNum];

            int findIndex = -1;

            for (int i = 0; i < fallGoodsItemList.Count; i++)
            {
                int randNum = Global.GetRandomNumber(1, 10001);
                int percent = fallGoodsItemList[i].SelfPercent;
                if (fallGoodsItemList[i].IsGood)
                {
                    percent = (int)(percent * numPercent);
                }

                if (randNum <= percent)
                {
                    if (yangGongBKItem.PickUpDict.ContainsKey(goodsDataList[i].Id))
                    {
                        continue;
                    }

                    findIndex = i;
                    break;
                }
            }

            if (-1 == findIndex) //如果通过随机概率没有找到了物品
            {
                int maxIndex   = -1;
                int maxPercent = 0;
                for (int i = 0; i < fallGoodsItemList.Count; i++)
                {
                    if (yangGongBKItem.PickUpDict.ContainsKey(goodsDataList[i].Id))
                    {
                        continue;
                    }

                    if (fallGoodsItemList[i].SelfPercent > maxPercent)
                    {
                        maxIndex   = i;
                        maxPercent = fallGoodsItemList[i].SelfPercent;
                    }
                }

                findIndex = maxIndex;
            }

            if (findIndex < 0)
            {
                return(-300);
            }

            goodsData = goodsDataList[findIndex];
            return(findIndex);
        }
コード例 #4
0
        public static YangGongBKItem OpenYangGongBK(GameClient client, bool isBaoWuBinding)
        {
            YangGongBKItem yangGongBKItem  = null;
            int            yangGongFallID  = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID1", -1);
            int            yangGongFallID2 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID2", -1);
            int            yangGongFallID3 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID3", -1);
            int            yangGongFallID4 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID4", -1);
            int            yangGongFallID5 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID5", -1);
            int            yangGongFallID6 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID6", -1);
            int            yangGongFallID7 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID7", -1);
            int            yangGongFallID8 = (int)GameManager.systemParamsList.GetParamValueIntByName("YangGongFallID8", -1);
            YangGongBKItem result;

            if (yangGongFallID <= 0 || yangGongFallID2 <= 0 || yangGongFallID3 <= 0 || yangGongFallID4 <= 0)
            {
                result = yangGongBKItem;
            }
            else if (yangGongFallID5 <= 0 || yangGongFallID6 <= 0 || yangGongFallID7 <= 0 || yangGongFallID8 <= 0)
            {
                result = yangGongBKItem;
            }
            else
            {
                List <FallGoodsItem> gallGoodsItemList  = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID, 1, false);
                List <FallGoodsItem> gallGoodsItemList2 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID2, 1, false);
                List <FallGoodsItem> gallGoodsItemList3 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID3, 1, false);
                List <FallGoodsItem> gallGoodsItemList4 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID4, 1, false);
                List <FallGoodsItem> gallGoodsItemList5 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID5, 1, true);
                List <FallGoodsItem> gallGoodsItemList6 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID6, 1, true);
                List <FallGoodsItem> gallGoodsItemList7 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID7, 1, true);
                List <FallGoodsItem> gallGoodsItemList8 = GameManager.GoodsPackMgr.GetRandomFallGoodsItemList(yangGongFallID8, 1, true);
                if (gallGoodsItemList == null || gallGoodsItemList2 == null || gallGoodsItemList3 == null || null == gallGoodsItemList4)
                {
                    result = yangGongBKItem;
                }
                else if (gallGoodsItemList5 == null || gallGoodsItemList6 == null || gallGoodsItemList7 == null || null == gallGoodsItemList8)
                {
                    result = yangGongBKItem;
                }
                else if (1 != gallGoodsItemList.Count || 1 != gallGoodsItemList2.Count || 1 != gallGoodsItemList3.Count || 1 != gallGoodsItemList4.Count)
                {
                    result = yangGongBKItem;
                }
                else if (1 != gallGoodsItemList5.Count || 1 != gallGoodsItemList6.Count || 1 != gallGoodsItemList7.Count || 1 != gallGoodsItemList8.Count)
                {
                    result = yangGongBKItem;
                }
                else
                {
                    gallGoodsItemList.AddRange(gallGoodsItemList2);
                    gallGoodsItemList.AddRange(gallGoodsItemList3);
                    gallGoodsItemList.AddRange(gallGoodsItemList4);
                    gallGoodsItemList.AddRange(gallGoodsItemList5);
                    gallGoodsItemList.AddRange(gallGoodsItemList6);
                    gallGoodsItemList.AddRange(gallGoodsItemList7);
                    gallGoodsItemList.AddRange(gallGoodsItemList8);
                    gallGoodsItemList = Global.RandomSortList <FallGoodsItem>(gallGoodsItemList);
                    List <GoodsData> goodsDataList     = GameManager.GoodsPackMgr.GetGoodsDataListFromFallGoodsItemList(gallGoodsItemList);
                    List <GoodsData> tempGoodsDataList = new List <GoodsData>();
                    for (int i = 0; i < goodsDataList.Count; i++)
                    {
                        tempGoodsDataList.Add(goodsDataList[i]);
                    }
                    yangGongBKItem = new YangGongBKItem
                    {
                        FallGoodsItemList = gallGoodsItemList,
                        GoodsDataList     = goodsDataList,
                        IsBaoWuBinding    = isBaoWuBinding,
                        TempGoodsDataList = tempGoodsDataList
                    };
                    result = yangGongBKItem;
                }
            }
            return(result);
        }