源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1704 行
64 KiB

  1. --[[
  2. @description:
  3. ]]
  4. require("game.task.TaskModel")
  5. require("game.task.TaskNewBaseView")
  6. require("game.task.TaskSubMainView")
  7. require("game.task.TaskSubExtensionView")
  8. require("game.task.TaskVerTabSubBtn")
  9. require("game.task.TaskSubCommonView")
  10. require("game.task.vo.TaskVo")
  11. require("game.task.vo.TaskTipsVo")
  12. require("game.task.TaskEvent")
  13. require("game.task.TaskLang")
  14. require("game.task.TaskFinishTipView")
  15. require("game.task.TaskDailyView")
  16. require("game.task.TaskDailyItem")
  17. require("game.task.TaskBountyRewardView")
  18. -------------------------
  19. --新的
  20. require("game.task.TaskCircleBuyTip")
  21. require("game.task.FlyShoeBuyTip")
  22. -------------------------
  23. TaskController = TaskController or BaseClass(BaseController)
  24. local TaskController = TaskController
  25. local table_insert = table.insert
  26. function TaskController:__init()
  27. TaskController.Instance = self
  28. self.taskModel = TaskModel:getInstance()
  29. self.taskModel.after_scene_start = false
  30. self:RegisterAllProtocals()
  31. self:EnableCheckoutClear()
  32. self:InitEvent()
  33. end
  34. function TaskController:RegisterAllProtocals()
  35. self:RegisterProtocal(30000, "handler30000")--可接任务和已接任务列表
  36. self:RegisterProtocal(30001, "handler30001")--完成任务某环节
  37. self:RegisterProtocal(30005, "handler30005")--放弃任务
  38. self:RegisterProtocal(30017, "handler30017")--已完成任务列表
  39. self:RegisterProtocal(30018, "handler30018")--快速完成任务
  40. self:RegisterProtocal(30019, "handler30019")--领取跑环额外奖励
  41. end
  42. function TaskController:InitEvent()
  43. local open_task_view = function (index,task_id,parent_index,sub_index)
  44. self:OpenTaskView(index,task_id,parent_index,sub_index)
  45. end
  46. GlobalEventSystem:Bind(EventName.OPEN_TASK_VIEW, open_task_view)
  47. --场景开始了
  48. local function loginComplete()
  49. if self.taskModel.game_start_request == true then
  50. self.taskModel.game_start_request = false
  51. self.taskModel:HideRoleWeapon() --可能30000第一次返回的时候主角还没创建,场景开始后,主角一定创建了,这里再判断是否隐藏武器
  52. end
  53. end
  54. GlobalEventSystem:Bind(SceneManager.START,loginComplete)
  55. local game_start_fun = function ()
  56. self.main_line_break_wait = nil
  57. self.not_guide_wait_accept_main_task = nil
  58. self.mark_main_line_list = nil
  59. self.first_call_new_tip = nil
  60. self.taskModel:ClearData()
  61. setTimeout(
  62. function()
  63. DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30012)
  64. DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, 6)
  65. DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, 7)
  66. self:request30000()
  67. end,0.6)
  68. if self.auto_check_do_task_timer then
  69. GlobalTimerQuest:CancelQuest(self.auto_check_do_task_timer)
  70. self.auto_check_do_task_timer = nil
  71. end
  72. if self.can_move_timer_id then
  73. TimerQuest.CancelQuest(GlobalTimerQuest, self.can_move_timer_id)
  74. self.can_move_timer_id = false
  75. end
  76. self:ClearBreakLevelTimer()
  77. end
  78. GlobalEventSystem:Bind(EventName.GAME_START, game_start_fun)
  79. local function onRequeseTaskData( )
  80. self:request30000()
  81. end
  82. GlobalEventSystem:Bind(EventName.REQUEST_TASK_DATA, onRequeseTaskData)
  83. local function CIRCLE_TASK_QUICK_FINISH( id )
  84. self:request30018(id)
  85. end
  86. GlobalEventSystem:Bind(TaskEventType.CIRCLE_TASK_QUICK_FINISH, CIRCLE_TASK_QUICK_FINISH)
  87. --@force_use_shoe:点击任务栏飞鞋按钮时强制使用飞鞋
  88. local find_way_fun = function (params, use_shoe,force_use_shoe)
  89. self:findElement(params,use_shoe,force_use_shoe)
  90. end
  91. GlobalEventSystem:Bind(EventName.WAYFINDING, find_way_fun)--寻路
  92. local function loadComplete()
  93. --必须npc加载完, 场景加载完,才能继续做任务
  94. self.taskModel.proto_count = self.taskModel.proto_count + 1
  95. self.delay_fly_down_to_do_task = false
  96. if self.taskModel.proto_count >= 2 then
  97. self.taskModel.proto_count = 0
  98. self:ClearAutoDoTaskTimer()
  99. if SceneManager:getInstance():IsMainCityorYieldScene() then
  100. --切场景后自动寻路
  101. print("tanar: [TaskController 117]=> self.taskModel.need_task: ",self.taskModel.need_task)
  102. print("tanar: [TaskController 118]=> guide_force_do_task: ",guide_force_do_task)
  103. local guide_force_do_task = GuideModel:getInstance().need_force_do_task --引导触发的自动任务
  104. if self.taskModel.need_task or guide_force_do_task then
  105. if guide_force_do_task then
  106. GuideModel:getInstance().need_force_do_task = false
  107. end
  108. self.taskModel:SetNeedTaskFlag(false)
  109. self.taskModel:SetTaskAutoFlag(false)
  110. local onDelay = function( )
  111. local mainRole = Scene.Instance:GetMainRole()
  112. if mainRole and mainRole:IsInState(PoseState.FLY_SHOE_EFFECT) then
  113. self.delay_fly_down_to_do_task = true
  114. else
  115. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true)
  116. end
  117. end
  118. setTimeout(onDelay, 1.1)
  119. end
  120. end
  121. GlobalEventSystem:Fire(EventName.CAN_FIND_NPC)
  122. end
  123. end
  124. GlobalEventSystem:Bind(EventName.NPC_LOAD_FINISH, loadComplete)
  125. local function scene_load_view_complete( )
  126. loadComplete()
  127. --需要清掉标志,不然副本挂机会找不到怪
  128. TaskModel:getInstance().need_check_monster = false
  129. --如果不在安全场景或者也要,停止做任务 寻路也停掉,避免无法挂机
  130. if not SceneManager:getInstance():IsMainCityorYieldScene() then
  131. GlobalEventSystem:Fire(EventName.FORCE_STOP_DO_TASK)
  132. else
  133. if self.taskModel.need_show_circle_tip then
  134. GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS,self.taskModel.need_show_circle_tip)
  135. self.taskModel.need_show_circle_tip = false
  136. end
  137. if self.taskModel.wait_circle_show_award_data then
  138. -- GlobalEventSystem:Fire(NatureModel.OPEN_AWARD_RESULT_VIEW, self.taskModel.wait_circle_show_award_data)
  139. GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, self.taskModel.wait_circle_show_award_data)
  140. self.taskModel.wait_circle_show_award_data = false
  141. end
  142. end
  143. if self.auto_check_do_task_timer then
  144. GlobalTimerQuest:CancelQuest(self.auto_check_do_task_timer)
  145. self.auto_check_do_task_timer = nil
  146. end
  147. end
  148. GlobalEventSystem:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, scene_load_view_complete)
  149. local function doFlyShoeEffectFinishDown()
  150. if self.delay_fly_down_to_do_task then
  151. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true)
  152. self.delay_fly_down_to_do_task = false
  153. end
  154. end
  155. GlobalEventSystem:Bind(SceneEventType.DO_FLYSHOE_EFFECT_FINISH_DOWN,doFlyShoeEffectFinishDown)
  156. local function main_role_move_end()
  157. self:CreateAutoDoTaskTimer()
  158. end
  159. GlobalEventSystem:Bind(SceneEventType.MAIN_ROLE_MOVE_END, main_role_move_end)
  160. GlobalEventSystem:Bind(EventName.CREATE_MAIN_TASK_TIP, main_role_move_end)
  161. --是否继续开始任务
  162. local function reopen_fun(now)
  163. print("-------START_AUTO-------------", self.taskModel.now_task_id, self.taskModel.is_stop)
  164. -- local mainrole = Scene:getInstance():GetMainRole()
  165. -- if mainrole and mainrole:IsInState(PoseState.FLY) or mainrole:IsInState(PoseState.FLY_SHOE_EFFECT) or mainrole:IsInState(PoseState.FLY_SHOE) then
  166. -- -- Message.show("请落地后重试~")
  167. -- if self.taskModel.is_auto_task and self.taskModel.is_stop then
  168. -- local function task_load_scene_func( ... )
  169. -- GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK)
  170. -- end
  171. -- self.task_load_scene_func = task_load_scene_func--任务场景加载完后调什么
  172. -- self.task_load_scene_func_time = TimeUtil:getServerTime( )--事件时间
  173. -- end
  174. -- return
  175. -- end--飞鞋状态下开始任务
  176. if self.taskModel.is_auto_task and self.taskModel.is_stop then
  177. local delay_fun = function ()
  178. self.taskModel.is_stop = false
  179. -- GlobalEventSystem:Fire(EventName.FINDWAY_ENDED)
  180. self:AutoDoTask()
  181. end
  182. if now then
  183. delay_fun()
  184. else
  185. self.later_time_id = GlobalTimerQuest:AddDelayQuest(delay_fun, 0.6)
  186. end
  187. end
  188. end
  189. GlobalEventSystem:Bind(EventName.START_AUTO_DO_TASK, reopen_fun)
  190. --暂停自动寻路
  191. local function close_fun()
  192. -- local mainrole = Scene:getInstance():GetMainRole()
  193. -- if mainrole and mainrole:IsInState(PoseState.FLY) or mainrole:IsInState(PoseState.FLY_SHOE_EFFECT) or mainrole:IsInState(PoseState.FLY_SHOE) then
  194. -- -- Message.show("请落地后重试~")
  195. -- if self.taskModel.is_auto_task and self.taskModel.is_stop then
  196. -- if self.task_load_scene_func_time and self.task_load_scene_func_time <= TimeUtil:getServerTime( ) then--时间要满足先后顺序
  197. -- self.task_load_scene_func = nil--任务场景加载完后调什么
  198. -- self.task_load_scene_func_time = nil--事件时间
  199. -- end
  200. -- end
  201. -- end--飞鞋状态下停止任务
  202. self:ClearAutoDoTaskTimer()
  203. self.taskModel.is_stop = true--停止任务标记
  204. if not EscortModel:getInstance():IsEscortState() then--护送状态接着护送
  205. OperateManager.Instance:StopMove(true) --先清掉当前场景的操作包,避免继续移动寻路
  206. end
  207. if self.later_time_id then
  208. GlobalTimerQuest:CancelQuest(self.later_time_id)
  209. self.later_time_id = nil
  210. end
  211. end
  212. GlobalEventSystem:Bind(EventName.STOP_AUTO_DO_TASK, close_fun)
  213. --不再做任务
  214. local function stop_fun()
  215. self:ClearAutoDoTaskTimer()
  216. -- print("---------NOT_TASK---------:", self.taskModel.now_task_id, self.taskModel.is_stop)
  217. TaskModel:getInstance():SetTaskAutoFlag(false)
  218. local is_fire_evt = OperateManager.Instance:StopMove(true) --先清掉当前场景的操作包,避免继续移动寻路
  219. if not is_fire_evt then
  220. GlobalEventSystem:Fire(EventName.FINDWAY_ENDED)
  221. end
  222. end
  223. GlobalEventSystem:Bind(EventName.FORCE_STOP_DO_TASK, stop_fun)
  224. local do_first_task = function (force, is_force_main_line)
  225. TaskModel:getInstance():SetTaskAutoFlag(true)
  226. self.taskModel.is_stop = false
  227. self:AutoDoTask(force, is_force_main_line)
  228. end
  229. GlobalEventSystem:Bind(EventName.FORCE_TO_DO_TASK, do_first_task)
  230. local function onOpenTaskFinishView(show, task_type, task_id)
  231. if show then
  232. if self.TaskFinishTipView == nil then
  233. self.TaskFinishTipView = TaskFinishTipView.New()
  234. end
  235. self.TaskFinishTipView:Open(task_type, task_id)
  236. else
  237. if self.TaskFinishTipView and self.TaskFinishTipView:HasOpen() then
  238. self.TaskFinishTipView:Close()
  239. end
  240. end
  241. end
  242. GlobalEventSystem:Bind(EventName.OPEN_TASK_FINISH_TIP_VIEW, onOpenTaskFinishView)
  243. local function onOpenTaskDailyView(show)
  244. if show then
  245. if self.TaskDailyView == nil then
  246. self.TaskDailyView = TaskDailyView.New()
  247. end
  248. self.TaskDailyView:Open()
  249. else
  250. if self.TaskDailyView and self.TaskDailyView:HasOpen() then
  251. self.TaskDailyView:Close()
  252. end
  253. end
  254. end
  255. GlobalEventSystem:Bind(EventName.OPEN_TASK_DAILY_VIEW, onOpenTaskDailyView)
  256. local function onOpenTaskBountyRewardView(circle_num,is_close)
  257. if is_close then
  258. if self.TaskBountyRewardView and self.TaskBountyRewardView:HasOpen() then
  259. self.TaskBountyRewardView:Close()
  260. end
  261. else
  262. if GuideModel:getInstance():IsPromptViewOpen() or GuideModel:getInstance():IsHideSmallUI() then
  263. return
  264. end
  265. if self.TaskBountyRewardView == nil then
  266. self.TaskBountyRewardView = TaskBountyRewardView.New()
  267. end
  268. self.TaskBountyRewardView:Open(circle_num)
  269. end
  270. end
  271. GlobalEventSystem:Bind(EventName.OPEN_TASK_BOUNTY_REWARD_VIEW, onOpenTaskBountyRewardView)
  272. local function change_account()
  273. if self.auto_check_do_task_timer then
  274. GlobalTimerQuest:CancelQuest(self.auto_check_do_task_timer)
  275. self.auto_check_do_task_timer = nil
  276. end
  277. self:ClearBreakLevelTimer()
  278. end
  279. GlobalEventSystem:Bind(EventName.CHANGE_ACCOUNT,change_account)
  280. GlobalEventSystem:Bind(EventName.CHANGE_ROLE,change_account)
  281. local function onShowBreakLevelTimer()
  282. self:ClearBreakLevelTimer()
  283. if SceneManager:getInstance():IsMainCityorYieldScene() then
  284. local function onTimer()
  285. local main_role = Scene.Instance.main_role
  286. if main_role and main_role.stand_init_time > 25 then
  287. if self.taskModel.showExtendTip then
  288. GuideModel:getInstance():TriggerBreakLevelGuide()
  289. self:ClearBreakLevelTimer()
  290. end
  291. end
  292. end
  293. self.show_break_level_timer = GlobalTimerQuest:AddPeriodQuest(onTimer,30)
  294. end
  295. end
  296. self.taskModel:Bind(TaskEvent.SHOW_BREAK_LEVEL_TIMER, onShowBreakLevelTimer)
  297. local function CONTINUE_TASK( task_type )
  298. local circle_data = self.taskModel:GetCircleTaskInfo(task_type)
  299. local task_data = self.taskModel:GetTaskByType( task_type )
  300. if circle_data and (not task_data) then
  301. if circle_data.task_type == TaskType.GUILD_LINE then
  302. task_data = self.taskModel:GetGuildTipTask()
  303. elseif circle_data.task_type == TaskType.BOUNTY_LINE then
  304. task_data = self.taskModel:GetBountyTipTask()
  305. end
  306. end
  307. -------------------------
  308. if task_data then
  309. local vip = RoleManager.Instance.mainRoleInfo.vip_flag
  310. if vip > 0 and self.taskModel:IsShowFlyShoe(task_data) then
  311. self.taskModel:TaskClickFun(task_data,true)
  312. else
  313. self.taskModel:TaskClickFun(task_data)
  314. end
  315. if task_type == TaskType.BOUNTY_LINE or task_type == TaskType.GUILD_LINE then
  316. GlobalEventSystem:Fire(KfActivityModel.OPEN_ACTIVITY_BASE_VIEW,nil,nil,true)--触发任务关闭活动界面
  317. end
  318. else
  319. if task_type == TaskType.GUILD_LINE then
  320. local guild_id = RoleManager.Instance.mainRoleInfo.guild_id
  321. if not guild_id or guild_id == 0 then
  322. Message.show("请先加入社团")
  323. end
  324. end
  325. end
  326. end
  327. self.taskModel:Bind(TaskEvent.CONTINUE_TASK, CONTINUE_TASK)
  328. local function OPEN_QUICK_CIRCLE_TIPS( data )
  329. self.taskcirclebuytip = self.taskcirclebuytip or TaskCircleBuyTip.New()
  330. self.taskcirclebuytip:Open(data)
  331. end
  332. self.taskModel:Bind(TaskEvent.OPEN_QUICK_CIRCLE_TIPS,OPEN_QUICK_CIRCLE_TIPS)
  333. local function OPEN_BUY_SHOE_TIPS( buy_call )
  334. self.flyshoebuytip = self.flyshoebuytip or FlyShoeBuyTip.New()
  335. self.flyshoebuytip:Open(buy_call)
  336. end
  337. self.taskModel:Bind(TaskEvent.OPEN_BUY_SHOE_TIPS,OPEN_BUY_SHOE_TIPS)
  338. local function onGuildChange()
  339. self:DoTaskNotify()
  340. end
  341. RoleManager:getInstance():GetMainRoleVo():BindOne("guild_id", onGuildChange)
  342. end
  343. function TaskController:ClearBreakLevelTimer()
  344. if self.show_break_level_timer then
  345. GlobalTimerQuest:CancelQuest(self.show_break_level_timer)
  346. self.show_break_level_timer = nil
  347. end
  348. end
  349. function TaskController:CheckAutoDoTaskTimer()
  350. do return end
  351. -- if self.auto_check_do_task_timer then
  352. -- GlobalTimerQuest:CancelQuest(self.auto_check_do_task_timer)
  353. -- self.auto_check_do_task_timer = nil
  354. -- end
  355. -- local playerLv = RoleManager:getInstance():GetMainRoleVo().level
  356. -- if playerLv <= 120 and SceneManager:getInstance():IsMainCityorYieldScene() then
  357. -- local function onTimer()
  358. -- local playerLv = RoleManager:getInstance():GetMainRoleVo().level
  359. -- if playerLv > 1 and playerLv <= 120 then
  360. -- local main_role = Scene.Instance.main_role
  361. -- if main_role and main_role.stand_init_time > 35 and lua_viewM.main_cancas_last_visible then
  362. -- local taskVo = TaskModel:getInstance():GetTaskByType(TaskType.MAIN_LINE) or TaskModel:getInstance():GetTaskByType(TaskType.BOUNTY_LINE) or TaskModel:getInstance():GetBountyTipTask()
  363. -- if taskVo then
  364. -- TaskModel:getInstance().need_do_task_type = 0
  365. -- TaskModel:getInstance().last_task_type_cache = false
  366. -- TaskModel:getInstance().now_task_id = taskVo.id
  367. -- GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true)
  368. -- end
  369. -- end
  370. -- end
  371. -- end
  372. -- self.auto_check_do_task_timer = GlobalTimerQuest:AddPeriodQuest(onTimer,40)
  373. -- end
  374. end
  375. --创建自动开始任务定时器
  376. function TaskController:CreateAutoDoTaskTimer()
  377. do return end
  378. self:ClearAutoDoTaskTimer()
  379. if self.taskModel.is_auto_task then
  380. local playerLv = RoleManager:getInstance():GetMainRoleVo().level
  381. if playerLv <= 120 then
  382. local function func()
  383. if self.taskModel.is_auto_task and Scene.Instance.main_role and Scene.Instance.main_role:IsInState(PoseState.STAND) then
  384. if Scene.Instance.main_role.stand_init_time and Scene.Instance.main_role.stand_init_time > 4 then
  385. self:AutoDoTask()
  386. end
  387. end
  388. end
  389. self.auto_do_timer = GlobalTimerQuest:AddDelayQuest(func, 5)
  390. end
  391. end
  392. end
  393. --自动开始任务 force 30000返回的时候,可能是接完支线,就算是打开界面的任务类型, 也自动做
  394. function TaskController:AutoDoTask(force, is_force_main_line)
  395. --if ClientConfig.alpha_mode then return end
  396. self:ClearAutoDoTaskTimer()
  397. self.taskModel.guild_kill_monster_num = 0
  398. if Scene.Instance:IsSceneProloadFinish() then
  399. if SceneManager.Instance:IsMainCityorYieldScene() then
  400. local cur_task
  401. if is_force_main_line then
  402. cur_task = self.taskModel:GetMainTask()
  403. else
  404. cur_task = self.taskModel:GetCurTask()
  405. end
  406. print("Saber:TaskController [413] cur_task: ",cur_task)
  407. print("tanar: [TaskController 419]=> is_force_main_line: ",is_force_main_line)
  408. print("tanar: TaskController [386] ====== AutoDoTask parms: force = ", force)
  409. print("not self.taskModel:IsWaitProto(): ",not self.taskModel:IsWaitProto())
  410. print("self.taskModel:IsAutoDoTask(cur_task): ",self.taskModel:IsAutoDoTask(cur_task))
  411. print("cur_task and cur_task.mainTip == false: ",cur_task and cur_task.mainTip == false)
  412. print("self.taskModel.is_stop == false: ",self.taskModel.is_stop == false)
  413. print("self.taskModel.now_task_id: ",self.taskModel.now_task_id)
  414. print("not DialogueModel:getInstance().dialogue_is_open: ",not DialogueModel:getInstance().dialogue_is_open)
  415. print("not GuideModel:getInstance():IsNeedFinishGuideFirst(): ", not GuideModel:getInstance():IsNeedFinishGuideFirst())
  416. print("tanar: TaskController [395] ====== parms end")
  417. 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
  418. and UserMsgAdapter:getInstance().is_game_connected and not DialogueModel:getInstance().dialogue_is_open and not GuideModel:getInstance():IsNeedFinishGuideFirst() then
  419. --主线在等待升级的时候,不做任务,避免升级前去找开始npc,这个看网络
  420. print("tanar: [TaskController 413]=> cur_task.type: ",cur_task.type)
  421. if cur_task.type==TaskType.MAIN_LINE and TaskModel:getInstance().need_accept then
  422. print("tanar: [TaskController 417]=> TaskModel:getInstance().need_accept: ",TaskModel:getInstance().need_accept)
  423. return
  424. end
  425. if force and cur_task.tipParam and cur_task.tipParam[1] == TaskTipType.TYPE43 then
  426. --主线强制force参数会绕过TaskModel:getInstance()IsAutoDoTask的判断,引起部分界面类任务和引导重叠,这边特殊处理掉
  427. return
  428. end
  429. if cur_task.type == TaskType.TRUN_LINE then
  430. local last_is_main_yield_scene = SceneManager.Instance:IsMainCityorYieldScene(SceneManager.Instance:GetLastSceneId())
  431. local turn_task_needs_auto = self.taskModel:NeedAutoDoTurnTask(cur_task)
  432. -- local rein_task_finished = cur_task.taskTips and cur_task.taskTips[1] and cur_task.taskTips[1].isFinish == 1
  433. if ((self.delay_fly_down_to_do_task and not last_is_main_yield_scene) -- 防止在大世界切大世界场景也弹
  434. or (not self.delay_fly_down_to_do_task)) and not turn_task_needs_auto then -- 不能自动进行的任务需要弹出任务窗口确认
  435. -- and rein_task_finished then -- 转职任务不会自动执行,但切换场景进来的已完成转职任务的情况除外
  436. local turn = ReincarnationModel:getInstance():GetCurTurn()
  437. ReincarnationModel:getInstance():Fire(ReincarnationModel.OPEN_REIN_MAIN_TASK_VIEW, true, turn)
  438. return
  439. end
  440. end
  441. -- 从副本里出来后(失败或者主动退出),自动任务又要重新进这个副本,那就不要再进去了,改到61003控制
  442. self.taskModel:TaskClickFun(cur_task)
  443. end
  444. end
  445. else
  446. self.taskModel.after_scene_start = true
  447. end
  448. end
  449. --清除自动开始任务定时器
  450. function TaskController:ClearAutoDoTaskTimer()
  451. -- print("--------清除自动开始任务定时器-----")
  452. if self.auto_do_timer then
  453. GlobalTimerQuest:CancelQuest(self.auto_do_timer)
  454. self.auto_do_timer = nil
  455. end
  456. end
  457. -----------------协议相关---------------------
  458. function TaskController:request30000()
  459. self:Clear30000Timer()
  460. self:SendFmtToGame(30000,"")
  461. end
  462. function TaskController:handler30000()
  463. self.taskModel.notMain = true --没接有主线任务
  464. local task_type = self:ReadFmt("c")
  465. if task_type == 0 then
  466. self.taskModel._canTaskList={}
  467. self.taskModel._receivedTaskList={}
  468. self.taskModel.all_task_list = {}
  469. else
  470. local list = self.taskModel._canTaskList
  471. for i = #list, 1, -1 do
  472. if list[i].type == task_type then
  473. table.remove(list,i)
  474. end
  475. end
  476. list = self.taskModel._receivedTaskList
  477. for i = #list, 1, -1 do
  478. if list[i].type == task_type then
  479. table.remove(list,i)
  480. end
  481. end
  482. list = self.taskModel.all_task_list
  483. for i = #list, 1, -1 do
  484. if list[i].type == task_type then
  485. table.remove(list,i)
  486. end
  487. end
  488. end
  489. local len = self:ReadFmt("h")
  490. for index = 1, len do
  491. local taskVO=TaskVo.New(true, false)
  492. taskVO.acceptType = 1
  493. if taskVO.level and taskVO.level <= RoleManager.Instance.mainRoleInfo.level then
  494. if not ClientConfig.alpha_mode or taskVO.type~=TaskType.EXTENSION_LINE then
  495. self.taskModel:MakeTaskTip(taskVO)
  496. table_insert(self.taskModel._canTaskList,taskVO)--保存可接任务vo
  497. table_insert(self.taskModel.all_task_list, taskVO)
  498. -------------------------
  499. --非新手流程的时候,有可接取的主线,就不要等了,直接接
  500. if Config.ConfigTaskEffect.GuideLevel < RoleManager.Instance.mainRoleInfo.level then
  501. if taskVO.type == TaskType.MAIN_LINE then
  502. print('Ych:TaskController.lua[552] data', taskVO.id)
  503. --GlobalEventSystem:Fire(TaskEventType.SEND_TASK_ACCEPT, taskVO.id)
  504. if self.main_line_break_wait then
  505. if not self.taskModel.sign_mask_not_guide_wait_accept_main_task then--完成任务导致升级的时候会从重合导致当前自动任务流程停止,用30004的标记处理掉
  506. self.not_guide_wait_accept_main_task = true--非新手流程等主线任务更新,这次更新不要自动进行任务
  507. end
  508. self.auto_accept_main_id = taskVO.id--保存一下自动接的任务id,给30003协议返回用
  509. else
  510. --如果已经不是断层任务了,这个就不用了
  511. self.not_guide_wait_accept_main_task = false
  512. end
  513. end
  514. end
  515. -------------------------
  516. end
  517. end
  518. if taskVO.type == TaskType.MAIN_LINE and ((RoleManager.Instance.mainRoleInfo.level == 0) or (taskVO.level<=RoleManager.Instance.mainRoleInfo.level)) then
  519. --20000比13001还快,这时候人物等级都木有
  520. self.taskModel.notMain=false
  521. end
  522. end
  523. local need_refresh_monster_name
  524. local len4 = self:ReadFmt("h")
  525. for index = 1, len4 do
  526. local taskVO = TaskVo.New(true, true)
  527. if not ClientConfig.alpha_mode or taskVO.type~=TaskType.EXTENSION_LINE then
  528. taskVO.acceptType=0
  529. self.taskModel:MakeTaskTip(taskVO)
  530. table_insert(self.taskModel._receivedTaskList,taskVO)--保存已接任务vo
  531. table_insert(self.taskModel.all_task_list, taskVO)
  532. if taskVO.task_kind == TaskKind.CAI_JI_KIND then --采集任务,刷新采集怪的名字面板,有任务时才显示名字
  533. need_refresh_monster_name = true
  534. self.monster_content_id = taskVO.content_id
  535. end
  536. if taskVO.type == TaskType.MAIN_LINE then
  537. self.taskModel.notMain = false
  538. end
  539. end
  540. end
  541. --可能只发了某个类型的过来。所以要全部判断下
  542. if task_type > 0 then
  543. local list = self.taskModel.all_task_list
  544. for index,taskVO in pairs(list) do
  545. if taskVO.type == TaskType.MAIN_LINE then
  546. if taskVO.acceptType == 1 then
  547. if ((RoleManager.Instance.mainRoleInfo.level == 0) or (taskVO.level <= RoleManager.Instance.mainRoleInfo.level)) then
  548. self.taskModel.notMain = false
  549. break
  550. end
  551. elseif taskVO.acceptType == 0 then
  552. self.taskModel.notMain = false
  553. break
  554. end
  555. end
  556. end
  557. end
  558. self.taskModel.showExtendTip = self.taskModel:NeedShowExtendTip()
  559. --当前任务做完后,马上做下一个主线任务
  560. if RoleManager.Instance.mainRoleInfo.level <= TaskModel.AutoDoNewMainTaskLv then
  561. local task_data = self.taskModel:GetMainUITaskData()
  562. if not self.taskModel.now_task_id and task_data and task_data[1] and task_data[1].mainTip == false then
  563. if task_data[1].id ~= self.taskModel.last_task_id_cache and task_data[1].type==TaskType.MAIN_LINE then --马上继续下一个任务
  564. self.taskModel.now_task_id = task_data[1].id
  565. end
  566. end
  567. end
  568. if self.taskModel.need_do_task_type~=0 then
  569. --马上做赏金或社团任务
  570. local taskVo = self.taskModel:GetTaskByType(self.taskModel.need_do_task_type)
  571. if taskVo then
  572. TaskModel:getInstance():SetTaskAutoFlag(true)
  573. TaskModel:getInstance().now_task_id = taskVo.id
  574. end
  575. self.taskModel.need_do_task_type = 0
  576. else
  577. if self.taskModel.last_task_type_cache then
  578. if self.taskModel.last_task_type_cache==TaskType.BOUNTY_LINE then
  579. --自动做
  580. local taskVo = self.taskModel:GetTaskByType(TaskType.BOUNTY_LINE)
  581. if taskVo then
  582. self.taskModel.now_task_id = taskVo.id
  583. end
  584. --请求进度
  585. DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, TaskType.BOUNTY_LINE)
  586. elseif self.taskModel.last_task_type_cache==TaskType.GUILD_LINE then
  587. if RoleManager.Instance.mainRoleInfo.vip_flag >= Config.ConfigTaskEffect.guildAutoTaskVip then
  588. local taskVo = self.taskModel:GetTaskByType(TaskType.GUILD_LINE)
  589. if taskVo then
  590. self.taskModel.now_task_id = taskVo.id
  591. end
  592. else
  593. --vip不足,停止做任务
  594. GlobalEventSystem:Fire(EventName.FORCE_STOP_DO_TASK)
  595. end
  596. --请求进度
  597. DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, TaskType.GUILD_LINE)
  598. elseif self.taskModel.last_task_type_cache==TaskType.TRUN_LINE then
  599. local taskVo = self.taskModel:GetTaskByType(TaskType.TRUN_LINE)
  600. if taskVo then -- 存在任务时,根据上次完成转职任务的等级判断玩家是否处于卡级阶段,是则不自动进行转职任务
  601. local is_in_turn_task_limit = self.taskModel:IsNewTurnTaskInLimitLv()
  602. self.taskModel.now_task_id = not is_in_turn_task_limit and taskVo.id or false
  603. else
  604. self.taskModel.now_task_id = false
  605. end
  606. -- 2021年7月27日修改 转职任务转阶段不自动进行下一阶段
  607. -- self.taskModel.now_task_id = false
  608. end
  609. end
  610. end
  611. if need_refresh_monster_name then
  612. self.taskModel:RefreshCollectMonsterName(self.monster_content_id)
  613. elseif self.monster_content_id then
  614. local temp_content_id = self.monster_content_id
  615. self.monster_content_id = false
  616. self.taskModel:RefreshCollectMonsterName(temp_content_id)
  617. end
  618. self:HandleTask()
  619. -------------------------
  620. --self:CheckNewMainLineTip()--检查是否需要显示新主线
  621. self:CheckWaitNewMainLineAccept()
  622. -------------------------
  623. end
  624. function TaskController:HandleTask( )
  625. self:ClearAutoDoTaskTimer()
  626. self:Clear30000Timer()
  627. local delay_fun = function()
  628. if self.delay_id then
  629. GlobalTimerQuest:CancelQuest(self.delay_id)
  630. self.delay_id = nil
  631. end
  632. local function func()
  633. local task = self.taskModel:GetTaskById(self.taskModel.now_task_id)
  634. -------------------------
  635. --96级之后不用主动优先主线
  636. local auto_main_line = RoleManager.Instance.mainRoleInfo.level <= TaskModel.AutoDoNewMainTaskLv
  637. -------------------------
  638. if self.taskModel.notMain==true then
  639. self.taskModel:DefaultTask()
  640. if self.taskModel._nextMain then
  641. table_insert(self.taskModel._canTaskList, self.taskModel._nextMain )
  642. table_insert(self.taskModel.all_task_list, self.taskModel._nextMain)
  643. end
  644. end
  645. -- self.taskModel:Fire(TaskEvent.TASK_LIST_INIT)
  646. self:DoTaskNotify()
  647. GlobalEventSystem:Fire(EventName.UPDATE_TASK_STATE)
  648. local curTipType = 0 --当前环的任务类型
  649. local lastTipType = 0 --上一环的任务类型
  650. local task_id = 0
  651. if task then
  652. curTipType = task.tipType
  653. lastTipType = task:GetLastTaskTipsType()
  654. if curTipType == TaskTipType.TYPE59 then
  655. self.taskModel.accept_power_task_id = task.id
  656. end
  657. if lastTipType == TaskTipType.TYPE59 then
  658. --如果满足,则说明,战力任务领取的时候直接满足战力需求,继续做任务
  659. if self.taskModel.accept_power_task_id ~= task.id then
  660. lastTipType = 0
  661. end
  662. end
  663. end
  664. --当前环任务是战力引导任务,不自动做
  665. --上一环任务是战力引导任务,不自动做(但是如果如果领到任务,已经满足战力引导任务,则需要自动做)
  666. local can_do_task = curTipType ~= TaskTipType.TYPE59 and lastTipType ~= TaskTipType.TYPE59
  667. --如果这次次战力提升的任务,要重置 断层做主线的标志
  668. if not can_do_task and task and task.type == TaskType.MAIN_LINE and self.not_guide_wait_accept_main_task then
  669. self.not_guide_wait_accept_main_task = false
  670. end
  671. if self.taskModel.first_receive and can_do_task then
  672. --主线任务从无到有,需要自动做任务
  673. if auto_main_line and self.taskModel.last_notMain and not self.taskModel.notMain then
  674. self.not_guide_wait_accept_main_task = false
  675. self:AutoDoTask(true, true)
  676. return
  677. elseif task and task.type ~= TaskType.LIMIT_LINE
  678. and task.type ~= TaskType.PSIONIC_LINE then
  679. if self.not_guide_wait_accept_main_task then
  680. --非新手流程等主线任务更新,这次更新不要自动进行任务
  681. self.not_guide_wait_accept_main_task = false
  682. return
  683. end
  684. --限时任务不自动做 2020/5/9新增:圣物任务不自动做
  685. -- 这里需要特殊处理转职任务,由于转职任务触发下面的函数会打开界面,因此要自动打开界面的前提必须是任务可完成
  686. -- if task.type ~= TaskType.TRUN_LINE or
  687. -- (task.type == TaskType.TRUN_LINE and task.taskTips and task.taskTips[1] and task.taskTips[1].isFinish == 1) then
  688. -- (task.type == TaskType.TRUN_LINE and self.taskModel:NeedAutoDoTurnTask(task)) then
  689. self:AutoDoTask(true)
  690. -- end
  691. else
  692. self.not_guide_wait_accept_main_task = false
  693. end
  694. end
  695. --登陆不自动任务
  696. self.taskModel.first_receive = true
  697. --记录一下之前是否没有主线,是的话,接取了新的主线之后就要自动做主线
  698. self.taskModel.last_notMain = self.taskModel.notMain
  699. end
  700. func()
  701. end
  702. if not self.taskModel:IsWaitProto() then
  703. self.delay_id = GlobalTimerQuest:AddDelayQuest(delay_fun, 0.2)
  704. end
  705. -- GlobalEventSystem:Fire(EventName.SET_REINCARNATION_ICON)
  706. end
  707. --延时做任务,让流程不那么急,但是接任务和完成任务要取消掉,避免延时出问题
  708. function TaskController:Clear30000Timer()
  709. if self.delay_time_id then
  710. GlobalTimerQuest:CancelQuest(self.delay_time_id)
  711. self.delay_time_id = nil
  712. end
  713. if self.delay_id then
  714. GlobalTimerQuest:CancelQuest(self.delay_id)
  715. self.delay_id = nil
  716. end
  717. if self.break_timer_id then
  718. GlobalTimerQuest:CancelQuest(self.break_timer_id)
  719. self.break_timer_id = nil
  720. end
  721. end
  722. function TaskController:handler30001()
  723. if self.timer_id then
  724. GlobalTimerQuest:CancelQuest(self.timer_id)
  725. self.timer_id = nil
  726. end
  727. if self.event_id then
  728. GlobalEventSystem:UnBind(self.event_id)
  729. self.event_id = nil
  730. end
  731. local a_taskId = self:ReadFmt("i")
  732. local len = self:ReadFmt("h")
  733. local ttable={}
  734. local obj = nil
  735. for index = 1, len do
  736. obj = {
  737. type = self:ReadFmt("h"),
  738. isFinish = self:ReadFmt("h"),
  739. id = self:ReadFmt("i"),
  740. name = self:ReadFmt("s"),
  741. count = self:ReadFmt("i"),
  742. nowCount = self:ReadFmt("i"),
  743. sceneId = self:ReadFmt("i"),
  744. sceneName = self:ReadFmt("c"),
  745. scene_x = self:ReadFmt("h"),
  746. scene_y =self:ReadFmt("h"),
  747. need_find_way = self:ReadFmt("c"),
  748. additionalProperty = self:ReadFmt("s"),
  749. stage = self:ReadFmt("c"),
  750. }
  751. ttable[index] = obj
  752. end
  753. local cur_stage = self:ReadFmt("c")
  754. local target_num = self:ReadFmt("i")
  755. local cur_num = self:ReadFmt("i")
  756. local isComplete=false
  757. local recData=self.taskModel._receivedTaskList
  758. local need_req_task_list = true
  759. for key, var in ipairs(recData) do
  760. local taskVO=var
  761. if taskVO.id == a_taskId then
  762. local type = ttable[1] and ttable[1].type
  763. if type == TaskTipType.TYPE0
  764. or (type == TaskTipType.TYPE1 and (taskVO.type == TaskType.BOUNTY_LINE or taskVO.type == TaskType.GUILD_LINE or taskVO.type == TaskType.MAIN_LINE)) --支线不算完成,让玩家手动点击
  765. or type == TaskTipType.TYPE2
  766. or type == TaskTipType.TYPE9
  767. or type == TaskTipType.TYPE16
  768. or type == TaskTipType.TYPE18 then --杀怪或者采集
  769. isComplete = cur_num==target_num --数量达到就是完成
  770. print('Ych:TaskController.lua[844] data', isComplete)
  771. end
  772. --支线进度引导触发
  773. if taskVO.id == 3150001 and cur_num == target_num then
  774. GlobalEventSystem:Fire(EventName.TEST_HELP_STEP,HelpType.EXTENSION_LINE_TASK_FINISH)
  775. end
  776. --如果是社团的送新任务,则判读是否是都完成了
  777. if taskVO.type == TaskType.GUILD_LINE and not isComplete and type == TaskTipType.TYPE7 then
  778. local is_complete = true
  779. for i,v in ipairs(ttable) do
  780. if v.isFinish == 0 then
  781. is_complete = false
  782. break
  783. end
  784. end
  785. isComplete = is_complete
  786. print('Ych:TaskController.lua[861] data', isComplete)
  787. end
  788. --未完成的话就别请求新的任务列表
  789. if not isComplete then
  790. need_req_task_list = false
  791. end
  792. taskVO.taskTips=ttable
  793. taskVO.cur_num = cur_num
  794. taskVO.target_num = target_num
  795. taskVO.cur_stage = cur_stage
  796. -- self.taskModel:Fire(TaskEvent.TASK_LIST_INIT, false)
  797. -- self.taskModel:Fire(TaskEvent.REFRESH_TASK_DATA, taskVO.id)
  798. for i,v in ipairs(ttable) do
  799. if v.type == TaskTipType.TYPE9 then --要结束采集,(以结束对话来结束)
  800. GlobalEventSystem:Fire(EventName.CANCEL_NEXT_COLLECT)
  801. end
  802. end
  803. --处理副本任务偶然的bug
  804. if need_req_task_list and TaskModel:getInstance().need_task then
  805. self:request30000()
  806. need_req_task_list = false
  807. end
  808. print('Ych:TaskController.lua[888] data', isComplete)
  809. if isComplete==true then
  810. --重置状态
  811. self.taskModel:ResetFlag()
  812. if need_req_task_list and not TaskModel:getInstance().need_task then
  813. self:request30000()
  814. need_req_task_list = false
  815. end
  816. if taskVO.type == TaskType.BOUNTY_LINE then
  817. GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, TaskType.BOUNTY_LINE)
  818. elseif taskVO.type == TaskType.GUILD_LINE then
  819. print('Ych:TaskController.lua[887] data', cur_num, target_num, cur_stage)
  820. PrintTable(taskVO)
  821. if not ((type == TaskTipType.TYPE18 or type == TaskTipType.TYPE16) and cur_num == 0) then
  822. GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, TaskType.GUILD_LINE)
  823. end
  824. end
  825. local is_turn_task_and_need_auto = false
  826. -- 更新的是转职任务,则弹出任务窗口
  827. if taskVO.type == TaskType.TRUN_LINE then
  828. is_turn_task_and_need_auto = self.taskModel:NeedAutoDoTurnTask(taskVO)
  829. -- if SceneManager.Instance:IsMainCityorYieldScene() and not is_turn_task_and_need_auto then -- 转职界面涉及到副本,副本内不要弹出界面
  830. -- local turn = ReincarnationModel:getInstance():GetCurTurn()
  831. -- ReincarnationModel:getInstance():Fire(ReincarnationModel.OPEN_REIN_MAIN_TASK_VIEW, true, turn)
  832. -- end
  833. end
  834. --自动寻路
  835. local _play_action = function()
  836. if taskVO.type ~= TaskType.LIMIT_LINE -- 限时任务不自动做
  837. and (taskVO.type ~= TaskType.TRUN_LINE or taskVO.type == TaskType.TRUN_LINE and is_turn_task_and_need_auto -- 非需自动的转职任务不自动做
  838. ) then
  839. GlobalEventSystem:Fire(SceneEventType.SHOW_TASK, tonumber(taskVO.tipParam[3]))
  840. end
  841. if self.timer_id then
  842. GlobalTimerQuest:CancelQuest(self.timer_id)
  843. self.timer_id = nil
  844. end
  845. end
  846. if isComplete == true and taskVO.need_find_way == 1 and taskVO.tipParam[2] and taskVO.tipParam[3] then
  847. elseif taskVO.tipParam[1] and (taskVO.tipParam[1] == TaskTipType.TYPE7 or taskVO.tipParam[1] == TaskTipType.TYPE8
  848. or taskVO.tipParam[1] == TaskTipType.TYPE9) then --不需要寻路完成的对话任务
  849. if SceneManager:getInstance():IsSceneStart() then
  850. local delay_call = function ()
  851. _play_action()
  852. end
  853. if not self.timer_id then
  854. self.timer_id = GlobalTimerQuest:AddDelayQuest(delay_call, 0.1)
  855. end
  856. else
  857. local function complete_fun()
  858. _play_action()
  859. if self.event_id then
  860. GlobalEventSystem:UnBind(self.event_id)
  861. self.event_id = nil
  862. end
  863. end
  864. if not self.event_id then
  865. self.event_id = GlobalEventSystem:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, complete_fun)
  866. end
  867. end
  868. end
  869. end
  870. end
  871. end
  872. self:DoTaskNotify()
  873. end
  874. function TaskController:DoTaskNotify( )
  875. --分时刷新
  876. local function callback()
  877. self.taskModel:Fire(TaskEvent.TASK_LIST_INIT)
  878. end
  879. local is_limit = false
  880. if RoleManager.Instance.mainRoleInfo.level > 70 then
  881. is_limit = true
  882. end
  883. if is_limit then
  884. TimeManager.GetInstance():StartTime("TaskController_UpdateTaskProgress", 0.6, callback)
  885. else
  886. callback()
  887. end
  888. end
  889. function TaskController:request30005(id)
  890. self:SendFmtToGame(30005,"i", id)
  891. end
  892. function TaskController:handler30005()
  893. local code = self:ReadFmt("i")
  894. if code > 0 then
  895. self:request30000()
  896. end
  897. end
  898. function TaskController:handler30017( )
  899. local len = UserMsgAdapter.ReadFmt("h")
  900. local temp_list = {}
  901. for i=1,len do
  902. local id = UserMsgAdapter.ReadFmt("i")
  903. temp_list[id] = id
  904. end
  905. self.taskModel:SetFinishTaskList(temp_list)
  906. if ServerTimeController.Instance and ServerTimeController.Instance.open_init_eveny_can_fire then--是否可以发送任务完成列表协议
  907. ServerTimeController.Instance.open_init_eveny_can_fire = false
  908. GlobalEventSystem:Fire(EventName.OPEN_DAY_INIT)
  909. end
  910. BaseDungeonModel:getInstance():Fire(BaseDungeonModel.ON_FINISHED_TASK_DATA_RECEIVED)
  911. end
  912. function TaskController:request30018(id)
  913. self:SendFmtToGame(30018,"i", id)
  914. end
  915. function TaskController:handler30018( )
  916. local code = self:ReadFmt("i")
  917. if code == 3000008 then
  918. -- if self.taskModel.opening_circle_buy_tip then
  919. -- self.taskModel.wait_circle_buy_tip_close = true
  920. -- end
  921. self:request30000()
  922. else
  923. ErrorCodeShow(code)
  924. end
  925. end
  926. function TaskController:handler30019( )
  927. local code = self:ReadFmt("i")
  928. local task_type = self:ReadFmt("c")
  929. local reward_progress = self:ReadFmt("c")
  930. if code == 1 then
  931. local info = DeepCopy(TaskModel:getInstance():GetCircleTaskInfo(task_type))
  932. if info then
  933. info.reward_progress = reward_progress
  934. self.taskModel:SetCircleTaskInfo( info )
  935. --改需求了,直接关界面
  936. -- GlobalEventSystem:Fire(EventName.REFRESH_TASK_CIRCLE_TIPS)
  937. -- self:DoTaskNotify()
  938. else
  939. DialogueModel:getInstance():Fire(DialogueModel.REQUEST_CCMD_EVENT, 30010, task_type)
  940. end
  941. GlobalEventSystem:Fire(EventName.CLOSE_TASK_CIRCLE_TIPS)
  942. else
  943. ErrorCodeShow(code)
  944. end
  945. end
  946. --任务寻路
  947. --2020年2月19日调整修改--force_use_shoe:点击任务栏飞鞋按钮时强制使用飞鞋
  948. function TaskController:findElement(param, use_shoe, force_use_shoe)
  949. local use_shoe = false
  950. local level = RoleManager.Instance.mainRoleInfo.level
  951. if level >= Config.ConfigTaskEffect.GuideLevel then
  952. if VipModel:getInstance():CanFreeUseShoe() then
  953. use_shoe = true
  954. else
  955. local is_auto_use_shoe = lua_settingM:GetAutoFlyShoeSet()
  956. if force_use_shoe or is_auto_use_shoe then
  957. local num = GoodsModel:getInstance():GetTypeGoodsNum(AutoFightManager.FlyGoodsID)
  958. use_shoe = num > 0
  959. end
  960. end
  961. end
  962. if self.can_move_timer_id then
  963. TimerQuest.CancelQuest(GlobalTimerQuest, self.can_move_timer_id)
  964. self.can_move_timer_id = false
  965. end
  966. if self.fly_timer_id then
  967. TimerQuest.CancelQuest(GlobalTimerQuest, self.fly_timer_id)
  968. self.fly_timer_id = false
  969. end
  970. local array=Split(param,",")
  971. if Config.ConfigTaskEffect.NeedClickTaskType[tonumber(array[1])] then
  972. --点击判断是否已经完成任务,是的话发协议完成任务
  973. local task = TaskModel:getInstance():GetTaskById(tonumber(array[4]))
  974. if self.taskModel:IsNeedClickTask(task) then
  975. local tip = self.taskModel:GetExtendSpecialTip(task)
  976. if tip and tip.isFinish==1 then
  977. GlobalEventSystem:Fire(TaskEventType.SEND_TASK_FINISH, task.id)
  978. return
  979. end
  980. end
  981. end
  982. -- if array and #array > 0 and self.taskModel:NeedFindWayTask(tonumber(array[1])) then
  983. -- local main_role = Scene.Instance:GetMainRole()
  984. -- if main_role and main_role:CanMove() then
  985. -- print("Saber:TaskController [start:814] ------------------------------------------")
  986. -- else
  987. -- local timer_func = function ()
  988. -- local main_role = Scene.Instance:GetMainRole()
  989. -- if main_role and main_role:CanMove() then
  990. -- if self.can_move_timer_id then
  991. -- TimerQuest.CancelQuest(GlobalTimerQuest, self.can_move_timer_id)
  992. -- self.can_move_timer_id = false
  993. -- end
  994. -- self:findElement(param,use_shoe)
  995. -- local task = self.taskModel:GetTaskById(tonumber(array[4]))
  996. -- if self.taskModel:IsAutoDoTask(task) then
  997. -- GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT,false,true)
  998. -- end
  999. -- return
  1000. -- end
  1001. -- end
  1002. -- self.can_move_timer_id = TimerQuest.AddPeriodQuest(GlobalTimerQuest, timer_func, 0.01, -1)
  1003. -- return
  1004. -- end
  1005. -- end
  1006. if Scene.Instance:HasDropPick() and AutoFightManager:getInstance():GetAutoFightState()
  1007. and not use_shoe then
  1008. Scene.Instance.need_task_after_pick = true
  1009. return
  1010. end
  1011. local params={}
  1012. if #array>0 then
  1013. self.taskModel.need_check_monster = false
  1014. local findVo = FindVo.New()
  1015. findVo.type = -1
  1016. local type=tonumber(array[1])
  1017. findVo.sceneId = tonumber(array[2])
  1018. local sceneId=tonumber(array[2])
  1019. local npcId=0
  1020. 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
  1021. if tonumber(array[3]) == 0 then --自言自语
  1022. GlobalEventSystem:Fire(SceneEventType.SHOW_TASK, tonumber(array[3]))
  1023. return
  1024. else
  1025. findVo.type = FindVo.NPC
  1026. findVo.id = tonumber(array[3])
  1027. local scene_info = SceneManager.Instance:GetSceneInfo(findVo.sceneId)
  1028. print("---------find npc-------:", findVo.id, findVo.sceneId, scene_info)
  1029. if scene_info == nil then
  1030. print("tanar: TaskController [949] npc scene_info is nil")
  1031. return
  1032. end
  1033. --用小飞鞋,查找数据库获得npc坐标, 如果不需要用则不查数据库
  1034. if use_shoe or findVo.sceneId ~= SceneManager.Instance:GetSceneId() then
  1035. local item = ConfigItemMgr.Instance:GetSceneItem(findVo.sceneId)
  1036. if item and item.Npcs then
  1037. local npc = item.Npcs[findVo.id]
  1038. if npc then
  1039. findVo.x = npc.x/ SceneObj.LogicRealRatio.x
  1040. findVo.y = npc.y/ SceneObj.LogicRealRatio.y
  1041. end
  1042. end
  1043. else
  1044. local npc = SceneManager.Instance:GetNpcVo(findVo.id) --npc寻路,只有npc和主角在同一场景才有位置值
  1045. print("---------npc-is nil ?------:", npc)
  1046. if npc then
  1047. findVo.x = npc.logic_x
  1048. findVo.y = npc.logic_y
  1049. else
  1050. print("找不到npc", findVo.id)
  1051. end
  1052. end
  1053. end
  1054. elseif type == TaskTipType.TYPE1 or type == TaskTipType.TYPE18 then --怪物/采集/收集任务
  1055. findVo.type = FindVo.MONSTER
  1056. findVo.id = tonumber(array[3])
  1057. local task_id = tonumber(array[4])
  1058. findVo.need_check_monster = true
  1059. if #array == 6 or #array == 7 then
  1060. findVo.x=tonumber(array[5]) / SceneObj.LogicRealRatio.x
  1061. findVo.y=tonumber(array[6]) / SceneObj.LogicRealRatio.y
  1062. end
  1063. if TaskModel:getInstance().now_task_id then
  1064. --(注意,一般采集任务不会进这里,因为采集物没有配置random_pos,会走到FindVo.MONSTER)
  1065. local random_logic_pos, random_real_pos, ignore_rush = TaskModel:getInstance():GetTaskMonsterRandomPos(findVo.id, sceneId)
  1066. if random_logic_pos then --随机一堆怪物,解决玩家分流问题
  1067. --没有飞鞋的时候,打怪任务要走冲刺逻辑
  1068. if not ignore_rush and not use_shoe and type == TaskTipType.TYPE1 then
  1069. local monster = Scene.Instance:FindNearestMonster(findVo.id, false, false)
  1070. if monster then
  1071. Scene.Instance:MainRoleAttackMonster(monster)
  1072. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
  1073. return
  1074. else
  1075. if findVo.sceneId == SceneManager.Instance:GetSceneId() then
  1076. GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT)
  1077. Scene.Instance:MainRoleRushToPos(random_real_pos)
  1078. return
  1079. end
  1080. end
  1081. end
  1082. local function point_call_back( )
  1083. self.taskModel.task_cache_pos = nil
  1084. --打怪任务
  1085. if type == TaskTipType.TYPE1 then
  1086. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
  1087. --采集任务
  1088. elseif type == TaskTipType.TYPE18 then
  1089. self.try_collect_left_num = 6--采集物未创建的话,每隔一段时间尝试一下,6次就够了
  1090. local try_to_collect = nil--必须这么写
  1091. try_to_collect = function ( )
  1092. local monster = Scene.Instance:FindNearestMonster(findVo.id, false, true)
  1093. if monster then
  1094. local main_role = Scene.Instance.main_role
  1095. if main_role then
  1096. if self.task_collect_start_real_pos == nil then
  1097. self.task_collect_start_real_pos = co.TableXY(main_role:GetRealPos())
  1098. else
  1099. self.task_collect_start_real_pos.x = main_role.real_pos.x
  1100. self.task_collect_start_real_pos.y = main_role.real_pos.y
  1101. end
  1102. if self.task_collect_end_real_pos == nil then
  1103. self.task_collect_end_real_pos = co.TableXY(monster:GetRealPos())
  1104. else
  1105. self.task_collect_end_real_pos.x = monster.real_pos.x
  1106. self.task_collect_end_real_pos.y = monster.real_pos.y
  1107. end
  1108. main_role:SetDirection(self.task_collect_start_real_pos, self.task_collect_end_real_pos, true , true)
  1109. end
  1110. EventSystem.Fire(GlobalEventSystem,EventName.OPEN_COLLECT_VIEW, monster.id, monster:GetVo().type_id, monster:GetVo().pick_time)
  1111. else
  1112. self.try_collect_left_num = self.try_collect_left_num - 1
  1113. --此时采集物可能还未创建,所以延迟一段时间再尝试
  1114. if not self.delay_collect_id and self.try_collect_left_num >= 0 then
  1115. self.delay_collect_id = GlobalTimerQuest:AddPeriodQuest(try_to_collect, 0.5, 1)
  1116. end
  1117. end
  1118. end
  1119. try_to_collect()
  1120. end
  1121. end
  1122. findVo.find_range = 0
  1123. -- findVo.find_range = 1
  1124. -- if type == TaskTipType.TYPE1 then
  1125. -- findVo.find_range = 3
  1126. -- end
  1127. findVo.x = random_logic_pos.x
  1128. findVo.y = random_logic_pos.y
  1129. findVo.type = FindVo.POINT
  1130. findVo.call_back = point_call_back
  1131. end
  1132. end
  1133. elseif type == TaskTipType.TYPE6 then --收集任务配置的是物品id,直接打怪就行了
  1134. local function call_back( )
  1135. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
  1136. end
  1137. findVo.type = FindVo.POINT
  1138. local task_id = tonumber(array[4])
  1139. if task_id and Config.ConfigWorldMon.CollectTask[task_id] then
  1140. local collect_task_id = self.taskModel:GetCollectTaskId()
  1141. if collect_task_id and collect_task_id == task_id then
  1142. findVo.x = self.collect_task_pos.x
  1143. findVo.y = self.collect_task_pos.y
  1144. self.taskModel:ClearCollectTaskId()
  1145. else
  1146. local data = Config.ConfigWorldMon.CollectTask[task_id]
  1147. local index = math.random(1,#data.way_point)
  1148. local pos = data.way_point[index]
  1149. findVo.x = pos.x / SceneObj.LogicRealRatio.x
  1150. findVo.y = pos.y / SceneObj.LogicRealRatio.y
  1151. self.taskModel:SetCollectTaskId(task_id)
  1152. self.collect_task_pos = {x = findVo.x,y = findVo.y}
  1153. end
  1154. else
  1155. findVo.x=tonumber(array[5]) / SceneObj.LogicRealRatio.x
  1156. findVo.y=tonumber(array[6]) / SceneObj.LogicRealRatio.y
  1157. end
  1158. findVo.call_back = call_back
  1159. elseif type == TaskTipType.TYPE16 then --探索场景
  1160. findVo.type = FindVo.Explore
  1161. findVo.sceneId = tonumber(sceneId)
  1162. local x = tonumber(array[3])
  1163. local y = tonumber(array[4])
  1164. findVo.x = x / SceneObj.LogicRealRatio.x
  1165. findVo.y = y / SceneObj.LogicRealRatio.y
  1166. findVo.time = tonumber(array[5])
  1167. findVo.call_back = function ()
  1168. GlobalEventSystem:Fire(TaskEventType.TASK_QUEST)
  1169. end
  1170. elseif type == TaskTipType.TYPE2 or type == TaskTipType.TYPE37 or type == TaskTipType.TYPE29 then --通关副本
  1171. local task_id = tonumber(array[4])
  1172. if task_id and task_id == BossModel.FAKE_MONEY_BOSS_TASK_ID then
  1173. GlobalEventSystem:Fire(EventName.OPEN_BOSS_VIEW,Config.ConfigBoss.ModuleId.Money)
  1174. return
  1175. end
  1176. local config = Config.Dungeoncfg[tonumber(array[3])]
  1177. if config and config.type == BaseDungeonModel.DUN_TYPE.PersonBoss then
  1178. --专属幻魔
  1179. local boss_id = false
  1180. for k,v in pairs(Config.Personalbossinfo) do
  1181. if v.dun_id == tonumber(array[3]) then
  1182. boss_id = v.boss_id
  1183. end
  1184. end
  1185. GlobalEventSystem:Fire(EventName.OPEN_BOSS_VIEW,Config.ConfigBoss.ModuleId.Person,boss_id)
  1186. return
  1187. end
  1188. local task = TaskModel:getInstance():GetTaskById(task_id)
  1189. if task then
  1190. local open_ui_task = Config.ConfigTaskEffect.OpenUITask[task_id]
  1191. if task.type == TaskType.EXTENSION_LINE or open_ui_task then
  1192. --支线特殊处理
  1193. local is_open_view = tonumber(array[2])==0
  1194. if is_open_view or open_ui_task then
  1195. --打开副本界面 根据副本id
  1196. local cfg = Config.Dungeoncfg[tonumber(array[3])]
  1197. if cfg then
  1198. if tonumber(cfg.type) == BaseDungeonModel.DUN_TYPE.PersonBoss then
  1199. OpenFun.Open(460,1)
  1200. else
  1201. local dungeon_type = tonumber(cfg.type)
  1202. if BaseDungeonModel.DungeonSingleType[dungeon_type] then
  1203. if dungeon_type == BaseDungeonModel.DUN_TYPE.MATERIAL then
  1204. local open_key = cfg.id - 900 --没有字段区分是哪一个进阶副本,先写死id
  1205. if open_key and open_key >= 101 and open_key <= 108 then
  1206. OpenFun.Open(610, open_key)
  1207. else
  1208. OpenFun.Open(610, dungeon_type)
  1209. end
  1210. else
  1211. OpenFun.Open(610, dungeon_type)
  1212. end
  1213. else
  1214. OpenFun.Open(215, BaseDungeonModel.DungeonTeamType[dungeon_type])
  1215. end
  1216. end
  1217. return
  1218. end
  1219. else
  1220. --直接进入副本
  1221. setTimeout(
  1222. function()
  1223. local config = Config.Dungeoncfg[tonumber(array[3])]
  1224. if config and config.enter_type == 1 then
  1225. local main_role = Scene.Instance.main_role
  1226. if main_role then
  1227. local enter_dir_angle = main_role:GetDirectionAngle()
  1228. RoleManager:getInstance():SetEnterDirAngle(enter_dir_angle)
  1229. end
  1230. end
  1231. BaseDungeonModel:getInstance():Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61001, tonumber(array[3])) end,0.3)
  1232. return
  1233. end
  1234. else
  1235. local dun_id = tonumber(array[3])
  1236. local time = 0.3
  1237. if dun_id == GuideModel.CHANGE_GOD_SCENE_ID then
  1238. time = 1
  1239. end
  1240. local function on_delay_enter_dungeon()
  1241. local config = Config.Dungeoncfg[tonumber(array[3])]
  1242. if config and config.enter_type == 1 then
  1243. local main_role = Scene.Instance.main_role
  1244. if main_role then
  1245. local enter_dir_angle = main_role:GetDirectionAngle()
  1246. RoleManager:getInstance():SetEnterDirAngle(enter_dir_angle)
  1247. end
  1248. end
  1249. BaseDungeonModel:getInstance():Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61001, dun_id)
  1250. end
  1251. --主线任务无缝加载,距离太远的话要校正一下坐标,先走到策划配置的点再进入副本
  1252. local temp_limit_cfg = Config.ConfigChangeSceneEffect.DungeonLimit[dun_id]
  1253. local need_reset_pos = false
  1254. if temp_limit_cfg then
  1255. local target_pos = temp_limit_cfg.enter_pos
  1256. local cur_scene_id = SceneManager:getInstance():GetSceneId()
  1257. local dun_scene_id = Config.Dungeoncfg[dun_id].scene_id
  1258. if dun_scene_id == cur_scene_id then
  1259. --已经在副本场景里了,则自动战斗
  1260. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT,false,true)
  1261. return
  1262. else
  1263. --走小飞鞋寻路
  1264. findVo.type = FindVo.POINT
  1265. findVo.dunSceneId = dun_scene_id
  1266. findVo.sceneId = tonumber(temp_limit_cfg.enter_scene_id)
  1267. local x = tonumber(target_pos.x)
  1268. local y = tonumber(target_pos.y)
  1269. findVo.x = x / SceneObj.LogicRealRatio.x
  1270. findVo.y = y / SceneObj.LogicRealRatio.y
  1271. local range = temp_limit_cfg.work_min_distance/100
  1272. range = range > 1 and range or 0
  1273. findVo.range = range
  1274. findVo.call_back = on_delay_enter_dungeon
  1275. end
  1276. else
  1277. --正常情况是这里进入副本
  1278. setTimeout(on_delay_enter_dungeon, time)
  1279. --自动做的任务, 打完回来要继续
  1280. TaskModel:getInstance():SetNeedTaskFlag(true)
  1281. return
  1282. end
  1283. end
  1284. end
  1285. -- elseif type == TaskTipType.TYPE25 then --五转 点亮星格
  1286. -- GlobalEventSystem:Fire(EventName.OPEN_REINCARNATION_VIEW)
  1287. -- return
  1288. elseif type == TaskTipType.TYPE51 then --解锁地狱摩托
  1289. OpenFun.Open(114, 0)
  1290. return
  1291. elseif type == TaskTipType.TYPE100 then --击杀BOSS
  1292. GlobalEventSystem:Fire(EventName.OPEN_BOSS_VIEW, tonumber(array[3]))
  1293. return
  1294. elseif type == TaskTipType.TYPE101 then --强化装备
  1295. OpenFun.Open(152, 1)
  1296. return
  1297. elseif type == TaskTipType.TYPE102 then --完成某类型副本
  1298. if tonumber(array[3]) == BaseDungeonModel.DUN_TYPE.PersonBoss then
  1299. OpenFun.Open(460,1)
  1300. elseif BaseDungeonModel.DungeonTeamType[tonumber(array[3])] then
  1301. DunManyModel:getInstance():Fire(DunManyModel.OPEN_DUN_MANY_HALL_VIEW,tonumber(array[3]))
  1302. else
  1303. BaseDungeonModel:GetInstance():Fire(BaseDungeonModel.OPEN_HALL_VIEW,tonumber(array[3]))
  1304. end
  1305. return
  1306. elseif type == TaskTipType.TYPE103 then --单次副本获得x经验
  1307. BaseDungeonModel:getInstance():OpenViewByDunType(tonumber(array[3]))
  1308. return
  1309. elseif type == TaskTipType.TYPE104 then --添加好友
  1310. GlobalEventSystem:Fire(EventName.OPEN_SOCIALITY_VIEW)
  1311. setTimeout(function ()
  1312. GlobalEventSystem:Fire(EventName.OPEN_SOCIALITY_VIEW, 2)
  1313. end,0.15)
  1314. return
  1315. elseif type == TaskTipType.TYPE105 then --加入社团
  1316. OpenFun.Open(400, 0)
  1317. -- GlobalEventSystem:Fire(EventName.OPEN_GUILD_APPLY_VIEW)
  1318. return
  1319. elseif type == TaskTipType.TYPE106 then --社团装备回收
  1320. if RoleManager.Instance.mainRoleInfo.level >= Config.ConfigOpenLv.EquipSwallow then
  1321. GlobalEventSystem:Fire(EventName.OPEN_PET_SWALLOW_VIEW)
  1322. else
  1323. Message.show("熔炼功能" .. Config.ConfigOpenLv.EquipSwallow .."级开启哦")
  1324. end
  1325. return
  1326. elseif type == TaskTipType.TYPE107 then --完成社团活动
  1327. if RoleManager.Instance.mainRoleInfo.guild_id>0 then
  1328. local contentId = tonumber(array[3])
  1329. OpenFun.Open(402, contentId)
  1330. else
  1331. Message.show("请先加入一个社团")
  1332. end
  1333. return
  1334. elseif type == TaskTipType.TYPE108 then --捐献一件装备到社团仓库
  1335. -- if RoleManager.Instance.mainRoleInfo.guild_id>0 then
  1336. -- if GuildModel:getInstance():GetGuildBuildLvInfo(GuildModel.GUILD_DEPOT) == 0 then
  1337. -- Message.show("暂时未开启此建筑")
  1338. -- else
  1339. -- GlobalEventSystem:Fire(EventName.OPEN_GUILD_MAIN_VIEW, 3)
  1340. -- end
  1341. -- else
  1342. -- Message.show("请先加入一个社团")
  1343. -- end
  1344. return
  1345. elseif type == TaskTipType.TYPE109 then --在市场上购买1个商品
  1346. GlobalEventSystem:Fire(EventName.OPEN_MARKET_VIEW, 1)
  1347. return
  1348. elseif type == TaskTipType.TYPE110 then --在市场上架1个物品
  1349. GlobalEventSystem:Fire(EventName.OPEN_MARKET_VIEW, 3)
  1350. return
  1351. elseif type == TaskTipType.TYPE23 then --合成物品
  1352. --合成按钮跳转
  1353. local type_id = tonumber(array[3])
  1354. ComposeModel.Instance:TryComposeJump(type_id)
  1355. return
  1356. elseif type == TaskTipType.TYPE24 then --活跃度
  1357. GlobalEventSystem:Fire(ActivityIconManager.SHOW_LEAD_EFFECT,157)
  1358. return
  1359. elseif type == TaskTipType.TYPE26 then --吞噬
  1360. if RoleManager.Instance.mainRoleInfo.level >= Config.ConfigOpenLv.EquipSwallow then
  1361. GlobalEventSystem:Fire(EventName.OPEN_PET_SWALLOW_VIEW)
  1362. else
  1363. Message.show("熔炼功能" .. Config.ConfigOpenLv.EquipSwallow .."级开启哦")
  1364. end
  1365. return
  1366. elseif type == TaskTipType.TYPE27 then --击杀首领
  1367. local kill_type = tonumber(array[2])
  1368. local monster_id = tonumber(array[3])
  1369. if monster_id and kill_type then
  1370. local boss_type = TaskModel.TYPE27_KILL_TYPE[kill_type]
  1371. GlobalEventSystem:Fire(EventName.OPEN_BOSS_VIEW, boss_type, monster_id)
  1372. end
  1373. return
  1374. elseif type == TaskTipType.TYPE28 then --钓鱼之路
  1375. GlobalEventSystem:Fire(EventName.OPEN_SKILL_VIEW,4,1,true)
  1376. return
  1377. elseif type == TaskTipType.TYPE111 then --击杀首领
  1378. local dun_id = tonumber(array[3])
  1379. if dun_id then
  1380. local config = Config.Dungeoncfg[dun_id]
  1381. if config then
  1382. if config.type == 20 then --"宝石副本"
  1383. OpenFun.Open(610,37)
  1384. elseif config.type == 21 then -- "神格副本"
  1385. OpenFun.Open(610,23)
  1386. elseif config.type == 5 then -- "装备副本"
  1387. OpenFun.Open(610,32)
  1388. end
  1389. end
  1390. end
  1391. return
  1392. elseif type == TaskTipType.TYPE36 then --装备附能
  1393. OpenFun.Open(152,5)
  1394. return
  1395. elseif type == TaskTipType.TYPE39 then --装备升星
  1396. OpenFun.Open(152,2)
  1397. return
  1398. elseif type == TaskTipType.TYPE31 then --竞技场次数
  1399. OpenFun.Open(280,0)
  1400. return
  1401. elseif type == TaskTipType.TYPE40 then --商城购买
  1402. local shop_key_id = tonumber(array[2])
  1403. local temp_cfg = Config.Shop[shop_key_id]
  1404. local show_open_effect = true--针对一些特别的显示特效不显示tip
  1405. if show_open_effect then
  1406. GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, temp_cfg.shop_type, temp_cfg.sub_type, temp_cfg.goods_id, nil,true)
  1407. else
  1408. GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, temp_cfg.shop_type, temp_cfg.sub_type, temp_cfg.goods_id, true)
  1409. end
  1410. return
  1411. elseif type == TaskTipType.TYPE34 then --进入某类副本
  1412. local dungeon_type = tonumber(array[3])
  1413. if BaseDungeonModel.DungeonSingleType[dungeon_type] then
  1414. OpenFun.Open(610, dungeon_type)
  1415. else
  1416. OpenFun.Open(215, BaseDungeonModel.DungeonTeamType[dungeon_type])
  1417. end
  1418. return
  1419. elseif type == TaskTipType.TYPE41 or type == TaskTipType.TYPE42 then --好友送礼/好友亲密度
  1420. OpenFun.Open(140, 1)
  1421. return
  1422. elseif type == TaskTipType.TYPE43 then --进阶系统升级
  1423. OpenFun.Open(146,tonumber(array[3]))
  1424. return
  1425. elseif type == TaskTipType.TYPE56 then --进阶目标(进阶到一定阶数)
  1426. OpenFun.Open(146,tonumber(array[3]))
  1427. return
  1428. elseif type == TaskTipType.TYPE44 then --升品之路
  1429. OpenFun.Open(414, 0)
  1430. return
  1431. elseif type == TaskTipType.TYPE45 then --唤神升级
  1432. OpenFun.Open(173, 1)
  1433. return
  1434. elseif type == TaskTipType.TYPE46 then --星辰升级
  1435. OpenFun.Open(148,1)
  1436. return
  1437. elseif type == TaskTipType.TYPE47 then --宠物升级
  1438. OpenFun.Open(163,1)
  1439. return
  1440. elseif type == TaskTipType.TYPE48 then --晒娃
  1441. OpenFun.Open(165,1)
  1442. return
  1443. elseif type == TaskTipType.TYPE49 then --装备圣物
  1444. OpenFun.Open(139,2)
  1445. return
  1446. elseif type == TaskTipType.TYPE50 then --圣物寻宝
  1447. OpenFun.Open(139,7)
  1448. return
  1449. elseif type == TaskTipType.TYPE52 then --转职目标
  1450. GlobalEventSystem:Fire(EventName.OPEN_NEW_MAIN_ROLE_VIEW, NewMainRoleModel.TabId.REIN)
  1451. return
  1452. elseif type == TaskTipType.TYPE53 then --龙神抽奖
  1453. OpenFun.Open(170,1)
  1454. return
  1455. elseif type == TaskTipType.TYPE54 then --装备套装
  1456. local dai_num = tonumber(array[3])
  1457. local color = tonumber(array[2])
  1458. EquipCollectModel:getInstance():Fire(EquipCollectConst.OPEN_EC_MAIN_VIEW,true, EquipCollectConst.TAB_ID.COLLECT, dai_num, color, color)
  1459. return
  1460. elseif type == TaskTipType.TYPE55 then --战魂强化
  1461. OpenFun.Open(143,5)
  1462. return
  1463. elseif type == TaskTipType.TYPE57 then --完成预期任务
  1464. self:AutoDoTask(true, true)--直接做主线
  1465. return
  1466. elseif type == TaskTipType.TYPE58 then --宝宝同心值
  1467. OpenFun.Open(165,0)
  1468. return
  1469. elseif type == TaskTipType.TYPE59 then --战力
  1470. --这里不做任何处理,放到item点击处
  1471. return
  1472. elseif type == TaskTipType.TYPE60 then --任意主动技能升级次数
  1473. OpenFun.Open(210,1)
  1474. return
  1475. elseif type == TaskTipType.TYPE61 then --指定商店购买技能书
  1476. local temp_cfg = Config.Shop[10317] --指定第一本技能书的商店配置
  1477. local career = RoleManager.Instance.mainRoleInfo.career
  1478. local goods_table =
  1479. {
  1480. [1] = 210101,
  1481. [2] = 210201,
  1482. [3] = 210301,
  1483. [4] = 210401,
  1484. }
  1485. GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, temp_cfg.shop_type, temp_cfg.sub_type, goods_table[career], nil, true)
  1486. return
  1487. elseif type == TaskTipType.TYPE62 then --任意商店技能书购买
  1488. GlobalEventSystem:Fire(EventName.SHOW_MAIN_GET_SKILL_TASK_TIPS_VIEW, true)
  1489. return
  1490. end
  1491. --跨服主城场景id校正
  1492. if findVo.sceneId and (findVo.sceneId == KfWorldConst.BFCitySceneId or findVo.sceneId == KfWorldConst.KFCitySceneId) then
  1493. if KfWorldModel:GetInstance():IsKFCityOpen() then
  1494. findVo.sceneId = KfWorldConst.KFCitySceneId
  1495. else
  1496. findVo.sceneId = KfWorldConst.BFCitySceneId
  1497. end
  1498. end
  1499. local function on_find_vo_func()
  1500. Scene.Instance:ResetUserManulState() --到了执行寻路回调这里,就可以重置寻路缓存状态了
  1501. local cur_scene_id = SceneManager.Instance:GetSceneId()
  1502. if findVo.dunSceneId and findVo.dunSceneId == cur_scene_id then
  1503. --进入镜像副本之后,就不要再切场景了
  1504. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT,false,true)
  1505. elseif (findVo.sceneId == cur_scene_id) or SceneManager:getInstance():IsMappingToSameScene(cur_scene_id, findVo.sceneId) then
  1506. --已经是目标场景了,开始寻路,这里要兼容一下主城跟跨服主城
  1507. GlobalEventSystem:Fire(EventName.FIND, findVo)
  1508. else
  1509. --如果不在同场景, 先切场景
  1510. TaskModel:getInstance():SetNeedTaskFlag(true)
  1511. GlobalEventSystem:Fire(SceneEventType.REQUEST_CHANGE_SCENE, findVo.sceneId, nil, SceneTransType.GateAny, findVo.x, findVo.y)
  1512. end
  1513. end
  1514. if use_shoe then --使用小飞鞋
  1515. TaskModel:getInstance():SetChangeSceneType(false, false)
  1516. if findVo.sceneId ~= SceneManager.Instance:GetSceneId() then
  1517. TaskModel:getInstance():SetNeedTaskFlag(true)
  1518. end
  1519. local end_pos = GameMath.GetPosByCeterPoint(findVo.x * SceneObj.LogicRealRatio.x,findVo.y * SceneObj.LogicRealRatio.y, 100)
  1520. local fly_shoe_scene_id = SceneManager.Instance:GetSceneId()
  1521. local call_back = function ( )
  1522. if findVo.sceneId == fly_shoe_scene_id then
  1523. on_find_vo_func()
  1524. else
  1525. self.fly_timer_id = setTimeout(on_find_vo_func,0.5)
  1526. end
  1527. end
  1528. GlobalEventSystem:Fire(EventName.USE_FLY_SHOE, findVo.sceneId, end_pos.x,end_pos.y, call_back)
  1529. else
  1530. TaskModel:getInstance():SetChangeSceneType(SceneTransType.GateAny, findVo)
  1531. if findVo.sceneId ~= SceneManager.Instance:GetSceneId() then
  1532. TaskModel:getInstance():SetNeedTaskFlag(true)
  1533. end
  1534. GlobalEventSystem:Fire(EventName.FIND, findVo, change_scene_type)
  1535. end
  1536. end
  1537. end
  1538. -----------------界面相关-----------------
  1539. function TaskController:OpenTaskView(index,task_id,parent_index,sub_index)
  1540. if self.TaskNewBaseView == nil then
  1541. self.TaskNewBaseView = TaskNewBaseView.New()
  1542. end
  1543. self.TaskNewBaseView:Open(index, task_id,parent_index,sub_index)
  1544. end
  1545. function TaskController:CheckNewMainLineTip( )
  1546. local level = RoleManager.Instance.mainRoleInfo.level
  1547. if level < Config.ConfigTaskEffect.NewMainLineTipLvMin or Config.ConfigTaskEffect.NewMainLineTipLvMax < level then
  1548. return
  1549. end
  1550. local cur_task = self.taskModel:GetMainTask()
  1551. if not self.mark_main_line_list then
  1552. self.mark_main_line_list = {[0] = true}
  1553. end
  1554. if cur_task then
  1555. if not self.mark_main_line_list[cur_task.id] then
  1556. --新任务,标记起来
  1557. self.mark_main_line_list[cur_task.id] = true
  1558. if self.next_need_new_main_tip or (not self.first_call_new_tip) then
  1559. self.taskModel.tip_new_main_line = cur_task.id
  1560. GuideController.Instance:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE, 9993150002)
  1561. self.taskModel:Fire(TaskEvent.SHOW_NEW_MAIN_LINE_TIP)
  1562. end
  1563. end
  1564. end
  1565. --上一次是无主线,下一次才需要,或者第一次调用
  1566. self.next_need_new_main_tip = (not (cur_task and cur_task.id > 0))-- or (not self.first_call_new_tip)
  1567. if not self.first_call_new_tip then
  1568. self.first_call_new_tip = true
  1569. end
  1570. end
  1571. function TaskController:CheckWaitNewMainLineAccept( )
  1572. --等待断级主线的接取,那次30000协议返回不用自动任务
  1573. if Config.ConfigTaskEffect.GuideLevel < RoleManager.Instance.mainRoleInfo.level then
  1574. local cur_task = self.taskModel:GetMainTask()
  1575. local b = (not (cur_task and cur_task.id > 0 and cur_task.id ~= Config.ConfigTaskEffect.DefaultTaskId))
  1576. --如果当前卡主线了,等级达到一定程度,如果当前有跑环任务,就去跑环
  1577. if b == true and self.main_line_break_wait == false and RoleManager.Instance.mainRoleInfo.level >= Config.ConfigTaskEffect.WhenBreakMainLineGotoDoDailyTaskLevel then
  1578. self.taskModel:JustDoDailyCircleTask()
  1579. end
  1580. self.main_line_break_wait = b
  1581. end
  1582. end