Exemplo n.º 1
0
        public int GetTypeCardByQuality(int quality, int type)
        {
            List <int> dropList = new List <int>();

            foreach (GunCard_TableItem item in TableMgr.singleton.GunCardTable.getEnumerator())
            {
                if (item.gunType != type)
                {
                    continue;
                }

                if (item.rarity != quality)
                {
                    continue;
                }

                dropList.Add(item.id);
            }

            var index  = BaseRandom.Next(0, dropList.Count);
            var cardID = dropList[index];

            Debug.Log(cardID + " GetTypeCardByQuality " + type);

            return(cardID);
        }
Exemplo n.º 2
0
        public int GetCampUnlockStage(int autoLevel)
        {
            if (autoLevel <= 0)
            {
                return(0);
            }

            List <Level_TableItem> list;

            if (!levelDic.TryGetValue(autoLevel, out list))
            {
                return(GetCampUnlockStage(autoLevel - 1));
            }

            var level = list[BaseRandom.Next(0, list.Count)];

            return(level.id);
        }
Exemplo n.º 3
0
        public int GetCardByQuality(int quality)
        {
            List <int> dropList;

            if (!cardsDic.TryGetValue(quality, out dropList))
            {
                return(0);
            }

            var index  = BaseRandom.Next(0, dropList.Count);
            var cardID = dropList[index];

            if (lockCardList.Contains(cardID))//卡牌是否解锁
            {
                Debug.Log("卡牌未解锁");
                return(GetCardByQuality(quality));
            }

            return(cardID);
        }
Exemplo n.º 4
0
        private GameGoodsAddResult CheckGoodsAddResult(int goods_type, BigInteger goods_count, int goods_param)
        {
            GameGoodsAddResult result    = null;
            GoodsType          goodsType = (GoodsType)goods_type;

            switch (goodsType)
            {
            case GoodsType.DIAMOND:
            {
                result = new GameGoodsAddResult();
#if SERVER_CHECK
                result.requestType = GoodsRequestType.Network;
#else
                result.requestType = GoodsRequestType.Local;
#endif
                result.realAddGoods = new List <GameGoodData>()
                {
                    new GameGoodData()
                    {
                        type  = (GoodsType)goods_type,
                        count = goods_count,
                        param = goods_param,
                    }
                };
            }
            break;

            case GoodsType.GOLD:
            case GoodsType.KEY:
            case GoodsType.CAMPSITE_REWARD:
            {
                result              = new GameGoodsAddResult();
                result.requestType  = GoodsRequestType.Local;
                result.realAddGoods = new List <GameGoodData>()
                {
                    new GameGoodData()
                    {
                        type  = (GoodsType)goods_type,
                        count = goods_count,
                        param = goods_param,
                    }
                };
            }
            break;

            case GoodsType.CARD:
            {
                result              = new GameGoodsAddResult();
                result.requestType  = GoodsRequestType.Local;
                result.realAddGoods = new List <GameGoodData>();
                result.tips         = new HashSet <string>();
                CheckCardRealAdd((int)goods_count, goods_param, result.realAddGoods, result.tips);
            }
            break;

            case GoodsType.CARD_CHIP:
            {
                result              = new GameGoodsAddResult();
                result.requestType  = GoodsRequestType.Local;
                result.realAddGoods = new List <GameGoodData>();
                result.tips         = new HashSet <string>();
                CheckCardClipRealAdd((int)goods_count, goods_param, result.realAddGoods, result.tips);
            }
            break;

            case GoodsType.RANDOM_CARD:
            {
                List <int> cardList = PlayerDataMgr.singleton.GetDropCardsByQuality(goods_param);
                var        index    = BaseRandom.Next(0, cardList.Count);
                var        id       = cardList[index];
                result              = new GameGoodsAddResult();
                result.requestType  = GoodsRequestType.Local;
                result.realAddGoods = new List <GameGoodData>();
                result.tips         = new HashSet <string>();
                CheckCardRealAdd((int)goods_count, id, result.realAddGoods, result.tips);
            }
            break;

            case GoodsType.RANDOM_CARD_CHIP:
            {
                List <int> cardList = PlayerDataMgr.singleton.GetDropCardsByQuality(goods_param);
                var        index    = BaseRandom.Next(0, cardList.Count);
                var        id       = cardList[index];
                result              = new GameGoodsAddResult();
                result.requestType  = GoodsRequestType.Local;
                result.realAddGoods = new List <GameGoodData>();
                result.tips         = new HashSet <string>();
                CheckCardClipRealAdd((int)goods_count, id, result.realAddGoods, result.tips);
            }
            break;

            case GoodsType.GOLD_MINUTE:
            {
                var count = goods_count * IdleRewardMgr.singleton.GetGoldPerMinute();
                result              = new GameGoodsAddResult();
                result.requestType  = GoodsRequestType.Local;
                result.realAddGoods = new List <GameGoodData>()
                {
                    new GameGoodData()
                    {
                        type  = GoodsType.GOLD,
                        count = count,
                        param = goods_param,
                    }
                };
            }
            break;

            default:
                break;
            }

            return(result);
        }
