Example #1
0
        public override bool TakeAction()
        {
            TaskHelper.CheckStoryCompleted(ContextUser.UserID);
            //增加初始任务
            userTaskList = TaskHelper.SendAllowTask(ContextUser, ContextUser.TaskProgress);

            userTaskList = new GameDataCacheSet <UserTask>().FindAll(ContextUser.UserID, m => m.TaskType.Equals(TaskType) && m.TaskState != TaskState.Close);
            userTaskList.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(x.TaskID.CompareTo(y.TaskID));
            });
            return(true);
        }
Example #2
0
        public override bool TakeAction()
        {
            TaskHelper.CheckStoryCompleted(ContextUser.UserID);

            List <StoryTaskInfo> taskinfoArray = new ShareCacheStruct <StoryTaskInfo>().FindAll(m => m.PlotID == 1001);

            if (taskinfoArray.Count == 0)
            {
                return(false);
            }
            //增加初始任务
            _userTaskList = TaskHelper.SendAllowTask(ContextUser, ContextUser.TaskProgress);

            if (_ops == 0)
            {
                _userTaskList = new PersonalCacheStruct <UserTask>().FindAll(ContextUser.UserID,
                                                                             m => m.TaskType < TaskType.Daily &&
                                                                             (m.TaskState == TaskState.AllowTake ||
                                                                              m.TaskState == TaskState.Taked ||
                                                                              m.TaskState == TaskState.Completed ||
                                                                              (m.TaskType == TaskType.Master && m.TaskState == TaskState.NoTake))
                                                                             );
            }
            else if (_ops == 1)
            {
                //当前任务
                _userTaskList = new PersonalCacheStruct <UserTask>().FindAll(
                    ContextUser.UserID,
                    m => m.TaskType < TaskType.Daily && (m.TaskState == TaskState.Taked || m.TaskState == TaskState.Completed)
                    );
            }
            else if (_ops == 2)
            {
                //可接任务
                List <UserTask> taskArray = new PersonalCacheStruct <UserTask>().FindAll(
                    ContextUser.UserID,
                    m => m.TaskType < TaskType.Daily && m.TaskState == TaskState.NoTake
                    );
                foreach (UserTask userTask in taskArray)
                {
                    StoryTaskInfo taskInfo = new ShareCacheStruct <StoryTaskInfo>().FindKey(userTask.TaskID);
                    if (taskInfo != null && taskInfo.TaskLv <= ContextUser.UserLv)
                    {
                        userTask.TaskState = TaskState.AllowTake;
                        //userTask.Update();
                    }
                }

                _userTaskList = new PersonalCacheStruct <UserTask>().FindAll(
                    ContextUser.UserID,
                    m => m.TaskType < TaskType.Daily && (m.TaskState == TaskState.AllowTake)
                    );
            }

            _userTaskList.QuickSort(
                (x, y) =>
            {
                if (x.TaskState == TaskState.AllowTake && y.TaskState == TaskState.Taked)
                {
                    return(1);
                }
                else if (y.TaskState == TaskState.AllowTake && x.TaskState == TaskState.Taked)
                {
                    return(-1);
                }
                else
                {
                    return(x.TaskState.CompareTo(y.TaskState));
                }
            }
                );
            return(true);
        }