Beispiel #1
0
        /// <summary>
        /// 周式任务
        /// </summary>
        /// <param name="pb"></param>
        /// <param name="npcid"></param>
        /// <param name="isremove"></param>
        public static void WeekTask(PlayerBusiness pb, string npcid, bool isremove)
        {
            string soleid = pb.ID + "WeekTask";
            if (!m_dic.TryAdd(soleid, soleid))
                return;
            try
            {
                int cur = pb.WeekTotal(8);
                int max = Convert.ToInt32(TipManager.GetMessage(TaskReturn.LoopMax));
                if (cur >= max)
                    return;

                //表示一个环式任务都没有做的情况
                GameConfig gc = null;//要触发的任务
                Task t = TaskAccess.Instance.GetWeekTask(pb.ID);
                if (t == null)
                {
                    //触发新的任务
                    if (cur == 0)
                    {
                       gc = GameConfigAccess.Instance.GetFristWeek(pb.Level, 8);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(npcid))
                        {
                            gc = GameConfigAccess.Instance.GetWeekTask(npcid, 8, pb.Level);
                        }
                    }
                }
                else
                {
                    DateTime dt = DateTime.Now;

                    string taskid = t.Value.GetStringOrDefault("TaskID");
                    //任务触发时间
                    DateTime created = t.Created.ToLocalTime();
                    if (!ActivityManager.LocalWeek(created, dt))
                    {
                        //移除任务
                        DeleteTask(pb, new List<string>() { taskid }, isremove);
                        //触发第一个任务
                        gc = GameConfigAccess.Instance.GetFristWeek(pb.Level, 8);
                    }
                }

                if (gc == null)
                    return;

                //表示没有任务
                Task task = TaskAccess.Instance.TaskBase(pb.ID, pb.RoleID, gc, (cur + 1), pb.Level);
                if (task == null)
                    return;

                if (isremove)
                {
                    pb.Call(TaskCommand.TaskActivationR, TaskAccess.Instance.GetTaskInfo(task));
                }
            }
            finally
            {
                m_dic.TryRemove(soleid, out soleid);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 任务触发
        /// </summary>
        /// <param name="note"></param>
        /// <param name="gc"></param>
        public static void TaskStartBusiness(PlayerBusiness pb, GameConfig gc, bool IsCall = true)
        {
            if (!TaskAccess.Instance.TaskLimit(pb.ID, pb.Level, gc.ID, gc.Value))
            {
                return;
            }
            int loopcount = 0;
            if (gc.Value.GetIntOrDefault("TaskType") == 8)
            {
                loopcount = pb.WeekTotal(8) + 1;
            }

            Task task = TaskAccess.Instance.TaskBase(pb.ID, pb.RoleID, gc, loopcount, pb.Level);

            if (IsCall && task != null)
            {
                pb.Call(TaskCommand.TaskActivationR, TaskAccess.Instance.GetTaskInfo(task));
            }
        }