--[[ @description:任务模块 ]] require("game.task.TaskModel") require("game.task.TaskNewBaseView") require("game.task.TaskSubMainView") require("game.task.TaskSubExtensionView") require("game.task.TaskVerTabSubBtn") require("game.task.TaskSubCommonView") require("game.task.vo.TaskVo") require("game.task.vo.TaskTipsVo") require("game.task.TaskEvent") require("game.task.TaskLang") require("game.task.TaskFinishTipView") require("game.task.TaskDailyView") require("game.task.TaskDailyItem") require("game.task.TaskBountyRewardView") ------------------------- --新的 require("game.task.TaskCircleBuyTip") require("game.task.FlyShoeBuyTip") ------------------------- TaskController = TaskController or BaseClass(BaseController) local TaskController = TaskController local table_insert = table.insert function TaskController:__init() TaskController.Instance = self self.taskModel = TaskModel:getInstance() self.taskModel.after_scene_start = false self:RegisterAllProtocals() self:EnableCheckoutClear() self:InitEvent() end function TaskController:RegisterAllProtocals() self:RegisterProtocal(30000, "handler30000")--可接任务和已接任务列表 self:RegisterProtocal(30001, "handler30001")--完成任务某环节 self:RegisterProtocal(30005, "handler30005")--放弃任务 self:RegisterProtocal(30017, "handler30017")--已完成任务列表 self:RegisterProtocal(30018, "handler30018")--快速完成任务 self:RegisterProtocal(30019, "handler30019")--领取跑环额外奖励 end function TaskController:InitEvent() local open_task_view = function (index,task_id,parent_index,sub_index) self:OpenTaskView(index,task_id,parent_index,sub_index) end GlobalEventSystem:Bind(EventName.OPEN_TASK_VIEW, open_task_view) --场景开始了 local function loginComplete() if self.taskModel.game_start_request == true then self.taskModel.game_start_request = false self.taskModel:HideRoleWeapon() --可能30000第一次返回的时候主角还没创建,场景开始后,主角一定创建了,这里再判断是否隐藏武器 end end GlobalEventSystem:Bind(SceneManager.START,loginComplete) local game_start_fun = function () self.main_line_break_wait = nil self.not_guide_wait_accept_main_task = nil self.mark_main_line_list = nil self.first_call_new_tip = nil self.taskModel:ClearData() setTimeout( function() DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30012) DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, 6) DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, 7) self:request30000() end,0.6) if self.auto_check_do_task_timer then GlobalTimerQuest:CancelQuest(self.auto_check_do_task_timer) self.auto_check_do_task_timer = nil end if self.can_move_timer_id then TimerQuest.CancelQuest(GlobalTimerQuest, self.can_move_timer_id) self.can_move_timer_id = false end self:ClearBreakLevelTimer() end GlobalEventSystem:Bind(EventName.GAME_START, game_start_fun) local function onRequeseTaskData( ) self:request30000() end GlobalEventSystem:Bind(EventName.REQUEST_TASK_DATA, onRequeseTaskData) local function CIRCLE_TASK_QUICK_FINISH( id ) self:request30018(id) end GlobalEventSystem:Bind(TaskEventType.CIRCLE_TASK_QUICK_FINISH, CIRCLE_TASK_QUICK_FINISH) --@force_use_shoe:点击任务栏飞鞋按钮时强制使用飞鞋 local find_way_fun = function (params, use_shoe,force_use_shoe) self:findElement(params,use_shoe,force_use_shoe) end GlobalEventSystem:Bind(EventName.WAYFINDING, find_way_fun)--寻路 local function loadComplete() --必须npc加载完, 场景加载完,才能继续做任务 self.taskModel.proto_count = self.taskModel.proto_count + 1 self.delay_fly_down_to_do_task = false if self.taskModel.proto_count >= 2 then self.taskModel.proto_count = 0 self:ClearAutoDoTaskTimer() if SceneManager:getInstance():IsMainCityorYieldScene() then --切场景后自动寻路 print("tanar: [TaskController 117]=> self.taskModel.need_task: ",self.taskModel.need_task) print("tanar: [TaskController 118]=> guide_force_do_task: ",guide_force_do_task) local guide_force_do_task = GuideModel:getInstance().need_force_do_task --引导触发的自动任务 if self.taskModel.need_task or guide_force_do_task then if guide_force_do_task then GuideModel:getInstance().need_force_do_task = false end self.taskModel:SetNeedTaskFlag(false) self.taskModel:SetTaskAutoFlag(false) local onDelay = function( ) local mainRole = Scene.Instance:GetMainRole() if mainRole and mainRole:IsInState(PoseState.FLY_SHOE_EFFECT) then self.delay_fly_down_to_do_task = true else GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true) end end setTimeout(onDelay, 1.1) end end GlobalEventSystem:Fire(EventName.CAN_FIND_NPC) end end GlobalEventSystem:Bind(EventName.NPC_LOAD_FINISH, loadComplete) local function scene_load_view_complete( ) loadComplete() --需要清掉标志,不然副本挂机会找不到怪 TaskModel:getInstance().need_check_monster = false --如果不在安全场景或者也要,停止做任务 寻路也停掉,避免无法挂机 if not SceneManager:getInstance():IsMainCityorYieldScene() then GlobalEventSystem:Fire(EventName.FORCE_STOP_DO_TASK) else if self.taskModel.need_show_circle_tip then GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS,self.taskModel.need_show_circle_tip) self.taskModel.need_show_circle_tip = false end if self.taskModel.wait_circle_show_award_data then -- GlobalEventSystem:Fire(NatureModel.OPEN_AWARD_RESULT_VIEW, self.taskModel.wait_circle_show_award_data) GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, self.taskModel.wait_circle_show_award_data) self.taskModel.wait_circle_show_award_data = false end end if self.auto_check_do_task_timer then GlobalTimerQuest:CancelQuest(self.auto_check_do_task_timer) self.auto_check_do_task_timer = nil end end GlobalEventSystem:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, scene_load_view_complete) local function doFlyShoeEffectFinishDown() if self.delay_fly_down_to_do_task then GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true) self.delay_fly_down_to_do_task = false end end GlobalEventSystem:Bind(SceneEventType.DO_FLYSHOE_EFFECT_FINISH_DOWN,doFlyShoeEffectFinishDown) local function main_role_move_end() self:CreateAutoDoTaskTimer() end GlobalEventSystem:Bind(SceneEventType.MAIN_ROLE_MOVE_END, main_role_move_end) GlobalEventSystem:Bind(EventName.CREATE_MAIN_TASK_TIP, main_role_move_end) --是否继续开始任务 local function reopen_fun(now) print("-------START_AUTO-------------", self.taskModel.now_task_id, self.taskModel.is_stop) -- local mainrole = Scene:getInstance():GetMainRole() -- if mainrole and mainrole:IsInState(PoseState.FLY) or mainrole:IsInState(PoseState.FLY_SHOE_EFFECT) or mainrole:IsInState(PoseState.FLY_SHOE) then -- -- Message.show("请落地后重试~") -- if self.taskModel.is_auto_task and self.taskModel.is_stop then -- local function task_load_scene_func( ... ) -- GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK) -- end -- self.task_load_scene_func = task_load_scene_func--任务场景加载完后调什么 -- self.task_load_scene_func_time = TimeUtil:getServerTime( )--事件时间 -- end -- return -- end--飞鞋状态下开始任务 if self.taskModel.is_auto_task and self.taskModel.is_stop then local delay_fun = function () self.taskModel.is_stop = false -- GlobalEventSystem:Fire(EventName.FINDWAY_ENDED) self:AutoDoTask() end if now then delay_fun() else self.later_time_id = GlobalTimerQuest:AddDelayQuest(delay_fun, 0.6) end end end GlobalEventSystem:Bind(EventName.START_AUTO_DO_TASK, reopen_fun) --暂停自动寻路 local function close_fun() -- local mainrole = Scene:getInstance():GetMainRole() -- if mainrole and mainrole:IsInState(PoseState.FLY) or mainrole:IsInState(PoseState.FLY_SHOE_EFFECT) or mainrole:IsInState(PoseState.FLY_SHOE) then -- -- Message.show("请落地后重试~") -- if self.taskModel.is_auto_task and self.taskModel.is_stop then -- if self.task_load_scene_func_time and self.task_load_scene_func_time <= TimeUtil:getServerTime( ) then--时间要满足先后顺序 -- self.task_load_scene_func = nil--任务场景加载完后调什么 -- self.task_load_scene_func_time = nil--事件时间 -- end -- end -- end--飞鞋状态下停止任务 self:ClearAutoDoTaskTimer() self.taskModel.is_stop = true--停止任务标记 if not EscortModel:getInstance():IsEscortState() then--护送状态接着护送 OperateManager.Instance:StopMove(true) --先清掉当前场景的操作包,避免继续移动寻路 end if self.later_time_id then GlobalTimerQuest:CancelQuest(self.later_time_id) self.later_time_id = nil end end GlobalEventSystem:Bind(EventName.STOP_AUTO_DO_TASK, close_fun) --不再做任务 local function stop_fun() self:ClearAutoDoTaskTimer() -- print("---------NOT_TASK---------:", self.taskModel.now_task_id, self.taskModel.is_stop) TaskModel:getInstance():SetTaskAutoFlag(false) local is_fire_evt = OperateManager.Instance:StopMove(true) --先清掉当前场景的操作包,避免继续移动寻路 if not is_fire_evt then GlobalEventSystem:Fire(EventName.FINDWAY_ENDED) end end GlobalEventSystem:Bind(EventName.FORCE_STOP_DO_TASK, stop_fun) local do_first_task = function (force, is_force_main_line) TaskModel:getInstance():SetTaskAutoFlag(true) self.taskModel.is_stop = false self:AutoDoTask(force, is_force_main_line) end GlobalEventSystem:Bind(EventName.FORCE_TO_DO_TASK, do_first_task) local function onOpenTaskFinishView(show, task_type, task_id) if show then if self.TaskFinishTipView == nil then self.TaskFinishTipView = TaskFinishTipView.New() end self.TaskFinishTipView:Open(task_type, task_id) else if self.TaskFinishTipView and self.TaskFinishTipView:HasOpen() then self.TaskFinishTipView:Close() end end end GlobalEventSystem:Bind(EventName.OPEN_TASK_FINISH_TIP_VIEW, onOpenTaskFinishView) local function onOpenTaskDailyView(show) if show then if self.TaskDailyView == nil then self.TaskDailyView = TaskDailyView.New() end self.TaskDailyView:Open() else if self.TaskDailyView and self.TaskDailyView:HasOpen() then self.TaskDailyView:Close() end end end GlobalEventSystem:Bind(EventName.OPEN_TASK_DAILY_VIEW, onOpenTaskDailyView) local function onOpenTaskBountyRewardView(circle_num,is_close) if is_close then if self.TaskBountyRewardView and self.TaskBountyRewardView:HasOpen() then self.TaskBountyRewardView:Close() end else if GuideModel:getInstance():IsPromptViewOpen() or GuideModel:getInstance():IsHideSmallUI() then return end if self.TaskBountyRewardView == nil then self.TaskBountyRewardView = TaskBountyRewardView.New() end self.TaskBountyRewardView:Open(circle_num) end end GlobalEventSystem:Bind(EventName.OPEN_TASK_BOUNTY_REWARD_VIEW, onOpenTaskBountyRewardView) local function change_account() if self.auto_check_do_task_timer then GlobalTimerQuest:CancelQuest(self.auto_check_do_task_timer) self.auto_check_do_task_timer = nil end self:ClearBreakLevelTimer() end GlobalEventSystem:Bind(EventName.CHANGE_ACCOUNT,change_account) GlobalEventSystem:Bind(EventName.CHANGE_ROLE,change_account) local function onShowBreakLevelTimer() self:ClearBreakLevelTimer() if SceneManager:getInstance():IsMainCityorYieldScene() then local function onTimer() local main_role = Scene.Instance.main_role if main_role and main_role.stand_init_time > 25 then if self.taskModel.showExtendTip then GuideModel:getInstance():TriggerBreakLevelGuide() self:ClearBreakLevelTimer() end end end self.show_break_level_timer = GlobalTimerQuest:AddPeriodQuest(onTimer,30) end end self.taskModel:Bind(TaskEvent.SHOW_BREAK_LEVEL_TIMER, onShowBreakLevelTimer) local function CONTINUE_TASK( task_type ) local circle_data = self.taskModel:GetCircleTaskInfo(task_type) local task_data = self.taskModel:GetTaskByType( task_type ) if circle_data and (not task_data) then if circle_data.task_type == TaskType.GUILD_LINE then task_data = self.taskModel:GetGuildTipTask() elseif circle_data.task_type == TaskType.BOUNTY_LINE then task_data = self.taskModel:GetBountyTipTask() end end ------------------------- if task_data then local vip = RoleManager.Instance.mainRoleInfo.vip_flag if vip > 0 and self.taskModel:IsShowFlyShoe(task_data) then self.taskModel:TaskClickFun(task_data,true) else self.taskModel:TaskClickFun(task_data) end if task_type == TaskType.BOUNTY_LINE or task_type == TaskType.GUILD_LINE then GlobalEventSystem:Fire(KfActivityModel.OPEN_ACTIVITY_BASE_VIEW,nil,nil,true)--触发任务关闭活动界面 end else if task_type == TaskType.GUILD_LINE then local guild_id = RoleManager.Instance.mainRoleInfo.guild_id if not guild_id or guild_id == 0 then Message.show("请先加入社团") end end end end self.taskModel:Bind(TaskEvent.CONTINUE_TASK, CONTINUE_TASK) local function OPEN_QUICK_CIRCLE_TIPS( data ) self.taskcirclebuytip = self.taskcirclebuytip or TaskCircleBuyTip.New() self.taskcirclebuytip:Open(data) end self.taskModel:Bind(TaskEvent.OPEN_QUICK_CIRCLE_TIPS,OPEN_QUICK_CIRCLE_TIPS) local function OPEN_BUY_SHOE_TIPS( buy_call ) self.flyshoebuytip = self.flyshoebuytip or FlyShoeBuyTip.New() self.flyshoebuytip:Open(buy_call) end self.taskModel:Bind(TaskEvent.OPEN_BUY_SHOE_TIPS,OPEN_BUY_SHOE_TIPS) local function onGuildChange() self:DoTaskNotify() end RoleManager:getInstance():GetMainRoleVo():BindOne("guild_id", onGuildChange) end function TaskController:ClearBreakLevelTimer() if self.show_break_level_timer then GlobalTimerQuest:CancelQuest(self.show_break_level_timer) self.show_break_level_timer = nil end end function TaskController:CheckAutoDoTaskTimer() do return end -- if self.auto_check_do_task_timer then -- GlobalTimerQuest:CancelQuest(self.auto_check_do_task_timer) -- self.auto_check_do_task_timer = nil -- end -- local playerLv = RoleManager:getInstance():GetMainRoleVo().level -- if playerLv <= 120 and SceneManager:getInstance():IsMainCityorYieldScene() then -- local function onTimer() -- local playerLv = RoleManager:getInstance():GetMainRoleVo().level -- if playerLv > 1 and playerLv <= 120 then -- local main_role = Scene.Instance.main_role -- if main_role and main_role.stand_init_time > 35 and lua_viewM.main_cancas_last_visible then -- local taskVo = TaskModel:getInstance():GetTaskByType(TaskType.MAIN_LINE) or TaskModel:getInstance():GetTaskByType(TaskType.BOUNTY_LINE) or TaskModel:getInstance():GetBountyTipTask() -- if taskVo then -- TaskModel:getInstance().need_do_task_type = 0 -- TaskModel:getInstance().last_task_type_cache = false -- TaskModel:getInstance().now_task_id = taskVo.id -- GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true) -- end -- end -- end -- end -- self.auto_check_do_task_timer = GlobalTimerQuest:AddPeriodQuest(onTimer,40) -- end end --创建自动开始任务定时器 function TaskController:CreateAutoDoTaskTimer() do return end self:ClearAutoDoTaskTimer() if self.taskModel.is_auto_task then local playerLv = RoleManager:getInstance():GetMainRoleVo().level if playerLv <= 120 then local function func() if self.taskModel.is_auto_task and Scene.Instance.main_role and Scene.Instance.main_role:IsInState(PoseState.STAND) then if Scene.Instance.main_role.stand_init_time and Scene.Instance.main_role.stand_init_time > 4 then self:AutoDoTask() end end end self.auto_do_timer = GlobalTimerQuest:AddDelayQuest(func, 5) end end end --自动开始任务 force 30000返回的时候,可能是接完支线,就算是打开界面的任务类型, 也自动做 function TaskController:AutoDoTask(force, is_force_main_line) --if ClientConfig.alpha_mode then return end self:ClearAutoDoTaskTimer() self.taskModel.guild_kill_monster_num = 0 if Scene.Instance:IsSceneProloadFinish() then if SceneManager.Instance:IsMainCityorYieldScene() then local cur_task if is_force_main_line then cur_task = self.taskModel:GetMainTask() else cur_task = self.taskModel:GetCurTask() end print("Saber:TaskController [413] cur_task: ",cur_task) print("tanar: [TaskController 419]=> is_force_main_line: ",is_force_main_line) print("tanar: TaskController [386] ====== AutoDoTask parms: force = ", force) print("not self.taskModel:IsWaitProto(): ",not self.taskModel:IsWaitProto()) print("self.taskModel:IsAutoDoTask(cur_task): ",self.taskModel:IsAutoDoTask(cur_task)) print("cur_task and cur_task.mainTip == false: ",cur_task and cur_task.mainTip == false) print("self.taskModel.is_stop == false: ",self.taskModel.is_stop == false) print("self.taskModel.now_task_id: ",self.taskModel.now_task_id) print("not DialogueModel:getInstance().dialogue_is_open: ",not DialogueModel:getInstance().dialogue_is_open) print("not GuideModel:getInstance():IsNeedFinishGuideFirst(): ", not GuideModel:getInstance():IsNeedFinishGuideFirst()) print("tanar: TaskController [395] ====== parms end") if not self.taskModel:IsWaitProto() and (self.taskModel:IsAutoDoTask(cur_task) or force) and cur_task and cur_task.mainTip == false and self.taskModel.is_stop == false and UserMsgAdapter:getInstance().is_game_connected and not DialogueModel:getInstance().dialogue_is_open and not GuideModel:getInstance():IsNeedFinishGuideFirst() then --主线在等待升级的时候,不做任务,避免升级前去找开始npc,这个看网络 print("tanar: [TaskController 413]=> cur_task.type: ",cur_task.type) if cur_task.type==TaskType.MAIN_LINE and TaskModel:getInstance().need_accept then print("tanar: [TaskController 417]=> TaskModel:getInstance().need_accept: ",TaskModel:getInstance().need_accept) return end if force and cur_task.tipParam and cur_task.tipParam[1] == TaskTipType.TYPE43 then --主线强制force参数会绕过TaskModel:getInstance()IsAutoDoTask的判断,引起部分界面类任务和引导重叠,这边特殊处理掉 return end if cur_task.type == TaskType.TRUN_LINE then local last_is_main_yield_scene = SceneManager.Instance:IsMainCityorYieldScene(SceneManager.Instance:GetLastSceneId()) local turn_task_needs_auto = self.taskModel:NeedAutoDoTurnTask(cur_task) -- local rein_task_finished = cur_task.taskTips and cur_task.taskTips[1] and cur_task.taskTips[1].isFinish == 1 if ((self.delay_fly_down_to_do_task and not last_is_main_yield_scene) -- 防止在大世界切大世界场景也弹 or (not self.delay_fly_down_to_do_task)) and not turn_task_needs_auto then -- 不能自动进行的任务需要弹出任务窗口确认 -- and rein_task_finished then -- 转职任务不会自动执行,但切换场景进来的已完成转职任务的情况除外 local turn = ReincarnationModel:getInstance():GetCurTurn() ReincarnationModel:getInstance():Fire(ReincarnationModel.OPEN_REIN_MAIN_TASK_VIEW, true, turn) return end end -- 从副本里出来后(失败或者主动退出),自动任务又要重新进这个副本,那就不要再进去了,改到61003控制 self.taskModel:TaskClickFun(cur_task) end end else self.taskModel.after_scene_start = true end end --清除自动开始任务定时器 function TaskController:ClearAutoDoTaskTimer() -- print("--------清除自动开始任务定时器-----") if self.auto_do_timer then GlobalTimerQuest:CancelQuest(self.auto_do_timer) self.auto_do_timer = nil end end -----------------协议相关--------------------- function TaskController:request30000() self:Clear30000Timer() self:SendFmtToGame(30000,"") end function TaskController:handler30000() self.taskModel.notMain = true --没接有主线任务 local task_type = self:ReadFmt("c") if task_type == 0 then self.taskModel._canTaskList={} self.taskModel._receivedTaskList={} self.taskModel.all_task_list = {} else local list = self.taskModel._canTaskList for i = #list, 1, -1 do if list[i].type == task_type then table.remove(list,i) end end list = self.taskModel._receivedTaskList for i = #list, 1, -1 do if list[i].type == task_type then table.remove(list,i) end end list = self.taskModel.all_task_list for i = #list, 1, -1 do if list[i].type == task_type then table.remove(list,i) end end end local len = self:ReadFmt("h") for index = 1, len do local taskVO=TaskVo.New(true, false) taskVO.acceptType = 1 if taskVO.level and taskVO.level <= RoleManager.Instance.mainRoleInfo.level then if not ClientConfig.alpha_mode or taskVO.type~=TaskType.EXTENSION_LINE then self.taskModel:MakeTaskTip(taskVO) table_insert(self.taskModel._canTaskList,taskVO)--保存可接任务vo table_insert(self.taskModel.all_task_list, taskVO) ------------------------- --非新手流程的时候,有可接取的主线,就不要等了,直接接 if Config.ConfigTaskEffect.GuideLevel < RoleManager.Instance.mainRoleInfo.level then if taskVO.type == TaskType.MAIN_LINE then print('Ych:TaskController.lua[552] data', taskVO.id) --GlobalEventSystem:Fire(TaskEventType.SEND_TASK_ACCEPT, taskVO.id) if self.main_line_break_wait then if not self.taskModel.sign_mask_not_guide_wait_accept_main_task then--完成任务导致升级的时候会从重合导致当前自动任务流程停止,用30004的标记处理掉 self.not_guide_wait_accept_main_task = true--非新手流程等主线任务更新,这次更新不要自动进行任务 end self.auto_accept_main_id = taskVO.id--保存一下自动接的任务id,给30003协议返回用 else --如果已经不是断层任务了,这个就不用了 self.not_guide_wait_accept_main_task = false end end end ------------------------- end end if taskVO.type == TaskType.MAIN_LINE and ((RoleManager.Instance.mainRoleInfo.level == 0) or (taskVO.level<=RoleManager.Instance.mainRoleInfo.level)) then --20000比13001还快,这时候人物等级都木有 self.taskModel.notMain=false end end local need_refresh_monster_name local len4 = self:ReadFmt("h") for index = 1, len4 do local taskVO = TaskVo.New(true, true) if not ClientConfig.alpha_mode or taskVO.type~=TaskType.EXTENSION_LINE then taskVO.acceptType=0 self.taskModel:MakeTaskTip(taskVO) table_insert(self.taskModel._receivedTaskList,taskVO)--保存已接任务vo table_insert(self.taskModel.all_task_list, taskVO) if taskVO.task_kind == TaskKind.CAI_JI_KIND then --采集任务,刷新采集怪的名字面板,有任务时才显示名字 need_refresh_monster_name = true self.monster_content_id = taskVO.content_id end if taskVO.type == TaskType.MAIN_LINE then self.taskModel.notMain = false end end end --可能只发了某个类型的过来。所以要全部判断下 if task_type > 0 then local list = self.taskModel.all_task_list for index,taskVO in pairs(list) do if taskVO.type == TaskType.MAIN_LINE then if taskVO.acceptType == 1 then if ((RoleManager.Instance.mainRoleInfo.level == 0) or (taskVO.level <= RoleManager.Instance.mainRoleInfo.level)) then self.taskModel.notMain = false break end elseif taskVO.acceptType == 0 then self.taskModel.notMain = false break end end end end self.taskModel.showExtendTip = self.taskModel:NeedShowExtendTip() --当前任务做完后,马上做下一个主线任务 if RoleManager.Instance.mainRoleInfo.level <= TaskModel.AutoDoNewMainTaskLv then local task_data = self.taskModel:GetMainUITaskData() if not self.taskModel.now_task_id and task_data and task_data[1] and task_data[1].mainTip == false then if task_data[1].id ~= self.taskModel.last_task_id_cache and task_data[1].type==TaskType.MAIN_LINE then --马上继续下一个任务 self.taskModel.now_task_id = task_data[1].id end end end if self.taskModel.need_do_task_type~=0 then --马上做赏金或社团任务 local taskVo = self.taskModel:GetTaskByType(self.taskModel.need_do_task_type) if taskVo then TaskModel:getInstance():SetTaskAutoFlag(true) TaskModel:getInstance().now_task_id = taskVo.id end self.taskModel.need_do_task_type = 0 else if self.taskModel.last_task_type_cache then if self.taskModel.last_task_type_cache==TaskType.BOUNTY_LINE then --自动做 local taskVo = self.taskModel:GetTaskByType(TaskType.BOUNTY_LINE) if taskVo then self.taskModel.now_task_id = taskVo.id end --请求进度 DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, TaskType.BOUNTY_LINE) elseif self.taskModel.last_task_type_cache==TaskType.GUILD_LINE then if RoleManager.Instance.mainRoleInfo.vip_flag >= Config.ConfigTaskEffect.guildAutoTaskVip then local taskVo = self.taskModel:GetTaskByType(TaskType.GUILD_LINE) if taskVo then self.taskModel.now_task_id = taskVo.id end else --vip不足,停止做任务 GlobalEventSystem:Fire(EventName.FORCE_STOP_DO_TASK) end --请求进度 DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, TaskType.GUILD_LINE) elseif self.taskModel.last_task_type_cache==TaskType.TRUN_LINE then local taskVo = self.taskModel:GetTaskByType(TaskType.TRUN_LINE) if taskVo then -- 存在任务时,根据上次完成转职任务的等级判断玩家是否处于卡级阶段,是则不自动进行转职任务 local is_in_turn_task_limit = self.taskModel:IsNewTurnTaskInLimitLv() self.taskModel.now_task_id = not is_in_turn_task_limit and taskVo.id or false else self.taskModel.now_task_id = false end -- 2021年7月27日修改 转职任务转阶段不自动进行下一阶段 -- self.taskModel.now_task_id = false end end end if need_refresh_monster_name then self.taskModel:RefreshCollectMonsterName(self.monster_content_id) elseif self.monster_content_id then local temp_content_id = self.monster_content_id self.monster_content_id = false self.taskModel:RefreshCollectMonsterName(temp_content_id) end self:HandleTask() ------------------------- --self:CheckNewMainLineTip()--检查是否需要显示新主线 self:CheckWaitNewMainLineAccept() ------------------------- end function TaskController:HandleTask( ) self:ClearAutoDoTaskTimer() self:Clear30000Timer() local delay_fun = function() if self.delay_id then GlobalTimerQuest:CancelQuest(self.delay_id) self.delay_id = nil end local function func() local task = self.taskModel:GetTaskById(self.taskModel.now_task_id) ------------------------- --96级之后不用主动优先主线 local auto_main_line = RoleManager.Instance.mainRoleInfo.level <= TaskModel.AutoDoNewMainTaskLv ------------------------- if self.taskModel.notMain==true then self.taskModel:DefaultTask() if self.taskModel._nextMain then table_insert(self.taskModel._canTaskList, self.taskModel._nextMain ) table_insert(self.taskModel.all_task_list, self.taskModel._nextMain) end end -- self.taskModel:Fire(TaskEvent.TASK_LIST_INIT) self:DoTaskNotify() GlobalEventSystem:Fire(EventName.UPDATE_TASK_STATE) local curTipType = 0 --当前环的任务类型 local lastTipType = 0 --上一环的任务类型 local task_id = 0 if task then curTipType = task.tipType lastTipType = task:GetLastTaskTipsType() if curTipType == TaskTipType.TYPE59 then self.taskModel.accept_power_task_id = task.id end if lastTipType == TaskTipType.TYPE59 then --如果满足,则说明,战力任务领取的时候直接满足战力需求,继续做任务 if self.taskModel.accept_power_task_id ~= task.id then lastTipType = 0 end end end --当前环任务是战力引导任务,不自动做 --上一环任务是战力引导任务,不自动做(但是如果如果领到任务,已经满足战力引导任务,则需要自动做) local can_do_task = curTipType ~= TaskTipType.TYPE59 and lastTipType ~= TaskTipType.TYPE59 --如果这次次战力提升的任务,要重置 断层做主线的标志 if not can_do_task and task and task.type == TaskType.MAIN_LINE and self.not_guide_wait_accept_main_task then self.not_guide_wait_accept_main_task = false end if self.taskModel.first_receive and can_do_task then --主线任务从无到有,需要自动做任务 if auto_main_line and self.taskModel.last_notMain and not self.taskModel.notMain then self.not_guide_wait_accept_main_task = false self:AutoDoTask(true, true) return elseif task and task.type ~= TaskType.LIMIT_LINE and task.type ~= TaskType.PSIONIC_LINE then if self.not_guide_wait_accept_main_task then --非新手流程等主线任务更新,这次更新不要自动进行任务 self.not_guide_wait_accept_main_task = false return end --限时任务不自动做 2020/5/9新增:圣物任务不自动做 -- 这里需要特殊处理转职任务,由于转职任务触发下面的函数会打开界面,因此要自动打开界面的前提必须是任务可完成 -- if task.type ~= TaskType.TRUN_LINE or -- (task.type == TaskType.TRUN_LINE and task.taskTips and task.taskTips[1] and task.taskTips[1].isFinish == 1) then -- (task.type == TaskType.TRUN_LINE and self.taskModel:NeedAutoDoTurnTask(task)) then self:AutoDoTask(true) -- end else self.not_guide_wait_accept_main_task = false end end --登陆不自动任务 self.taskModel.first_receive = true --记录一下之前是否没有主线,是的话,接取了新的主线之后就要自动做主线 self.taskModel.last_notMain = self.taskModel.notMain end func() end if not self.taskModel:IsWaitProto() then self.delay_id = GlobalTimerQuest:AddDelayQuest(delay_fun, 0.2) end -- GlobalEventSystem:Fire(EventName.SET_REINCARNATION_ICON) end --延时做任务,让流程不那么急,但是接任务和完成任务要取消掉,避免延时出问题 function TaskController:Clear30000Timer() if self.delay_time_id then GlobalTimerQuest:CancelQuest(self.delay_time_id) self.delay_time_id = nil end if self.delay_id then GlobalTimerQuest:CancelQuest(self.delay_id) self.delay_id = nil end if self.break_timer_id then GlobalTimerQuest:CancelQuest(self.break_timer_id) self.break_timer_id = nil end end function TaskController:handler30001() if self.timer_id then GlobalTimerQuest:CancelQuest(self.timer_id) self.timer_id = nil end if self.event_id then GlobalEventSystem:UnBind(self.event_id) self.event_id = nil end local a_taskId = self:ReadFmt("i") local len = self:ReadFmt("h") local ttable={} local obj = nil for index = 1, len do obj = { type = self:ReadFmt("h"), isFinish = self:ReadFmt("h"), id = self:ReadFmt("i"), name = self:ReadFmt("s"), count = self:ReadFmt("i"), nowCount = self:ReadFmt("i"), sceneId = self:ReadFmt("i"), sceneName = self:ReadFmt("c"), scene_x = self:ReadFmt("h"), scene_y =self:ReadFmt("h"), need_find_way = self:ReadFmt("c"), additionalProperty = self:ReadFmt("s"), stage = self:ReadFmt("c"), } ttable[index] = obj end local cur_stage = self:ReadFmt("c") local target_num = self:ReadFmt("i") local cur_num = self:ReadFmt("i") local isComplete=false local recData=self.taskModel._receivedTaskList local need_req_task_list = true for key, var in ipairs(recData) do local taskVO=var if taskVO.id == a_taskId then local type = ttable[1] and ttable[1].type if type == TaskTipType.TYPE0 or (type == TaskTipType.TYPE1 and (taskVO.type == TaskType.BOUNTY_LINE or taskVO.type == TaskType.GUILD_LINE or taskVO.type == TaskType.MAIN_LINE)) --支线不算完成,让玩家手动点击 or type == TaskTipType.TYPE2 or type == TaskTipType.TYPE9 or type == TaskTipType.TYPE16 or type == TaskTipType.TYPE18 then --杀怪或者采集 isComplete = cur_num==target_num --数量达到就是完成 print('Ych:TaskController.lua[844] data', isComplete) end --支线进度引导触发 if taskVO.id == 3150001 and cur_num == target_num then GlobalEventSystem:Fire(EventName.TEST_HELP_STEP,HelpType.EXTENSION_LINE_TASK_FINISH) end --如果是社团的送新任务,则判读是否是都完成了 if taskVO.type == TaskType.GUILD_LINE and not isComplete and type == TaskTipType.TYPE7 then local is_complete = true for i,v in ipairs(ttable) do if v.isFinish == 0 then is_complete = false break end end isComplete = is_complete print('Ych:TaskController.lua[861] data', isComplete) end --未完成的话就别请求新的任务列表 if not isComplete then need_req_task_list = false end taskVO.taskTips=ttable taskVO.cur_num = cur_num taskVO.target_num = target_num taskVO.cur_stage = cur_stage -- self.taskModel:Fire(TaskEvent.TASK_LIST_INIT, false) -- self.taskModel:Fire(TaskEvent.REFRESH_TASK_DATA, taskVO.id) for i,v in ipairs(ttable) do if v.type == TaskTipType.TYPE9 then --要结束采集,(以结束对话来结束) GlobalEventSystem:Fire(EventName.CANCEL_NEXT_COLLECT) end end --处理副本任务偶然的bug if need_req_task_list and TaskModel:getInstance().need_task then self:request30000() need_req_task_list = false end print('Ych:TaskController.lua[888] data', isComplete) if isComplete==true then --重置状态 self.taskModel:ResetFlag() if need_req_task_list and not TaskModel:getInstance().need_task then self:request30000() need_req_task_list = false end if taskVO.type == TaskType.BOUNTY_LINE then GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, TaskType.BOUNTY_LINE) elseif taskVO.type == TaskType.GUILD_LINE then print('Ych:TaskController.lua[887] data', cur_num, target_num, cur_stage) PrintTable(taskVO) if not ((type == TaskTipType.TYPE18 or type == TaskTipType.TYPE16) and cur_num == 0) then GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, TaskType.GUILD_LINE) end end local is_turn_task_and_need_auto = false -- 更新的是转职任务,则弹出任务窗口 if taskVO.type == TaskType.TRUN_LINE then is_turn_task_and_need_auto = self.taskModel:NeedAutoDoTurnTask(taskVO) -- if SceneManager.Instance:IsMainCityorYieldScene() and not is_turn_task_and_need_auto then -- 转职界面涉及到副本,副本内不要弹出界面 -- local turn = ReincarnationModel:getInstance():GetCurTurn() -- ReincarnationModel:getInstance():Fire(ReincarnationModel.OPEN_REIN_MAIN_TASK_VIEW, true, turn) -- end end --自动寻路 local _play_action = function() if taskVO.type ~= TaskType.LIMIT_LINE -- 限时任务不自动做 and (taskVO.type ~= TaskType.TRUN_LINE or taskVO.type == TaskType.TRUN_LINE and is_turn_task_and_need_auto -- 非需自动的转职任务不自动做 ) then GlobalEventSystem:Fire(SceneEventType.SHOW_TASK, tonumber(taskVO.tipParam[3])) end if self.timer_id then GlobalTimerQuest:CancelQuest(self.timer_id) self.timer_id = nil end end if isComplete == true and taskVO.need_find_way == 1 and taskVO.tipParam[2] and taskVO.tipParam[3] then elseif taskVO.tipParam[1] and (taskVO.tipParam[1] == TaskTipType.TYPE7 or taskVO.tipParam[1] == TaskTipType.TYPE8 or taskVO.tipParam[1] == TaskTipType.TYPE9) then --不需要寻路完成的对话任务 if SceneManager:getInstance():IsSceneStart() then local delay_call = function () _play_action() end if not self.timer_id then self.timer_id = GlobalTimerQuest:AddDelayQuest(delay_call, 0.1) end else local function complete_fun() _play_action() if self.event_id then GlobalEventSystem:UnBind(self.event_id) self.event_id = nil end end if not self.event_id then self.event_id = GlobalEventSystem:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, complete_fun) end end end end end end self:DoTaskNotify() end function TaskController:DoTaskNotify( ) --分时刷新 local function callback() self.taskModel:Fire(TaskEvent.TASK_LIST_INIT) end local is_limit = false if RoleManager.Instance.mainRoleInfo.level > 70 then is_limit = true end if is_limit then TimeManager.GetInstance():StartTime("TaskController_UpdateTaskProgress", 0.6, callback) else callback() end end function TaskController:request30005(id) self:SendFmtToGame(30005,"i", id) end function TaskController:handler30005() local code = self:ReadFmt("i") if code > 0 then self:request30000() end end function TaskController:handler30017( ) local len = UserMsgAdapter.ReadFmt("h") local temp_list = {} for i=1,len do local id = UserMsgAdapter.ReadFmt("i") temp_list[id] = id end self.taskModel:SetFinishTaskList(temp_list) if ServerTimeController.Instance and ServerTimeController.Instance.open_init_eveny_can_fire then--是否可以发送任务完成列表协议 ServerTimeController.Instance.open_init_eveny_can_fire = false GlobalEventSystem:Fire(EventName.OPEN_DAY_INIT) end BaseDungeonModel:getInstance():Fire(BaseDungeonModel.ON_FINISHED_TASK_DATA_RECEIVED) end function TaskController:request30018(id) self:SendFmtToGame(30018,"i", id) end function TaskController:handler30018( ) local code = self:ReadFmt("i") if code == 3000008 then -- if self.taskModel.opening_circle_buy_tip then -- self.taskModel.wait_circle_buy_tip_close = true -- end self:request30000() else ErrorCodeShow(code) end end function TaskController:handler30019( ) local code = self:ReadFmt("i") local task_type = self:ReadFmt("c") local reward_progress = self:ReadFmt("c") if code == 1 then local info = DeepCopy(TaskModel:getInstance():GetCircleTaskInfo(task_type)) if info then info.reward_progress = reward_progress self.taskModel:SetCircleTaskInfo( info ) --改需求了,直接关界面 -- GlobalEventSystem:Fire(EventName.REFRESH_TASK_CIRCLE_TIPS) -- self:DoTaskNotify() else DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, task_type) end GlobalEventSystem:Fire(EventName.CLOSE_TASK_CIRCLE_TIPS) else ErrorCodeShow(code) end end --任务寻路 --2020年2月19日调整修改--force_use_shoe:点击任务栏飞鞋按钮时强制使用飞鞋 function TaskController:findElement(param, use_shoe, force_use_shoe) local use_shoe = false local level = RoleManager.Instance.mainRoleInfo.level if level >= Config.ConfigTaskEffect.GuideLevel then if VipModel:getInstance():CanFreeUseShoe() then use_shoe = true else local is_auto_use_shoe = lua_settingM:GetAutoFlyShoeSet() if force_use_shoe or is_auto_use_shoe then local num = GoodsModel:getInstance():GetTypeGoodsNum(AutoFightManager.FlyGoodsID) use_shoe = num > 0 end end end if self.can_move_timer_id then TimerQuest.CancelQuest(GlobalTimerQuest, self.can_move_timer_id) self.can_move_timer_id = false end if self.fly_timer_id then TimerQuest.CancelQuest(GlobalTimerQuest, self.fly_timer_id) self.fly_timer_id = false end local array=Split(param,",") if Config.ConfigTaskEffect.NeedClickTaskType[tonumber(array[1])] then --点击判断是否已经完成任务,是的话发协议完成任务 local task = TaskModel:getInstance():GetTaskById(tonumber(array[4])) if self.taskModel:IsNeedClickTask(task) then local tip = self.taskModel:GetExtendSpecialTip(task) if tip and tip.isFinish==1 then GlobalEventSystem:Fire(TaskEventType.SEND_TASK_FINISH, task.id) return end end end -- if array and #array > 0 and self.taskModel:NeedFindWayTask(tonumber(array[1])) then -- local main_role = Scene.Instance:GetMainRole() -- if main_role and main_role:CanMove() then -- print("Saber:TaskController [start:814] ------------------------------------------") -- else -- local timer_func = function () -- local main_role = Scene.Instance:GetMainRole() -- if main_role and main_role:CanMove() then -- if self.can_move_timer_id then -- TimerQuest.CancelQuest(GlobalTimerQuest, self.can_move_timer_id) -- self.can_move_timer_id = false -- end -- self:findElement(param,use_shoe) -- local task = self.taskModel:GetTaskById(tonumber(array[4])) -- if self.taskModel:IsAutoDoTask(task) then -- GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT,false,true) -- end -- return -- end -- end -- self.can_move_timer_id = TimerQuest.AddPeriodQuest(GlobalTimerQuest, timer_func, 0.01, -1) -- return -- end -- end if Scene.Instance:HasDropPick() and AutoFightManager:getInstance():GetAutoFightState() and not use_shoe then Scene.Instance.need_task_after_pick = true return end local params={} if #array>0 then self.taskModel.need_check_monster = false local findVo = FindVo.New() findVo.type = -1 local type=tonumber(array[1]) findVo.sceneId = tonumber(array[2]) local sceneId=tonumber(array[2]) local npcId=0 if type == TaskTipType.TYPE0 or type == TaskTipType.TYPE7 or type == TaskTipType.TYPE8 or type == TaskTipType.TYPE9 or type == TaskTipType.TYPE35 or type == TaskTipType.TYPE38 then --NPC if tonumber(array[3]) == 0 then --自言自语 GlobalEventSystem:Fire(SceneEventType.SHOW_TASK, tonumber(array[3])) return else findVo.type = FindVo.NPC findVo.id = tonumber(array[3]) local scene_info = SceneManager.Instance:GetSceneInfo(findVo.sceneId) print("---------find npc-------:", findVo.id, findVo.sceneId, scene_info) if scene_info == nil then print("tanar: TaskController [949] npc scene_info is nil") return end --用小飞鞋,查找数据库获得npc坐标, 如果不需要用则不查数据库 if use_shoe or findVo.sceneId ~= SceneManager.Instance:GetSceneId() then local item = ConfigItemMgr.Instance:GetSceneItem(findVo.sceneId) if item and item.Npcs then local npc = item.Npcs[findVo.id] if npc then findVo.x = npc.x/ SceneObj.LogicRealRatio.x findVo.y = npc.y/ SceneObj.LogicRealRatio.y end end else local npc = SceneManager.Instance:GetNpcVo(findVo.id) --npc寻路,只有npc和主角在同一场景才有位置值 print("---------npc-is nil ?------:", npc) if npc then findVo.x = npc.logic_x findVo.y = npc.logic_y else print("找不到npc", findVo.id) end end end elseif type == TaskTipType.TYPE1 or type == TaskTipType.TYPE18 then --怪物/采集/收集任务 findVo.type = FindVo.MONSTER findVo.id = tonumber(array[3]) local task_id = tonumber(array[4]) findVo.need_check_monster = true if #array == 6 or #array == 7 then findVo.x=tonumber(array[5]) / SceneObj.LogicRealRatio.x findVo.y=tonumber(array[6]) / SceneObj.LogicRealRatio.y end if TaskModel:getInstance().now_task_id then --(注意,一般采集任务不会进这里,因为采集物没有配置random_pos,会走到FindVo.MONSTER) local random_logic_pos, random_real_pos, ignore_rush = TaskModel:getInstance():GetTaskMonsterRandomPos(findVo.id, sceneId) if random_logic_pos then --随机一堆怪物,解决玩家分流问题 --没有飞鞋的时候,打怪任务要走冲刺逻辑 if not ignore_rush and not use_shoe and type == TaskTipType.TYPE1 then local monster = Scene.Instance:FindNearestMonster(findVo.id, false, false) if monster then Scene.Instance:MainRoleAttackMonster(monster) GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT) return else if findVo.sceneId == SceneManager.Instance:GetSceneId() then GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT) Scene.Instance:MainRoleRushToPos(random_real_pos) return end end end local function point_call_back( ) self.taskModel.task_cache_pos = nil --打怪任务 if type == TaskTipType.TYPE1 then GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT) --采集任务 elseif type == TaskTipType.TYPE18 then self.try_collect_left_num = 6--采集物未创建的话,每隔一段时间尝试一下,6次就够了 local try_to_collect = nil--必须这么写 try_to_collect = function ( ) local monster = Scene.Instance:FindNearestMonster(findVo.id, false, true) if monster then local main_role = Scene.Instance.main_role if main_role then if self.task_collect_start_real_pos == nil then self.task_collect_start_real_pos = co.TableXY(main_role:GetRealPos()) else self.task_collect_start_real_pos.x = main_role.real_pos.x self.task_collect_start_real_pos.y = main_role.real_pos.y end if self.task_collect_end_real_pos == nil then self.task_collect_end_real_pos = co.TableXY(monster:GetRealPos()) else self.task_collect_end_real_pos.x = monster.real_pos.x self.task_collect_end_real_pos.y = monster.real_pos.y end main_role:SetDirection(self.task_collect_start_real_pos, self.task_collect_end_real_pos, true , true) end EventSystem.Fire(GlobalEventSystem,EventName.OPEN_COLLECT_VIEW, monster.id, monster:GetVo().type_id, monster:GetVo().pick_time) else self.try_collect_left_num = self.try_collect_left_num - 1 --此时采集物可能还未创建,所以延迟一段时间再尝试 if not self.delay_collect_id and self.try_collect_left_num >= 0 then self.delay_collect_id = GlobalTimerQuest:AddPeriodQuest(try_to_collect, 0.5, 1) end end end try_to_collect() end end findVo.find_range = 0 -- findVo.find_range = 1 -- if type == TaskTipType.TYPE1 then -- findVo.find_range = 3 -- end findVo.x = random_logic_pos.x findVo.y = random_logic_pos.y findVo.type = FindVo.POINT findVo.call_back = point_call_back end end elseif type == TaskTipType.TYPE6 then --收集任务配置的是物品id,直接打怪就行了 local function call_back( ) GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT) end findVo.type = FindVo.POINT local task_id = tonumber(array[4]) if task_id and Config.ConfigWorldMon.CollectTask[task_id] then local collect_task_id = self.taskModel:GetCollectTaskId() if collect_task_id and collect_task_id == task_id then findVo.x = self.collect_task_pos.x findVo.y = self.collect_task_pos.y self.taskModel:ClearCollectTaskId() else local data = Config.ConfigWorldMon.CollectTask[task_id] local index = math.random(1,#data.way_point) local pos = data.way_point[index] findVo.x = pos.x / SceneObj.LogicRealRatio.x findVo.y = pos.y / SceneObj.LogicRealRatio.y self.taskModel:SetCollectTaskId(task_id) self.collect_task_pos = {x = findVo.x,y = findVo.y} end else findVo.x=tonumber(array[5]) / SceneObj.LogicRealRatio.x findVo.y=tonumber(array[6]) / SceneObj.LogicRealRatio.y end findVo.call_back = call_back elseif type == TaskTipType.TYPE16 then --探索场景 findVo.type = FindVo.Explore findVo.sceneId = tonumber(sceneId) local x = tonumber(array[3]) local y = tonumber(array[4]) findVo.x = x / SceneObj.LogicRealRatio.x findVo.y = y / SceneObj.LogicRealRatio.y findVo.time = tonumber(array[5]) findVo.call_back = function () GlobalEventSystem:Fire(TaskEventType.TASK_QUEST) end elseif type == TaskTipType.TYPE2 or type == TaskTipType.TYPE37 or type == TaskTipType.TYPE29 then --通关副本 local task_id = tonumber(array[4]) if task_id and task_id == BossModel.FAKE_MONEY_BOSS_TASK_ID then GlobalEventSystem:Fire(EventName.OPEN_BOSS_VIEW,Config.ConfigBoss.ModuleId.Money) return end local config = Config.Dungeoncfg[tonumber(array[3])] if config and config.type == BaseDungeonModel.DUN_TYPE.PersonBoss then --专属幻魔 local boss_id = false for k,v in pairs(Config.Personalbossinfo) do if v.dun_id == tonumber(array[3]) then boss_id = v.boss_id end end GlobalEventSystem:Fire(EventName.OPEN_BOSS_VIEW,Config.ConfigBoss.ModuleId.Person,boss_id) return end local task = TaskModel:getInstance():GetTaskById(task_id) if task then local open_ui_task = Config.ConfigTaskEffect.OpenUITask[task_id] if task.type == TaskType.EXTENSION_LINE or open_ui_task then --支线特殊处理 local is_open_view = tonumber(array[2])==0 if is_open_view or open_ui_task then --打开副本界面 根据副本id local cfg = Config.Dungeoncfg[tonumber(array[3])] if cfg then if tonumber(cfg.type) == BaseDungeonModel.DUN_TYPE.PersonBoss then OpenFun.Open(460,1) else local dungeon_type = tonumber(cfg.type) if BaseDungeonModel.DungeonSingleType[dungeon_type] then if dungeon_type == BaseDungeonModel.DUN_TYPE.MATERIAL then local open_key = cfg.id - 900 --没有字段区分是哪一个进阶副本,先写死id if open_key and open_key >= 101 and open_key <= 108 then OpenFun.Open(610, open_key) else OpenFun.Open(610, dungeon_type) end else OpenFun.Open(610, dungeon_type) end else OpenFun.Open(215, BaseDungeonModel.DungeonTeamType[dungeon_type]) end end return end else --直接进入副本 setTimeout( function() local config = Config.Dungeoncfg[tonumber(array[3])] if config and config.enter_type == 1 then local main_role = Scene.Instance.main_role if main_role then local enter_dir_angle = main_role:GetDirectionAngle() RoleManager:getInstance():SetEnterDirAngle(enter_dir_angle) end end BaseDungeonModel:getInstance():Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61001, tonumber(array[3])) end,0.3) return end else local dun_id = tonumber(array[3]) local time = 0.3 if dun_id == GuideModel.CHANGE_GOD_SCENE_ID then time = 1 end local function on_delay_enter_dungeon() local config = Config.Dungeoncfg[tonumber(array[3])] if config and config.enter_type == 1 then local main_role = Scene.Instance.main_role if main_role then local enter_dir_angle = main_role:GetDirectionAngle() RoleManager:getInstance():SetEnterDirAngle(enter_dir_angle) end end BaseDungeonModel:getInstance():Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61001, dun_id) end --主线任务无缝加载,距离太远的话要校正一下坐标,先走到策划配置的点再进入副本 local temp_limit_cfg = Config.ConfigChangeSceneEffect.DungeonLimit[dun_id] local need_reset_pos = false if temp_limit_cfg then local target_pos = temp_limit_cfg.enter_pos local cur_scene_id = SceneManager:getInstance():GetSceneId() local dun_scene_id = Config.Dungeoncfg[dun_id].scene_id if dun_scene_id == cur_scene_id then --已经在副本场景里了,则自动战斗 GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT,false,true) return else --走小飞鞋寻路 findVo.type = FindVo.POINT findVo.dunSceneId = dun_scene_id findVo.sceneId = tonumber(temp_limit_cfg.enter_scene_id) local x = tonumber(target_pos.x) local y = tonumber(target_pos.y) findVo.x = x / SceneObj.LogicRealRatio.x findVo.y = y / SceneObj.LogicRealRatio.y local range = temp_limit_cfg.work_min_distance/100 range = range > 1 and range or 0 findVo.range = range findVo.call_back = on_delay_enter_dungeon end else --正常情况是这里进入副本 setTimeout(on_delay_enter_dungeon, time) --自动做的任务, 打完回来要继续 TaskModel:getInstance():SetNeedTaskFlag(true) return end end end -- elseif type == TaskTipType.TYPE25 then --五转 点亮星格 -- GlobalEventSystem:Fire(EventName.OPEN_REINCARNATION_VIEW) -- return elseif type == TaskTipType.TYPE51 then --解锁地狱摩托 OpenFun.Open(114, 0) return elseif type == TaskTipType.TYPE100 then --击杀BOSS GlobalEventSystem:Fire(EventName.OPEN_BOSS_VIEW, tonumber(array[3])) return elseif type == TaskTipType.TYPE101 then --强化装备 OpenFun.Open(152, 1) return elseif type == TaskTipType.TYPE102 then --完成某类型副本 if tonumber(array[3]) == BaseDungeonModel.DUN_TYPE.PersonBoss then OpenFun.Open(460,1) elseif BaseDungeonModel.DungeonTeamType[tonumber(array[3])] then DunManyModel:getInstance():Fire(DunManyModel.OPEN_DUN_MANY_HALL_VIEW,tonumber(array[3])) else BaseDungeonModel:GetInstance():Fire(BaseDungeonModel.OPEN_HALL_VIEW,tonumber(array[3])) end return elseif type == TaskTipType.TYPE103 then --单次副本获得x经验 BaseDungeonModel:getInstance():OpenViewByDunType(tonumber(array[3])) return elseif type == TaskTipType.TYPE104 then --添加好友 GlobalEventSystem:Fire(EventName.OPEN_SOCIALITY_VIEW) setTimeout(function () GlobalEventSystem:Fire(EventName.OPEN_SOCIALITY_VIEW, 2) end,0.15) return elseif type == TaskTipType.TYPE105 then --加入社团 OpenFun.Open(400, 0) -- GlobalEventSystem:Fire(EventName.OPEN_GUILD_APPLY_VIEW) return elseif type == TaskTipType.TYPE106 then --社团装备回收 if RoleManager.Instance.mainRoleInfo.level >= Config.ConfigOpenLv.EquipSwallow then GlobalEventSystem:Fire(EventName.OPEN_PET_SWALLOW_VIEW) else Message.show("熔炼功能" .. Config.ConfigOpenLv.EquipSwallow .."级开启哦") end return elseif type == TaskTipType.TYPE107 then --完成社团活动 if RoleManager.Instance.mainRoleInfo.guild_id>0 then local contentId = tonumber(array[3]) OpenFun.Open(402, contentId) else Message.show("请先加入一个社团") end return elseif type == TaskTipType.TYPE108 then --捐献一件装备到社团仓库 -- if RoleManager.Instance.mainRoleInfo.guild_id>0 then -- if GuildModel:getInstance():GetGuildBuildLvInfo(GuildModel.GUILD_DEPOT) == 0 then -- Message.show("暂时未开启此建筑") -- else -- GlobalEventSystem:Fire(EventName.OPEN_GUILD_MAIN_VIEW, 3) -- end -- else -- Message.show("请先加入一个社团") -- end return elseif type == TaskTipType.TYPE109 then --在市场上购买1个商品 GlobalEventSystem:Fire(EventName.OPEN_MARKET_VIEW, 1) return elseif type == TaskTipType.TYPE110 then --在市场上架1个物品 GlobalEventSystem:Fire(EventName.OPEN_MARKET_VIEW, 3) return elseif type == TaskTipType.TYPE23 then --合成物品 --合成按钮跳转 local type_id = tonumber(array[3]) ComposeModel.Instance:TryComposeJump(type_id) return elseif type == TaskTipType.TYPE24 then --活跃度 GlobalEventSystem:Fire(ActivityIconManager.SHOW_LEAD_EFFECT,157) return elseif type == TaskTipType.TYPE26 then --吞噬 if RoleManager.Instance.mainRoleInfo.level >= Config.ConfigOpenLv.EquipSwallow then GlobalEventSystem:Fire(EventName.OPEN_PET_SWALLOW_VIEW) else Message.show("熔炼功能" .. Config.ConfigOpenLv.EquipSwallow .."级开启哦") end return elseif type == TaskTipType.TYPE27 then --击杀首领 local kill_type = tonumber(array[2]) local monster_id = tonumber(array[3]) if monster_id and kill_type then local boss_type = TaskModel.TYPE27_KILL_TYPE[kill_type] GlobalEventSystem:Fire(EventName.OPEN_BOSS_VIEW, boss_type, monster_id) end return elseif type == TaskTipType.TYPE28 then --钓鱼之路 GlobalEventSystem:Fire(EventName.OPEN_SKILL_VIEW,4,1,true) return elseif type == TaskTipType.TYPE111 then --击杀首领 local dun_id = tonumber(array[3]) if dun_id then local config = Config.Dungeoncfg[dun_id] if config then if config.type == 20 then --"宝石副本" OpenFun.Open(610,37) elseif config.type == 21 then -- "神格副本" OpenFun.Open(610,23) elseif config.type == 5 then -- "装备副本" OpenFun.Open(610,32) end end end return elseif type == TaskTipType.TYPE36 then --装备附能 OpenFun.Open(152,5) return elseif type == TaskTipType.TYPE39 then --装备升星 OpenFun.Open(152,2) return elseif type == TaskTipType.TYPE31 then --竞技场次数 OpenFun.Open(280,0) return elseif type == TaskTipType.TYPE40 then --商城购买 local shop_key_id = tonumber(array[2]) local temp_cfg = Config.Shop[shop_key_id] local show_open_effect = true--针对一些特别的显示特效不显示tip if show_open_effect then GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, temp_cfg.shop_type, temp_cfg.sub_type, temp_cfg.goods_id, nil,true) else GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, temp_cfg.shop_type, temp_cfg.sub_type, temp_cfg.goods_id, true) end return elseif type == TaskTipType.TYPE34 then --进入某类副本 local dungeon_type = tonumber(array[3]) if BaseDungeonModel.DungeonSingleType[dungeon_type] then OpenFun.Open(610, dungeon_type) else OpenFun.Open(215, BaseDungeonModel.DungeonTeamType[dungeon_type]) end return elseif type == TaskTipType.TYPE41 or type == TaskTipType.TYPE42 then --好友送礼/好友亲密度 OpenFun.Open(140, 1) return elseif type == TaskTipType.TYPE43 then --进阶系统升级 OpenFun.Open(146,tonumber(array[3])) return elseif type == TaskTipType.TYPE56 then --进阶目标(进阶到一定阶数) OpenFun.Open(146,tonumber(array[3])) return elseif type == TaskTipType.TYPE44 then --升品之路 OpenFun.Open(414, 0) return elseif type == TaskTipType.TYPE45 then --唤神升级 OpenFun.Open(173, 1) return elseif type == TaskTipType.TYPE46 then --星辰升级 OpenFun.Open(148,1) return elseif type == TaskTipType.TYPE47 then --宠物升级 OpenFun.Open(163,1) return elseif type == TaskTipType.TYPE48 then --晒娃 OpenFun.Open(165,1) return elseif type == TaskTipType.TYPE49 then --装备圣物 OpenFun.Open(139,2) return elseif type == TaskTipType.TYPE50 then --圣物寻宝 OpenFun.Open(139,7) return elseif type == TaskTipType.TYPE52 then --转职目标 GlobalEventSystem:Fire(EventName.OPEN_NEW_MAIN_ROLE_VIEW, NewMainRoleModel.TabId.REIN) return elseif type == TaskTipType.TYPE53 then --龙神抽奖 OpenFun.Open(170,1) return elseif type == TaskTipType.TYPE54 then --装备套装 local dai_num = tonumber(array[3]) local color = tonumber(array[2]) EquipCollectModel:getInstance():Fire(EquipCollectConst.OPEN_EC_MAIN_VIEW,true, EquipCollectConst.TAB_ID.COLLECT, dai_num, color, color) return elseif type == TaskTipType.TYPE55 then --战魂强化 OpenFun.Open(143,5) return elseif type == TaskTipType.TYPE57 then --完成预期任务 self:AutoDoTask(true, true)--直接做主线 return elseif type == TaskTipType.TYPE58 then --宝宝同心值 OpenFun.Open(165,0) return elseif type == TaskTipType.TYPE59 then --战力 --这里不做任何处理,放到item点击处 return elseif type == TaskTipType.TYPE60 then --任意主动技能升级次数 OpenFun.Open(210,1) return elseif type == TaskTipType.TYPE61 then --指定商店购买技能书 local temp_cfg = Config.Shop[10317] --指定第一本技能书的商店配置 local career = RoleManager.Instance.mainRoleInfo.career local goods_table = { [1] = 210101, [2] = 210201, [3] = 210301, [4] = 210401, } GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, temp_cfg.shop_type, temp_cfg.sub_type, goods_table[career], nil, true) return elseif type == TaskTipType.TYPE62 then --任意商店技能书购买 GlobalEventSystem:Fire(EventName.SHOW_MAIN_GET_SKILL_TASK_TIPS_VIEW, true) return end --跨服主城场景id校正 if findVo.sceneId and (findVo.sceneId == KfWorldConst.BFCitySceneId or findVo.sceneId == KfWorldConst.KFCitySceneId) then if KfWorldModel:GetInstance():IsKFCityOpen() then findVo.sceneId = KfWorldConst.KFCitySceneId else findVo.sceneId = KfWorldConst.BFCitySceneId end end local function on_find_vo_func() Scene.Instance:ResetUserManulState() --到了执行寻路回调这里,就可以重置寻路缓存状态了 local cur_scene_id = SceneManager.Instance:GetSceneId() if findVo.dunSceneId and findVo.dunSceneId == cur_scene_id then --进入镜像副本之后,就不要再切场景了 GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT,false,true) elseif (findVo.sceneId == cur_scene_id) or SceneManager:getInstance():IsMappingToSameScene(cur_scene_id, findVo.sceneId) then --已经是目标场景了,开始寻路,这里要兼容一下主城跟跨服主城 GlobalEventSystem:Fire(EventName.FIND, findVo) else --如果不在同场景, 先切场景 TaskModel:getInstance():SetNeedTaskFlag(true) GlobalEventSystem:Fire(SceneEventType.REQUEST_CHANGE_SCENE, findVo.sceneId, nil, SceneTransType.GateAny, findVo.x, findVo.y) end end if use_shoe then --使用小飞鞋 TaskModel:getInstance():SetChangeSceneType(false, false) if findVo.sceneId ~= SceneManager.Instance:GetSceneId() then TaskModel:getInstance():SetNeedTaskFlag(true) end local end_pos = GameMath.GetPosByCeterPoint(findVo.x * SceneObj.LogicRealRatio.x,findVo.y * SceneObj.LogicRealRatio.y, 100) local fly_shoe_scene_id = SceneManager.Instance:GetSceneId() local call_back = function ( ) if findVo.sceneId == fly_shoe_scene_id then on_find_vo_func() else self.fly_timer_id = setTimeout(on_find_vo_func,0.5) end end GlobalEventSystem:Fire(EventName.USE_FLY_SHOE, findVo.sceneId, end_pos.x,end_pos.y, call_back) else TaskModel:getInstance():SetChangeSceneType(SceneTransType.GateAny, findVo) if findVo.sceneId ~= SceneManager.Instance:GetSceneId() then TaskModel:getInstance():SetNeedTaskFlag(true) end GlobalEventSystem:Fire(EventName.FIND, findVo, change_scene_type) end end end -----------------界面相关----------------- function TaskController:OpenTaskView(index,task_id,parent_index,sub_index) if self.TaskNewBaseView == nil then self.TaskNewBaseView = TaskNewBaseView.New() end self.TaskNewBaseView:Open(index, task_id,parent_index,sub_index) end function TaskController:CheckNewMainLineTip( ) local level = RoleManager.Instance.mainRoleInfo.level if level < Config.ConfigTaskEffect.NewMainLineTipLvMin or Config.ConfigTaskEffect.NewMainLineTipLvMax < level then return end local cur_task = self.taskModel:GetMainTask() if not self.mark_main_line_list then self.mark_main_line_list = {[0] = true} end if cur_task then if not self.mark_main_line_list[cur_task.id] then --新任务,标记起来 self.mark_main_line_list[cur_task.id] = true if self.next_need_new_main_tip or (not self.first_call_new_tip) then self.taskModel.tip_new_main_line = cur_task.id GuideController.Instance:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE, 9993150002) self.taskModel:Fire(TaskEvent.SHOW_NEW_MAIN_LINE_TIP) end end end --上一次是无主线,下一次才需要,或者第一次调用 self.next_need_new_main_tip = (not (cur_task and cur_task.id > 0))-- or (not self.first_call_new_tip) if not self.first_call_new_tip then self.first_call_new_tip = true end end function TaskController:CheckWaitNewMainLineAccept( ) --等待断级主线的接取,那次30000协议返回不用自动任务 if Config.ConfigTaskEffect.GuideLevel < RoleManager.Instance.mainRoleInfo.level then local cur_task = self.taskModel:GetMainTask() local b = (not (cur_task and cur_task.id > 0 and cur_task.id ~= Config.ConfigTaskEffect.DefaultTaskId)) --如果当前卡主线了,等级达到一定程度,如果当前有跑环任务,就去跑环 if b == true and self.main_line_break_wait == false and RoleManager.Instance.mainRoleInfo.level >= Config.ConfigTaskEffect.WhenBreakMainLineGotoDoDailyTaskLevel then self.taskModel:JustDoDailyCircleTask() end self.main_line_break_wait = b end end