示例#1
0
 public static short IsComplete(GameUser user, StoryTaskInfo taskInfo)
 {
     if (user.UserLv >= taskInfo.TaskLv)
     {
         int collectNum = TrumpHelper.GetUserItemNum(user.UserID, taskInfo.TargetItemID);
         if (collectNum >= taskInfo.TargetItemNum)
         {
             return 1;
         }
         else
         {
             return 0;
         }
     }
     return 2;
 }
示例#2
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;
 }
示例#3
0
文件: Action3007.cs 项目: 0jpq0/Scut
        public override bool TakeAction()
        {
            bool result = true;
            taskInfo = new ConfigCacheSet<StoryTaskInfo>().FindKey(TaskID);
            if (taskInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                //this.ErrorInfo = LanguageManager.GetLang().St3002_NotFind;
                SaveLog(new Exception(string.Format("{0},User:{1},task:{2}", LanguageManager.GetLang().St3002_NotFind, ContextUser.UserID, TaskID)));
                return false;
            }
            _userGeneral = UserGeneral.GetMainGeneral(Uid);
            //获得奖励
            UserTask userTask = new GameDataCacheSet<UserTask>().FindKey(ContextUser.UserID, TaskID);
            if (userTask == null || userTask.TaskState != TaskState.Completed)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St3007_NoCompleted;
                return false;
            }
            //交付物品任务扣除材料
            if (taskInfo.TermsType == PlotTermsType.Shouji || taskInfo.TermsType == PlotTermsType.Delivery)
            {
                UserItemHelper.UseUserItem(Uid, taskInfo.TargetItemID, taskInfo.TargetItemNum);
            }
            userTask.TaskState = TaskState.Close;
            UserTaskLog taskLog = new UserTaskLog()
            {
                LogID = Guid.NewGuid().ToString(),
                TaskID = userTask.TaskID,
                UserID = userTask.UserID,
                TaskType = userTask.TaskType,
                TaskState = userTask.TaskState,
                TaskPrize = string.Format("Experience:{0},GameCoin:{1};GameCoin:{2} ",
                    taskInfo.Experience,
                    taskInfo.GameCoin,
                    ContextUser.GameCoin
                ),
                CreateDate = DateTime.Now
            };
            var sender = DataSyncManager.GetDataSender();
            sender.Send(taskLog);

            ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, taskInfo.GameCoin, int.MaxValue);
            if (taskInfo.TaskType == TaskType.Master && ContextUser.TaskProgress < TaskID)
            {
                ContextUser.TaskProgress = TaskID;
            }
            //ContextUser.Update();

            //任务加佣兵经验
            //var userEmbattles = new GameDataCacheSet<UserEmbattle>().FindAll(UserEmbattle.Index_UserID_MagicID, Uid, ContextUser.UseMagicID);
            //foreach (var userEmbattle in userEmbattles)
            //{
            //    UserGeneral userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(ContextUser.UserID, userEmbattle.GeneralID);
            //    if (userGeneral == null) continue;
            //    userGeneral.CurrExperience = MathUtils.Addition(userGeneral.CurrExperience, taskInfo.Experience, int.MaxValue);
            //    //userGeneral.Update();
            //}
            UserHelper.UserGeneralExp(ContextUser.UserID,taskInfo.Experience);

            //开启功能
            TaskHelper.EnableFunction(ContextUser, taskInfo.FunctionEnum);

            //下发可接任务
            TaskHelper.SendAllowTask(ContextUser, TaskID);

            //开启副本
            PlotHelper.EnablePlot(Uid, taskInfo.EnablePlot);

            //保留主线任务
            var cacheSet = new GameDataCacheSet<UserTask>();
            if (userTask.TaskType == TaskType.Master)
            {
                //userTask.Update();
            }
            else
            {
                //原因:最后支线任务无限刷新BUG
                if (!TaskHelper.IsLastTask(userTask))
                {
                    cacheSet.Delete(userTask);
                }
            }
            return result;
        }
示例#4
0
 /// <summary>
 /// 任务是否完成
 /// </summary>
 /// <param name="user"></param>
 /// <param name="taskInfo"></param>
 /// <returns></returns>
 public static short IsComplete(GameUser user, StoryTaskInfo taskInfo)
 {
     UserTask userTask = new PersonalCacheStruct<UserTask>().FindKey(user.UserID, taskInfo.TaskID);
     if (userTask != null && userTask.TaskState == TaskState.Close)
     {
         return 3;
     }
     if (taskInfo.TaskLv > user.UserLv)
     {
         return 0;
     }
     if (user.UserLv >= taskInfo.TaskLv)
     {
         int collectNum = TrumpHelper.GetUserItemNum(user.UserID, taskInfo.TargetItemID);
         if (collectNum >= taskInfo.TargetItemNum)
         {
             return 2;
         }
         else
         {
             return 1;
         }
     }
     return 0;
 }