コード例 #1
0
ファイル: RouterManager.cs プロジェクト: wuhuolong/MaxBooks
        public bool GotoGuildTask(params object[] args)
        {
            if (!SysConfigManager.GetInstance().CheckSysHasOpened(GameConst.SYS_OPEN_QUEST_GUILD, true))
            {
                return(false);
            }
            if (!CheckSysDownloaded(GameConst.SYS_OPEN_QUEST_GUILD))
            {
                return(false);
            }

            // 记录当弹出退出提示的时候是否要继续自动战斗
            if (SceneHelp.Instance.IsInInstance == true || SceneHelp.Instance.IsCanExitBtnInWild == true)
            {
                SceneHelp.Instance.IsAutoFightingWhenShowExitTips = InstanceManager.Instance.IsAutoFighting || SceneHelp.Instance.IsAutoFightingWhenShowExitTips;
            }

            GuildTaskInfo guildTaskInfo = TaskManager.Instance.GuildTaskInfo;
            List <Task>   tasks         = TaskManager.Instance.VisibleGuildTasks;
            bool          isGoto        = false;

            if (guildTaskInfo == null)
            {
                isGoto = false;
            }
            else
            {
                if (tasks.Count > 0)
                {
                    isGoto = true;
                }
                else
                {
                    isGoto = false;
                }
            }
            if (isGoto == true)
            {
                TaskHelper.TaskGuide(tasks[0]);
            }
            else
            {
                if (guildTaskInfo != null && guildTaskInfo.reward_state == 1)
                {
                    xc.ui.ugui.UIManager.Instance.ShowSysWindow("UITaskWindow", xc.GameConst.QUEST_GUILD, null);
                }
                else
                {
                    TaskHelper.AcceptGuildTaskGuide();
                }
            }
            UIManager.Instance.CloseSysWindow("UITowerClimbWindow");

            return(true);
        }
