Beispiel #1
0
        /// <summary>
        /// 检索目标数量
        /// </summary>
        /// <param name="taskInfo"></param>
        /// <param name="plotNpcId"></param>
        /// <param name="currMonsterList"></param>
        /// <returns></returns>
        private static List <string> FindTargetMonsterNum(StoryTaskInfo taskInfo, int plotNpcId, string[] currMonsterList)
        {
            string[]      targetMonsterList    = taskInfo.TargetMonsterID.ToNotNullString().Split(',');
            string[]      targetMonsterNumList = ObjectExtend.ToNotNullString(taskInfo.TargetMonsterNum).Split(',');
            List <string> targetNumList        = new List <string>();
            int           index = 0;

            foreach (string monster in targetMonsterList)
            {
                int num = currMonsterList.Length > index?ObjectExtend.ToInt(currMonsterList[index]) : 0;

                int maxNum = targetMonsterNumList.Length > index?ObjectExtend.ToInt(targetMonsterNumList[index]) : 0;

                if (num < maxNum)
                {
                    var plotEmbattleList = new ConfigCacheSet <PlotEmbattleInfo>().FindAll(m => m.PlotNpcID == plotNpcId);
                    foreach (PlotEmbattleInfo plotEmbattle in plotEmbattleList)
                    {
                        if (plotEmbattle.MonsterID == ObjectExtend.ToInt(monster))
                        {
                            num += 1;
                        }
                    }
                    targetNumList.Add(num.ToString());
                }
                else
                {
                    targetNumList.Add(maxNum.ToString());
                }
                index++;
            }
            return(targetNumList);
        }
Beispiel #2
0
        public override bool TakeAction()
        {
            List <UserTakePrize> userPrizeList = new ShareCacheStruct <UserTakePrize>().FindAll(m => !m.IsTasked && m.UserID == ObjectExtend.ToInt(Uid));

            if (userPrizeList.Count > 0)
            {
                var userPrize = userPrizeList[0];
                if (userPrize.ItemPackage.Length > 0)
                {
                    if (UserItemHelper.CheckItemOut(ContextUser, ItemStatus.BeiBao, PutItemNum(userPrize)))
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St1107_GridNumFull;
                        return(false);
                    }
                }
                if (userPrize.SparePackage.Length > 0)
                {
                    int currNum = ContextUser.SparePartList.FindAll(m => string.IsNullOrEmpty(m.UserItemID)).Count;
                    currNum = MathUtils.Addition(currNum, PutCrystalSpareNum(userPrize.SparePackage.Split(','), 1));
                    //原因:零件等于开启格子时提示背包已满
                    if (currNum > ContextUser.UserExtend.SparePartGridNum)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St1213_GridNumFull;
                        return(false);
                    }
                }

                if (userPrize.CrystalPackage.Length > 0)
                {
                    var package = UserCrystalPackage.Get(ContextUser.UserID);
                    UserCrystalInfo[] crystalArrayErr =
                        package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(0)).ToArray();
                    int crystalNum = MathUtils.Addition(crystalArrayErr.Length, PutCrystalSpareNum(userPrize.CrystalPackage.Split(','), 2));
                    //原因:命运水晶等于开启格子时提示背包已满
                    if (crystalNum > ContextUser.CrystalNum)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St1307_FateBackpackFull;
                        return(false);
                    }
                }

                if (!string.IsNullOrEmpty(userPrize.EnchantPackage) && userPrize.EnchantPackage.Length > 0)
                {
                    var package = UserEnchant.Get(ContextUser.UserID);
                    if (package != null)
                    {
                        var enchantList = package.EnchantPackage.FindAll(m => string.IsNullOrEmpty(m.UserItemID));
                        int enchantNum  = MathUtils.Addition(enchantList.Count, PutCrystalSpareNum(userPrize.EnchantPackage.Split(','), 2));
                        if (ContextUser.UserExtend != null && enchantNum > ContextUser.UserExtend.EnchantGridNum)
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St1259_EnchantGridNumFull;
                            return(false);
                        }
                    }
                }

                if (doProcessPrize(userPrize))
                {
                    ErrorInfo = userPrize.MailContent;
                }
                else
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
            }
            return(true);
        }