Exemplo n.º 5
0
        private TaskInfo CreateTaskInfo(Task_TableItem task, int param)
        {
            var taskTypeRes = TableMgr.singleton.CampTaskTypeTable.GetItemByID(task.type);

            if (taskTypeRes == null)
            {
                return(null);
            }

            var info = new TaskInfo();

            info.taskID   = task.id;
            info.taskType = task.type;

            if (param > 0)
            {
                info.taskParam = param - 1;
            }

            switch ((TaskType)task.type)
            {
            //case TaskType.Finish_Battle:
            //    {
            //        info.conditionValue = GetFinishTaskCount(task.type) + task.value + campSetRes.taskDifficulty;
            //    }
            //    break;
            case TaskType.Occupy_Building:
            {
                if (info.taskParam >= 0)
                {
                    var pointData = CampsiteMgr.singleton.GetPointByIndex(info.taskParam);
                    if (pointData == null)
                    {
                        return(null);
                    }

                    info.conditionValue = 1;
                    return(info);
                }
                else
                {
                    CampsitePointMgr pointData = null;
                    for (int i = 0; i < campSetRes.CampBuildingArr.Length; ++i)
                    {
                        pointData = CampsiteMgr.singleton.GetPointByIndex(i);
                        if (pointData == null)
                        {
                            continue;
                        }

                        if (!pointData.isUnlock)
                        {
                            info.taskParam      = i;
                            info.conditionValue = 1;
                            return(info);
                        }
                    }
                }

                return(null);
            }

            case TaskType.Equip_Gun:
            {
                if (info.taskParam < 0)
                {
                    List <int> buildingList = new List <int>();
                    for (int i = 0; i < campSetRes.CampBuildingArr.Length; ++i)
                    {
                        var pointData = CampsiteMgr.singleton.GetPointByIndex(i);
                        if (pointData == null)
                        {
                            continue;
                        }

                        if (pointData.isUnlock)
                        {
                            buildingList.Add(campSetRes.CampBuildingArr[i]);
                        }
                    }

                    if (buildingList.Count > 0)
                    {
                        info.taskParam = BaseRandom.Next(0, buildingList.Count);
                    }
                    else
                    {
                        return(null);
                    }
                }

                info.conditionValue = GetFinishTaskCount(task.type) * task.value *
                                      campSetRes.taskDifficulty +
                                      campSetRes.AutoLevelArr[info.taskParam];
            }
            break;

            case TaskType.LvUp_Building:
            {
                if (info.taskParam < 0)
                {
                    //var index = GetFinishTaskCount(task.type) + GetContainTaskCount(task.type);
                    //Debug.Log("index " + index);
                    //var pointData = CampsiteMgr.singleton.GetPointByIndex(index);
                    //if (pointData == null)
                    //    return null;

                    //if (!pointData.isUnlock)
                    //{
                    //    return null;
                    //}
                    int index = -1;
                    for (int i = 0; i < campSetRes.CampBuildingArr.Length; ++i)
                    {
                        var pointData = CampsiteMgr.singleton.GetPointByIndex(i);
                        if (pointData == null)
                        {
                            continue;
                        }

                        if (pointData.isUnlock)
                        {
                            index = i;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (index <= GetFinishTaskParam(task.type))
                    {
                        return(null);
                    }

                    info.taskParam = index;
                }

                info.conditionValue = (int)(task.value * campSetRes.taskDifficulty *
                                            campSetRes.id * 0.3f) + 5;
            }
            break;

            case TaskType.Buildings_Level:
            {
                info.conditionValue = task.value * campSetRes.taskDifficulty *
                                      campSetRes.id / 2;
            }
            break;

            case TaskType.LevelUp_Gun:
            {
                if (info.taskParam < 0)
                {
                    var typeList = PlayerDataMgr.singleton.GetGunCardTypeList();
                    if (typeList.Count <= 0)
                    {
                        return(null);
                    }

                    info.taskParam = typeList[BaseRandom.Next(0, typeList.Count)];
                }
                info.conditionValue = GetFinishTaskCount(task.type) * 2 + task.value + campSetRes.taskDifficulty;
            }
            break;

            case TaskType.Supplies_Add:
            {
                //if (CampsiteMgr.singleton.TotalRewardRate <= 0.0f)
                //{
                //    return null;
                //}

                info.conditionValue = (BigInteger)(CampsiteMgr.singleton.TotalRewardRate *
                                                   task.value * campSetRes.taskDifficulty);
            }
            break;

            case TaskType.Cost_Gold:
            case TaskType.Get_Gold:
            {
                info.conditionValue = (BigInteger)(IdleRewardMgr.singleton.GetGoldPerMinute() *
                                                   (GetFinishTaskCount(task.type) + 1) * task.value * 0.5f *
                                                   campSetRes.taskDifficulty);
            }
            break;

            case TaskType.Quick_Reward:
            case TaskType.Open_Box:
            case TaskType.Fuse_Gun:
            case TaskType.Explore_Gold:
            case TaskType.Lv10_Gun:
            case TaskType.Finish_Battle:
            {
                info.conditionValue = task.value;
            }
            break;

            case TaskType.Epic_Gun:
            {
                info.conditionValue = 1;
            }
            break;

            case TaskType.Auto_Level:
            {
                if (info.taskParam < 0)
                {
                    int index = 0;
                    for (int i = 0; i < campSetRes.CampBuildingArr.Length; ++i)
                    {
                        var pointData = CampsiteMgr.singleton.GetPointByIndex(i);
                        if (pointData == null)
                        {
                            continue;
                        }

                        if (pointData.isUnlock)
                        {
                            index = i;
                        }
                        else
                        {
                            break;
                        }
                    }

                    info.taskParam = index;
                }

                var data = CampsiteMgr.singleton.GetPointByIndex(info.taskParam);
                if (data == null)
                {
                    return(null);
                }
                info.conditionValue = 1;
            }
            break;
            }

            return(info);
        }
Exemplo n.º 6
0
        public List <int> DrawCard(int boxID, int times, out int drawCount)
        {
            if (!PlayerDataMgr.singleton.DB.boxDrawDic.TryGetValue(boxID, out drawCount))
            {
                drawCount = 0;
            }

            var boxRes = TableMgr.singleton.BoxTable.GetItemByID(boxID);

            if (boxRes == null)
            {
                return(null);
            }

            Debug.Log("OpenBox " + boxID);
            Debug.Log("drawCount " + drawCount);

            var q = (int)CardQualityType.LEGEND;
            //cardQualityDic.Clear();
            List <int> cardQualityList = new List <int>();
            float      allRate         = 0.0f;

            for (int i = 0; i < boxRes.cardRateList.Length; ++i)//确定宝箱品质总概率
            {
                var quality = i + 1;
                if (!cardsDic.ContainsKey(quality))
                {
                    continue;
                }

                if (quality == q)
                {
                    //cardQualityDic[quality] = 0;
                    continue;
                }

                if (boxRes.cardRateList[i] > 0.0f)
                {
                    allRate += boxRes.cardRateList[i];
                    //cardQualityDic[quality] = 0;
                }
            }

            Debug.Log("allRate " + allRate);
            List <int> cardList = new List <int>();

            for (int i = 0; i < times; ++i)//随机宝箱各品质的数量
            {
                drawCount++;
                if (PlayerDataMgr.singleton.DB.boxDrawCount <
                    TableMgr.singleton.ValueTable.BoxAwardGunArr.Length)
                {
                    var cardID = TableMgr.singleton.ValueTable.BoxAwardGunArr[PlayerDataMgr.singleton.DB.boxDrawCount];
                    //cardID = GetTypeCardByQuality(quality, type);
                    cardList.Add(cardID);
                    PlayerDataMgr.singleton.DB.boxDrawCount++;

                    continue;
                }

                if (drawCount >= boxRes.awardCount)
                {//宝箱保底
                    //cardQualityDic[q] += 1;
                    cardQualityList.Add(q);
                    drawCount = 0;
                    continue;
                }

                bool b = PRD.Winning(drawCount, boxRes.cardRateList[q - 1]);
                if (b)
                {
                    //cardQualityDic[q] += 1;
                    cardQualityList.Add(q);
                    drawCount = 0;
                    continue;
                }

                var rate = BaseRandom.Next(0.0f, allRate);
                var all  = 0.0f;
                for (int j = 0; j < boxRes.cardRateList.Length - 1; ++j)
                {
                    all += boxRes.cardRateList[j];
                    if (rate < all)
                    {
                        //cardQualityDic[j + 1] += 1;
                        cardQualityList.Add(j + 1);
                        break;
                    }
                }
            }


            for (int i = 0; i < cardQualityList.Count; ++i)
            {
                var quality = cardQualityList[i];
                //int count = 0;
                //if (!cardQualityDic.TryGetValue(quality, out count))
                //    continue;

                //Debug.LogFormat("quality{0} count{1}", quality, count);
                //for (int j = 0; j < count; ++j)
                //{
                var cardID = GetCardByQuality(quality);

                cardList.Add(cardID);
                //}
            }

            Debug.Log("drawCount :" + drawCount);


            return(cardList);
        }