コード例 #2
0
ファイル: NpcHelper.cs プロジェクト: wuhuolong/MaxBooks
        /// <summary>
        /// 该NPC能否接取帮派任务
        /// </summary>
        public static bool NpcCanAcceptGuildTask(uint npcJsonId)
        {
            if (TaskManager.Instance.VisibleGuildTasks.Count == 0 && LocalPlayerManager.Instance.GuildID > 0 && SysConfigManager.GetInstance().CheckSysHasOpened(GameConst.SYS_OPEN_QUEST_GUILD) == true)
            {
                List <uint> accpetNpcParams = xc.GameConstHelper.GetUintList("GAME_QUEST_GUILD_ACCEPT_NPC");
                if (accpetNpcParams.Count > 2)
                {
                    if (accpetNpcParams[0] == SceneHelp.Instance.CurSceneID && accpetNpcParams[1] == npcJsonId)
                    {
                        GuildTaskInfo guildTaskInfo = TaskManager.Instance.GuildTaskInfo;
                        if (guildTaskInfo != null && guildTaskInfo.num < TaskHelper.GetGuildTaskMaxTimes())
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #3
0
ファイル: TaskNet.cs プロジェクト: wuhuolong/MaxBooks
        public static void HandleServerData(ushort protocol, byte[] data)
        {
            switch (protocol)
            {
            case NetMsg.MSG_TASK_INFO:
            {
                S2CTaskInfo pack = S2CPackBase.DeserializePack <S2CTaskInfo>(data);

                // 首先所有任务的置顶取消
                foreach (Task task in TaskManager.Instance.AllTasks)
                {
                    task.IsOnTop = false;
                }

                IsFirstReceiveTaskInfo = !Game.Instance.AllSystemInited;

                List <Task> newTasks = new List <Task>();
                newTasks.Clear();
                List <Task> finishedTasks = new List <Task>();
                finishedTasks.Clear();
                List <Task> newAcceptTasks = new List <Task>();
                newAcceptTasks.Clear();
                List <Task> doneTasks = new List <Task>();
                doneTasks.Clear();
                List <Task> tasksToGuide = new List <Task>();
                tasksToGuide.Clear();
                bool isTitleTaskChanged  = false;           // 头衔任务是否改变
                bool isEscortTaskChanged = false;           // 护送任务是否改变
                foreach (PkgTaskInfo taskInfo in pack.tasks)
                {
                    bool isNewTask = false;
                    if (TaskManager.Instance.HasTask(taskInfo.id))
                    {
                        TaskManager.Instance.DeleteTask(taskInfo.id);
                    }
                    else
                    {
                        isNewTask = true;
                    }

                    var dbTask = TaskDefine.MakeDefine(taskInfo.id);
                    if (dbTask == null)
                    {
                        GameDebug.LogError("Error!!! Can not find task data in db by id " + taskInfo.id);
                        continue;
                    }

                    Task task = new Task(dbTask);

                    uint index = 1;
                    foreach (var step in dbTask.Steps)
                    {
                        Task.StepProgress stepProgress = new Task.StepProgress();
                        stepProgress.StepId = index;
                        if (taskInfo.value.Count > 0)
                        {
                            stepProgress.CurrentValue = taskInfo.value[0];
                        }
                        else
                        {
                            stepProgress.CurrentValue = 0;
                        }

                        task.StepProgresss.Add(stepProgress);

                        ++index;
                    }

                    task.StepProgresss.Sort();
                    task.State     = taskInfo.state;
                    task.StartTime = taskInfo.start_time;
                    if (taskInfo.step > 0)
                    {
                        task.CurrentStepIndex = taskInfo.step - 1;
                    }
                    else
                    {
                        task.CurrentStepIndex = 0;
                    }

                    // 提高任务显示优先级
                    if (IsFirstReceiveTaskInfo == false)
                    {
                        // 头衔任务不受动态排序规则影响
                        if (task.Define.Type != GameConst.QUEST_TITLE)
                        {
                            Task.IncreaseCurDynamicShowPriority();
                            task.DynamicShowPriority = Task.CurDynamicShowPriority;
                        }
                    }

                    TaskManager.Instance.AddTask(task);

                    if (task.State == GameConst.QUEST_STATE_DONE)
                    {
                        Task.StepProgress   stepProgress = task.CurrentStepProgress;
                        TaskDefine.TaskStep curStep      = task.CurrentStep;
                        if (stepProgress != null && curStep != null)
                        {
                            stepProgress.CurrentValue = curStep.ExpectResult;
                        }
                    }

                    // 是否是新接取的任务
                    if (IsFirstReceiveTaskInfo == false && task.State == GameConst.QUEST_STATE_DOING)
                    {
                        if (task.CurrentStepProgress != null && task.CurrentStepProgress.CurrentValue == 0)
                        {
                            newAcceptTasks.Add(task);
                        }
                    }

                    // 是否自动执行,进入游戏首次收到这个消息不执行副本状态下不执行,新任务不执行,不是在追踪状态的任务不执行
                    if (IsFirstReceiveTaskInfo == false && SceneHelp.Instance.IsInNormalWild() == true && task.Define.AutoRunType != TaskDefine.EAutoRunType.None)
                    {
                        // 不可接或者失效的任务不可自动执行
                        if (taskInfo.state != GameConst.QUEST_STATE_UNACCEPT && taskInfo.state != GameConst.QUEST_STATE_INVALID)
                        {
                            if ((task.Define.AutoRunType == TaskDefine.EAutoRunType.AutoRun && InstanceManager.Instance.IsOnHook == false) || task.Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun)
                            {
                                // 如果当前正在导航的任务的自动执行是ForceAutoRun2,则其他任务的自动执行不会打断它
                                Task navigatingTask = TaskManager.Instance.NavigatingTask;
                                if (navigatingTask == null || navigatingTask.Define.AutoRunType != TaskDefine.EAutoRunType.ForceAutoRun2)
                                {
                                    if (taskInfo.state == GameConst.QUEST_STATE_DOING || taskInfo.state == GameConst.QUEST_STATE_DONE)
                                    {
                                        tasksToGuide.Add(task);
                                    }
                                }
                            }
                            else if (task.Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun2)
                            {
                                tasksToGuide.Add(task);
                            }
                        }
                    }

                    if (IsFirstReceiveTaskInfo == false)
                    {
                        if (taskInfo.state == GameConst.QUEST_STATE_FIN)
                        {
                            finishedTasks.Add(task);
                        }
                    }

                    if (IsFirstReceiveTaskInfo == false)
                    {
                        if (taskInfo.state == GameConst.QUEST_STATE_DONE)
                        {
                            doneTasks.Add(task);
                        }
                    }

                    // 任务进度飘字
                    if (isNewTask == false && taskInfo.state == GameConst.QUEST_STATE_DONE)
                    {
                        TaskHelper.ShowTaskProgressTips(task);
                    }

                    if (IsFirstReceiveTaskInfo == false && isNewTask == true)
                    {
                        newTasks.Add(task);
                    }

                    if (task.Define.Type == GameConst.QUEST_TITLE)
                    {
                        isTitleTaskChanged = true;
                    }
                    if (task.Define.Type == GameConst.QUEST_ESCORT)
                    {
                        isEscortTaskChanged = true;
                    }
                }

                //TaskManager.Instance.SortTaskList();

                //ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_CHANGED, null);
                StartTaskChangedCoroutine();

                if (isTitleTaskChanged == true)
                {
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.TITLE_TASK_CHANGED, null);
                }
                if (isEscortTaskChanged == true)
                {
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.ESCORT_TASK_CHANGED, null);
                }

                if (finishedTasks.Count > 0)
                {
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_FINISHED, new CEventBaseArgs(finishedTasks[0].Define.Id));

                    if (finishedTasks[0].Define.SubmitedTimelineId > 0)
                    {
                        // 是否是婚宴剧情动画
                        if (finishedTasks[0].Define.SubmitedTimelineId == GameConstHelper.GetUint("GAME_WEDDING_DRAMA_TIMELINE_ID_1"))
                        {
                            TimelineManager.Instance.PlayWeddingChapelTimeline();
                        }
                        else
                        {
                            TimelineManager.Instance.Play(finishedTasks[0].Define.SubmitedTimelineId);
                        }
                    }
                }

                if (newAcceptTasks.Count > 0)
                {
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_NEW_ACCEPTED, new CEventBaseArgs(newAcceptTasks[0].Define.Id));

                    if (newAcceptTasks[0].Define.ReceivedTimelineId > 0)
                    {
                        // 是否是婚宴剧情动画
                        if (newAcceptTasks[0].Define.ReceivedTimelineId == GameConstHelper.GetUint("GAME_WEDDING_DRAMA_TIMELINE_ID_1"))
                        {
                            TimelineManager.Instance.PlayWeddingChapelTimeline();
                        }
                        else
                        {
                            TimelineManager.Instance.Play(newAcceptTasks[0].Define.ReceivedTimelineId);
                        }
                    }

                    // 如果在副本里面接受了AutoRun的赏金任务或者帮派任务,则Post一个TASK_GUIDE的event,等退出副本再次导航这个任务
                    if (SceneHelp.Instance.IsInInstance == true)
                    {
                        if ((newAcceptTasks[0].Define.AutoRunType == TaskDefine.EAutoRunType.AutoRun && InstanceManager.Instance.IsOnHook == false) || newAcceptTasks[0].Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun || newAcceptTasks[0].Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun2)
                        {
                            BountyTaskInfo bountyTaskInfo = TaskManager.Instance.BountyTaskInfo;
                            GuildTaskInfo  guildTaskInfo  = TaskManager.Instance.GuildTaskInfo;

                            // bountyTaskInfo.id == 0即首次接取赏金任务时不自动执行
                            if (newAcceptTasks[0].Define.Type == GameConst.QUEST_SG && !(bountyTaskInfo != null && bountyTaskInfo.id == 0))
                            {
                                ClientEventMgr.GetInstance().PostEvent((int)ClientEvent.TASK_GUIDE, new CEventBaseArgs(newAcceptTasks[0].Define.Id));
                            }
                            // guildTaskInfo.id == 0即首次接取帮派任务时不自动执行
                            else if (newAcceptTasks[0].Define.Type == GameConst.QUEST_GUILD && !(guildTaskInfo != null && guildTaskInfo.id == 0))
                            {
                                ClientEventMgr.GetInstance().PostEvent((int)ClientEvent.TASK_GUIDE, new CEventBaseArgs(newAcceptTasks[0].Define.Id));
                            }
                        }
                    }
                }

                if (doneTasks.Count > 0)
                {
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_CAN_SUBMIT, new CEventBaseArgs(doneTasks));
                }

                if (SceneHelp.Instance.IsInNormalWild() == true)
                {
                    if (tasksToGuide.Count > 0)
                    {
                        BountyTaskInfo bountyTaskInfo = TaskManager.Instance.BountyTaskInfo;
                        GuildTaskInfo  guildTaskInfo  = TaskManager.Instance.GuildTaskInfo;

                        // DoNotAutoRunBountyTaskNextTime为true不自动执行,bountyTaskInfo.id == 0即首次接取赏金任务时不自动执行
                        if (tasksToGuide[0].Define.Type == GameConst.QUEST_SG && (TaskManager.Instance.DoNotAutoRunBountyTaskNextTime == true || (bountyTaskInfo != null && bountyTaskInfo.id == 0)))
                        {
                            TaskManager.Instance.DoNotAutoRunBountyTaskNextTime = false;
                        }
                        // DoNotAutoRunGuildTaskNextTime为true不自动执行,guildTaskInfo.id == 0即首次接取帮派任务时不自动执行
                        else if (tasksToGuide[0].Define.Type == GameConst.QUEST_GUILD && (TaskManager.Instance.DoNotAutoRunGuildTaskNextTime == true || (guildTaskInfo != null && guildTaskInfo.id == 0)))
                        {
                            TaskManager.Instance.DoNotAutoRunGuildTaskNextTime = false;
                        }
                        else
                        {
                            // 正在主线任务导航的时候,则不能自动执行其他类型的任务
                            if ((TaskManager.Instance.IsNavigatingMainTask == false && TaskHelper.MainTaskIsInGuideCoroutine == false) || tasksToGuide[0].Define.Type == GameConst.QUEST_MAIN)
                            {
                                if (tasksToGuide[0].State != GameConst.QUEST_STATE_UNACCEPT && tasksToGuide[0].State != GameConst.QUEST_STATE_FIN && tasksToGuide[0].State != GameConst.QUEST_STATE_INVALID)
                                {
                                    if ((TaskManager.Instance.NavigatingTaskType == GameConst.QUEST_NONE || TaskManager.Instance.NavigatingTaskType == tasksToGuide[0].Define.Type) &&
                                        (TaskHelper.TaskTypeInGuideCoroutine == GameConst.QUEST_NONE || TaskHelper.TaskTypeInGuideCoroutine == tasksToGuide[0].Define.Type))
                                    {
                                        // 如果需要自动寻路的任务是第三级别的自动执行,则需要先停止其他的任务寻路
                                        if (tasksToGuide[0].Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun2)
                                        {
                                            TargetPathManager.Instance.StopPlayerAndReset();
                                        }
                                        TaskHelper.TaskGuide(tasksToGuide[0]);
                                    }
                                }
                            }
                        }
                    }
                }

                if (newTasks.Count > 0)
                {
                    ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_ADDED, new CEventBaseArgs(newTasks[0].Define.Id));
                }

                TaskNet.HaveReceivedTaskInfo = true;

                break;
            }

            case NetMsg.MSG_TASK_DELETE:
            {
                S2CTaskDelete pack = S2CPackBase.DeserializePack <S2CTaskDelete>(data);

                Task navigatingTask = TaskManager.Instance.NavigatingTask;
                if (navigatingTask != null && navigatingTask.Define.Id == pack.id)
                {
                    TaskManager.Instance.NavigatingTask = null;
                    TargetPathManager.Instance.StopPlayerAndReset(false);
                }

                TaskManager.Instance.DeleteTask(pack.id);

                //ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_CHANGED, null);
                StartTaskChangedCoroutine();

                break;
            }

            case NetMsg.MSG_TASK_VALUE:
            {
                S2CTaskValue pack = S2CPackBase.DeserializePack <S2CTaskValue>(data);

                // 其它所有任务的置顶取消
                foreach (Task tempTask in TaskManager.Instance.AllTasks)
                {
                    if (tempTask.Define.Id != pack.id)
                    {
                        tempTask.IsOnTop = false;
                    }
                }

                bool isDone = false;
                uint value  = 0;
                if (pack.value.Count > 0)
                {
                    isDone = TaskManager.Instance.ChangeTaskCurStepValue(pack.id, pack.value[0]);
                    value  = pack.value[0];
                }
                else
                {
                    isDone = TaskManager.Instance.ChangeTaskCurStepValue(pack.id, 0);
                }

                Task task = TaskManager.Instance.GetTask(pack.id);

                // 提高任务显示优先级,头衔任务不受动态排序规则影响
                if (task != null && task.Define.Type != GameConst.QUEST_TITLE)
                {
                    Task.IncreaseCurDynamicShowPriority();
                    task.DynamicShowPriority = Task.CurDynamicShowPriority;
                }

                //TaskManager.Instance.SortTaskList();

                if (SceneHelp.Instance.IsInNormalWild() == true)
                {
                    if ((isDone == true || InstanceManager.Instance.IsAutoFighting == false) && task != null && task.Define.AutoRunType != TaskDefine.EAutoRunType.None)
                    {
                        if ((task.Define.AutoRunType == TaskDefine.EAutoRunType.AutoRun && InstanceManager.Instance.IsOnHook == false) || task.Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun || task.Define.AutoRunType == TaskDefine.EAutoRunType.ForceAutoRun2)
                        {
                            // 正在主线任务导航的时候,则不能自动执行其他类型的任务
                            if ((TaskManager.Instance.IsNavigatingMainTask == false && TaskHelper.MainTaskIsInGuideCoroutine == false) || task.Define.Type == GameConst.QUEST_MAIN)
                            {
                                // 进度大于0才自动执行
                                if (value > 0)
                                {
                                    if ((TaskManager.Instance.NavigatingTaskType == GameConst.QUEST_NONE || TaskManager.Instance.NavigatingTaskType == task.Define.Type) &&
                                        (TaskHelper.TaskTypeInGuideCoroutine == GameConst.QUEST_NONE || TaskHelper.TaskTypeInGuideCoroutine == task.Define.Type))
                                    {
                                        TaskHelper.TaskGuide(task);
                                    }
                                }
                            }
                        }
                    }
                }

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.TASK_PROGRESS_CHANGED, new CEventBaseArgs(pack.id));

                break;
            }

            case NetMsg.MSG_TASK_SG_INFO:
            {
                S2CTaskSgInfo pack = S2CPackBase.DeserializePack <S2CTaskSgInfo>(data);

                TaskManager.Instance.BountyTaskInfo = new BountyTaskInfo(pack.id, pack.num, pack.is_reward);
                if (TaskManager.Instance.BountyTaskInfo.id > 0 || TaskManager.Instance.BountyTaskInfo.is_reward == 0)
                {
                    TaskManager.Instance.BountyTaskCoinReward = 0;
                }

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.BOUNTY_TASK_CHANGED, null);

                if (IsFirstReceiveBountyTaskInfo == false)
                {
                    if (TaskManager.Instance.BountyTaskInfo.num >= TaskHelper.GetBountyTaskMaxTimes() && TaskManager.Instance.BountyTaskInfo.is_reward == 0)
                    {
                        if (SceneHelp.Instance.IsInWildInstance() == true)
                        {
                            xc.ui.ugui.UIManager.Instance.ShowSysWindow("UITaskWindow", xc.GameConst.QUEST_SG, null);
                        }
                        else
                        {
                            ClientEventMgr.GetInstance().PostEvent((int)ClientEvent.OPEN_TASK_WINDOW, new CEventBaseArgs(xc.GameConst.QUEST_SG));
                        }
                    }
                }

                IsFirstReceiveBountyTaskInfo = false;

                xc.ui.ugui.UIManager.Instance.ShowWaitScreen(false);

                break;
            }

            case NetMsg.MSG_TASK_REWARD_SG:
            {
                S2CTaskRewardSg pack = S2CPackBase.DeserializePack <S2CTaskRewardSg>(data);

                TaskManager.Instance.BountyTaskCoinReward = pack.coin;

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.BOUNTY_TASK_CHANGED, null);

                break;
            }

            case NetMsg.MSG_TASK_GUILD_INFO:
            {
                S2CTaskGuildInfo pack = S2CPackBase.DeserializePack <S2CTaskGuildInfo>(data);

                TaskManager.Instance.GuildTaskInfo = new GuildTaskInfo(pack.id, pack.num, pack.reward_state);
                //if (TaskManager.Instance.GuildTaskInfo.id > 0 || TaskManager.Instance.GuildTaskInfo.reward_state == 1)
                //{
                //    TaskManager.Instance.GuildTaskCtbReward = 0;
                //}

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.GUILD_TASK_CHANGED, null);

                if (IsFirstReceiveGuildTaskInfo == false && TaskManager.Instance.GuildTaskInfo.reward_state == 1)
                {
                    if (TaskManager.Instance.GuildTaskInfo.num >= GameConstHelper.GetInt("GAME_QUEST_GUILD_PRE_NUM"))
                    {
                        if (SceneHelp.Instance.IsInWildInstance() == true)
                        {
                            xc.ui.ugui.UIManager.Instance.ShowSysWindow("UITaskWindow", xc.GameConst.QUEST_GUILD, null);
                        }
                        else
                        {
                            ClientEventMgr.GetInstance().PostEvent((int)ClientEvent.OPEN_TASK_WINDOW, new CEventBaseArgs(xc.GameConst.QUEST_GUILD));
                        }
                    }
                }

                IsFirstReceiveGuildTaskInfo = false;

                xc.ui.ugui.UIManager.Instance.ShowWaitScreen(false);

                break;
            }

            case NetMsg.MSG_TASK_REWARD_GUILD:
            {
                S2CTaskRewardGuild pack = S2CPackBase.DeserializePack <S2CTaskRewardGuild>(data);

                TaskManager.Instance.GuildTaskCtbReward = pack.ctb;

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.GUILD_TASK_CHANGED, null);

                //UINotice.Instance.ShowMessage(string.Format(DBConstText.GetText("BAG_GET_GUILD_CTB"), pack.ctb));

                break;
            }

            case NetMsg.MSG_TASK_TRANSFER_INFO:
            {
                S2CTaskTransferInfo pack = S2CPackBase.DeserializePack <S2CTaskTransferInfo>(data);

                TaskManager.Instance.TransferTaskInfo = pack;

                ClientEventMgr.Instance.FireEvent((int)ClientEvent.TRANSFER_TASK_CHANGED, null);

                break;
            }

            case NetMsg.MSG_TASK_REWARD_TRANSFER:
            {
                //暂时没有用到
                break;
            }

            default: break;
            }
        }