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

661 行
21 KiB

  1. require("game.guide.GuideModel")
  2. require("game.guide.GuideShowView")
  3. require("game.guide.GuidePromptView")
  4. require("game.guide.HelpType")
  5. require("game.guide.GuideMasktView")
  6. require("game.guide.GuideHorseUseView")
  7. require("game.guide.ReChargePreView")
  8. require("game.guide.GuideTaskLimitView")
  9. require("game.guide.GuideIntroduceView")
  10. require("game.guide.GuideSpiritView")
  11. require("game.guide.GuideSpiritItem")
  12. --新增
  13. require("game.guide.GuideWelcomeView")
  14. require("game.guide.GuideStartView")
  15. GuideController = GuideController or BaseClass(BaseController)
  16. local GuideController = GuideController
  17. function GuideController:__init()
  18. GuideController.Instance = self
  19. self.model = GuideModel:getInstance()
  20. self.is_monster_create = false -- 是否怪物已经创建
  21. self.sound_id = 0
  22. self:RegisterProtocals()
  23. self:InitEvent()
  24. end
  25. function GuideController:RegisterProtocals()
  26. self:RegisterProtocal(10210, "on10210") --终身引导的事件列表
  27. self:RegisterProtocal(10211, "on10211") --终身引导的事件状态变更
  28. end
  29. function GuideController:on10210( )
  30. local vo = SCMD10210.New(true)
  31. self.model:SetLifelongHelpList(vo.list)
  32. end
  33. function GuideController:on10211( )
  34. local vo = SCMD10211.New(true)
  35. self.model:SetLifelongHelp(vo)
  36. end
  37. function GuideController:InitEvent()
  38. local function onReqLifelongHelp( id, state )
  39. self:SendFmtToGame(10211, "hc", id, state)
  40. end
  41. GlobalEventSystem:Bind(GuideModel.REQ_LIFELONG_HELPER_CHANGE, onReqLifelongHelp)
  42. --游戏登陆加载配置
  43. local function onGameStart()
  44. self.func_help_vo = false
  45. self.need_force_do_task = false
  46. self.model:ClearData()
  47. self.model:InitCookiesList()
  48. self.model:FinishOverHelp()
  49. GlobalEventSystem:Fire(EventName.IS_SHOW_TRUN_MASK_HELPER) --cookie加载完 刷新一下主界面
  50. --检测自动做主线
  51. self:StartCheckAutoDoTask()
  52. --获取终身引导的事件列表
  53. self:SendFmtToGame(10210)
  54. end
  55. GlobalEventSystem:Bind(EventName.COOKIE_INIT_FINISH, onGameStart)
  56. --新手剧情
  57. local function onWelcome(chapter_id)
  58. if ClientConfig.alpha_mode then
  59. return
  60. end
  61. if not self.story_view then
  62. self.story_view = GuideWelcomeView.New()
  63. end
  64. self.story_view:Open(chapter_id)
  65. end
  66. GlobalEventSystem:Bind(EventName.PLAY_ENTER_WELCOME_VIEW, onWelcome)
  67. --新手剧情
  68. local function onGuideStart(chapter_id)
  69. if ClientConfig.alpha_mode then
  70. return
  71. end
  72. if not self.guide_start_view then
  73. self.guide_start_view = GuideStartView.New()
  74. end
  75. self.guide_start_view:Open(chapter_id)
  76. end
  77. GlobalEventSystem:Bind(EventName.PLAY_ENTER_GUIDE_START_VIEW, onGuideStart)
  78. local function onSceneLoadFiinish()
  79. --当前需要触发特殊引导
  80. if self.need_retrigger_special_type and SceneManager:getInstance():IsMainCityorYieldSceneNotGuild() then
  81. local function on_delay( )
  82. GlobalEventSystem:Fire(GuideModel.EXECUTE_LIFELONG_HELPER, self.need_retrigger_special_type)
  83. self.need_retrigger_special_type = false
  84. end
  85. setTimeout(on_delay, 0.5)
  86. end
  87. --执行cookie所有的引导
  88. if not self.model.scene_init_finish then
  89. self.model.scene_init_finish = true
  90. setTimeout(function () self:TriggerAllHelper() end,0.3)
  91. end
  92. end
  93. GlobalEventSystem:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE,onSceneLoadFiinish)
  94. -- 升级
  95. local function onLevelUp(lv)
  96. -- self:TriggerHelper(GuideModel.LEVEL_TRIGGER_TYPE,lv) -- 触发升级引导
  97. --特殊引导
  98. if lv and lv == GuideModel.LIFELONG_MARKET_OPEN_TYPE_LEVEL then
  99. if self.model:NeedTriggerMarketOpenType() then
  100. self.need_retrigger_special_type = GuideModel.LIFELONG_TYPE.MARKET_OPEN
  101. end
  102. elseif lv and lv == GuideModel.LIFELONG_ELITE_ASSESS_TYPE_LEVEL then
  103. self.need_retrigger_special_type = GuideModel.LIFELONG_TYPE.ELITE_ASSESS
  104. end
  105. --当前是在大世界中,则直接触发
  106. if self.need_retrigger_special_type and SceneManager:getInstance():IsMainCityorYieldSceneNotGuild() then
  107. local function on_delay( )
  108. GlobalEventSystem:Fire(GuideModel.EXECUTE_LIFELONG_HELPER, self.need_retrigger_special_type)
  109. self.need_retrigger_special_type = false
  110. end
  111. setTimeout(on_delay, 0.5)
  112. end
  113. end
  114. RoleManager:getInstance().mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
  115. GlobalEventSystem:Bind(EventName.OFFLINE_LEVEL_UP, onLevelUp) --离线挂机,上线触发升级
  116. local function onTaskFinishHandler(taskId)
  117. self:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE,taskId)
  118. self:TriggerStory(taskId)
  119. end
  120. GlobalEventSystem:Bind(TaskEvent.ANS_FINISHED_TASK_LIST, onTaskFinishHandler)
  121. local function onTaskSuccessHandler(taskId)
  122. --支线完成引导
  123. if taskId == 3150001 then
  124. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_EXTENSION_LINE_TASK_FINISH,1)
  125. if helpVo then
  126. GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
  127. end
  128. end
  129. end
  130. GlobalEventSystem:Bind(TaskEventType.TASK_SUCCESS, onTaskSuccessHandler)
  131. local function onFinsishCurrentStep(helpVo,ignore_prompt)
  132. self:FinishCurrentHelpStep(helpVo,ignore_prompt)
  133. end
  134. GlobalEventSystem:Bind(EventName.FINISH_CURRENT_HELP_STEP,onFinsishCurrentStep)
  135. local function onFinsishAllStep(helpVo)
  136. self.model:FinishAll(helpVo)
  137. end
  138. GlobalEventSystem:Bind(EventName.FINISH_ALL_HELP_STEP,onFinsishAllStep)
  139. --新手引导测试
  140. local function onTestHelpStep(lv)
  141. -- self:TriggerHelper(GuideModel.LEVEL_TRIGGER_TYPE,lv) -- 触发升级引导
  142. self:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE,lv)
  143. end
  144. GlobalEventSystem:Bind(EventName.TEST_HELP_STEP,onTestHelpStep)
  145. local function onGuideIntroduceView (helpVo)
  146. if self.GuideIntroduceView == nil then
  147. self.GuideIntroduceView = GuideIntroduceView.New()
  148. end
  149. self.GuideIntroduceView:Open(helpVo)
  150. end
  151. GlobalEventSystem:Bind(EventName.OPEN_GUIDE_INTRODUCE_VIEW,onGuideIntroduceView)
  152. local function onGuideMasktView(ref_tar,prompt_type)
  153. if self.GuideMasktView == nil then
  154. self.GuideMasktView = GuideMasktView.New()
  155. end
  156. self.GuideMasktView:Open(ref_tar,prompt_type)
  157. end
  158. GlobalEventSystem:Bind(EventName.OPEN_FORCE_MASK_VIEW,onGuideMasktView)
  159. local function onOpenGuideTaskLimitView(show)
  160. if show then
  161. if self.GuideTaskLimitView == nil then
  162. self.GuideTaskLimitView = GuideTaskLimitView.New()
  163. end
  164. self.GuideTaskLimitView:Open()
  165. else
  166. if self.GuideTaskLimitView and self.GuideTaskLimitView:HasOpen() then
  167. self.GuideTaskLimitView:Close()
  168. end
  169. end
  170. end
  171. GlobalEventSystem:Bind(EventName.OPEN_GUIDE_TASK_LIMIT, onOpenGuideTaskLimitView)
  172. local function onGuideSpiritView()
  173. if self.GuideSpiritView == nil then
  174. self.GuideSpiritView = GuideSpiritView.New()
  175. end
  176. self.GuideSpiritView:Open()
  177. end
  178. GlobalEventSystem:Bind(EventName.OPEN_GUIDE_SPIRIT_VIEW,onGuideSpiritView)
  179. local function onGuideHorseUseView()
  180. if self.GuideHorseUseView == nil then
  181. self.GuideHorseUseView = GuideHorseUseView.New()
  182. end
  183. self.GuideHorseUseView:Open()
  184. end
  185. GlobalEventSystem:Bind(EventName.OPEN_HORSE_GUIDE_VIEW,onGuideHorseUseView)
  186. local function onGuidePromptView(attach_node,ui_attach_node,call_back,helpVo,view_layout_file,layer_name,z_depth)
  187. if self.GuidePromptView then
  188. self.GuidePromptView:Close()
  189. end
  190. if self.GuidePromptView == nil then
  191. self.GuidePromptView = GuidePromptView.New()
  192. end
  193. self.GuidePromptView:Open(attach_node,ui_attach_node,call_back,helpVo,view_layout_file,layer_name,z_depth)
  194. end
  195. GlobalEventSystem:Bind(EventName.OPEN_GUIDE_PROMPT_VIEW,onGuidePromptView)
  196. local function onCloseGuidePromptView(layout_file)
  197. if self.GuidePromptView then
  198. local view_layout_file = self.GuidePromptView.view_layout_file
  199. if layout_file == nil or layout_file == view_layout_file then
  200. self.GuidePromptView:Close()
  201. end
  202. end
  203. end
  204. GlobalEventSystem:Bind(EventName.CLOSE_GUIDE_PROMPT_VIEW,onCloseGuidePromptView)
  205. local function change_account()
  206. if self.GuidePromptView then
  207. self.GuidePromptView:Close()
  208. end
  209. end
  210. GlobalEventSystem:Bind(EventName.CHANGE_ACCOUNT,change_account)
  211. GlobalEventSystem:Bind(EventName.CHANGE_ROLE,change_account)
  212. local function onDirectExecuteGuide(helpVo)
  213. if helpVo then
  214. self:ExecuteHelps(helpVo)
  215. TaskModel:getInstance():SetTaskAutoFlag(true)
  216. end
  217. end
  218. self.model:Bind(GuideModel.DIRECT_EXECUTE_HELPER,onDirectExecuteGuide)
  219. end
  220. -- cfg_id 可能为等级 或者任务id
  221. function GuideController:TriggerHelper(type,cfg_id)
  222. -- if ClientConfig.alpha_mode then
  223. -- return
  224. -- end
  225. local voList
  226. if type == GuideModel.LEVEL_TRIGGER_TYPE then
  227. voList = self.model:GetLevelConfig(cfg_id)
  228. elseif type == GuideModel.TASK_TRIGGER_TYPE then
  229. voList = self.model:GetTaskConfig(cfg_id)
  230. end
  231. if voList == nil or #voList < 1 then
  232. return
  233. end
  234. -- print("tanar :GuideController [start:259] ================= ")
  235. -- PrintTable(voList)
  236. -- print("tanar :GuideController [end] ================= ")
  237. for i,vo in ipairs(voList) do
  238. if not self.model:HasExecuteStep(vo) then
  239. self:ExecuteHelps(vo)
  240. break
  241. end
  242. end
  243. end
  244. --执行所有cookie的引导
  245. function GuideController:TriggerAllHelper( )
  246. local lvList = self.model:GetLvCookieList()
  247. for k,v in pairs(lvList) do
  248. if not v.isEnd then
  249. local helpList = self.model:GetLevelConfig(v.lv)
  250. if helpList and helpList[v.step] and not self.model:IsOverHelp(v.help_type) then
  251. self:ExecuteHelps(helpList[v.step])
  252. end
  253. end
  254. end
  255. local taskList = self.model:GetTaskCookieList()
  256. for k,v in pairs(taskList) do
  257. if not v.isEnd then
  258. local helpList = self.model:GetTaskConfig(v.task_id)
  259. if helpList and helpList[v.step] and not self.model:IsOverHelp(v.help_type) then
  260. self:ExecuteHelps(helpList[v.step])
  261. end
  262. end
  263. end
  264. self.model:TriggerBreakGuide()
  265. self.model:TriggerBreakLevelGuide()
  266. end
  267. function GuideController:PlaySound(helpVo)
  268. lua_soundM:StopEffect(self, LuaSoundManager.SOUND_TYPE.GUIDE, self.sound_id)
  269. if helpVo.sound and Trim(helpVo.sound) ~= "" then
  270. self.sound_id = lua_soundM:PlayEffect(self, Trim(helpVo.sound), false, LuaSoundManager.SOUND_TYPE.GUIDE, 1)
  271. end
  272. end
  273. -- 执行引导
  274. function GuideController:ExecuteHelps(helpVo)
  275. if helpVo == nil then
  276. return
  277. end
  278. --判断条件
  279. if helpVo.step==1 then
  280. if helpVo.task_id==Config.ConfigHelper.firstRecharge then
  281. --如果首充了,就不引导
  282. if not RechargeActivityModel:getInstance():IsNoFirstRecharge() or PlatformMgr:getInstance():IsMlLianyun() then
  283. self:FinishCurrentHelpStep(helpVo)
  284. GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK)
  285. return
  286. end
  287. elseif helpVo.task_id==Config.ConfigHelper.firstRechargeTip then
  288. if PlatformMgr:getInstance():IsMlLianyun() then
  289. self:FinishCurrentHelpStep(helpVo)
  290. GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK)
  291. return
  292. end
  293. end
  294. end
  295. --为防止多个新功能开放,必须先把之前的清除
  296. if helpVo.help_type == HelpType.NEW_FUNC_OPEN then
  297. local last_helpVo = GuideModel:getInstance():GetHelpVo(HelpType.NEW_FUNC_OPEN,1)
  298. if last_helpVo then
  299. self.model:FinishCurrHelper(last_helpVo)
  300. end
  301. FuncOpenModel:getInstance():ClearOpenCondition()
  302. FuncOpenModel:getInstance():ClearOpenFuncData()
  303. if self.open_timer_id then
  304. GlobalTimerQuest:CancelQuest(self.open_timer_id)
  305. self.open_timer_id = nil
  306. end
  307. --这个单独处理
  308. if not SceneManager.Instance:IsMainCityorYieldScene() then
  309. self.func_help_vo = helpVo
  310. return
  311. end
  312. GlobalEventSystem:Fire(EventName.OPEN_STRENGTH_VIEW, false)
  313. end
  314. self.model:SetCurTriggerType(helpVo.type)
  315. self.model:SetCurHelpType(helpVo.help_type)
  316. self.model:SetCurHelpStep(helpVo.step)
  317. self.model:SetCurHelpVo(helpVo)
  318. helpVo.isEnd = false --正在执行的 标记为false
  319. --写入cookies
  320. self.model:SetHelperStep(helpVo)
  321. if helpVo.hide_small_ui then
  322. self.model:SetHideSmallUI(true)
  323. ItemUseModel:getInstance():HideItemUseView()
  324. self.model:HideUILayUI()
  325. end
  326. if helpVo.help_type == HelpType.NEW_FUNC_OPEN then
  327. -- GlobalEventSystem:Fire(EventName.CLOSE_ALL_VIEW)
  328. -- GlobalEventSystem:Fire(EventName.CLOSE_CHAT_VIEW)
  329. -- GlobalEventSystem:Fire(EventName.OPEN_TASK_BOUNTY_REWARD_VIEW,nil,true)
  330. -- local onDelay = function( )
  331. -- GlobalEventSystem:Fire(EventName.TRIGGER_NEW_FUNC_OPEN_HELPER,helpVo)
  332. -- self:ChangeSound(helpVo)
  333. -- end
  334. -- self.open_timer_id = setTimeout(onDelay, 0.3)
  335. GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
  336. GlobalEventSystem:Fire(EventName.TRIGGER_NEW_FUNC_OPEN_HELPER,helpVo)
  337. elseif helpVo.help_type == HelpType.TASK_ITEM_SHOW then
  338. -- if self.show_timer_id then
  339. -- GlobalTimerQuest:CancelQuest(self.show_timer_id)
  340. -- self.show_timer_id = nil
  341. -- end
  342. -- EventSystem.Fire(GlobalEventSystem, EventName.STOPAUTOFIGHT, false, true)--寻路要先切换掉自动挂机状态
  343. -- GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
  344. -- GlobalEventSystem:Fire(EventName.CLOSE_ALL_VIEW)
  345. -- local onDelay = function( )
  346. -- self:ShowModel(helpVo)
  347. -- self:ChangeSound(helpVo)
  348. -- end
  349. -- self.show_timer_id = setTimeout(onDelay, 0.1)
  350. GlobalEventSystem:Fire(EventName.GUIDE_CLOSE_VIEW)
  351. self:ShowModel(helpVo)
  352. elseif helpVo.help_type == HelpType.OPEN_UI_VIEW then
  353. self:OpenUI(helpVo)
  354. self:FinishCurrentHelpStep(helpVo)
  355. --收起菜单
  356. setTimeout(function()
  357. GlobalEventSystem:Fire(EventName.OPEN_LEFT_MIDDLE_MENU, false)
  358. end,0.6)
  359. elseif helpVo.help_type == HelpType.ENTER_MISSION then
  360. self:EnterMission(helpVo)
  361. self:FinishCurrentHelpStep(helpVo)
  362. elseif helpVo.help_type == HelpType.CAST_SKILL then --播放技能
  363. self:CastSkill(helpVo)
  364. elseif helpVo.help_type == HelpType.FORCE_MASK then --强制遮罩
  365. elseif helpVo.help_type == HelpType.OPEN_LIST_SHOW_ICON then --展开列表图标显示特效
  366. local onDelay = function ( )
  367. self:ExpandIconList(helpVo)
  368. self:FinishCurrentHelpStep(helpVo)
  369. end
  370. setTimeout(onDelay, 0.3)
  371. GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK)
  372. elseif helpVo.help_type == HelpType.OPEN_LIST_SHOW_PROMPT then --展开列表图标显示指引
  373. local onDelay = function ( )
  374. if helpVo.task_id == Config.ConfigHelper.mountTask then --永恒碑谷没开启的话, 要升级后再判断一次
  375. if not ActivityIconManager:getInstance():IsIconShow(21) then
  376. self.model.wait_level_up = helpVo
  377. return
  378. end
  379. end
  380. self:ShowIconListGuide(helpVo)
  381. end
  382. setTimeout(onDelay, 0.5)
  383. elseif helpVo.help_type == HelpType.DELAY_TIME then --延迟执行 param 为延迟的秒数
  384. self:DelayTime(helpVo)
  385. elseif helpVo.help_type == HelpType.CONTINUM_TASK then --继续任务
  386. self:ContinumTask(helpVo)
  387. elseif helpVo.help_type == HelpType.HIDE_SMALL_UI then --隐藏一些如道具使用的小界面
  388. ItemUseModel:getInstance():HideItemUseView()
  389. self.model:HideUILayUI()
  390. self:FinishCurrentHelpStep(helpVo)
  391. elseif helpVo.help_type == HelpType.SHOW_SMALL_UI then --显示一些如道具使用的小界面
  392. ItemUseModel:getInstance():ShowItemUseView()
  393. self.model:ShowUILayUI()
  394. self:FinishCurrentHelpStep(helpVo)
  395. elseif helpVo.help_type == HelpType.SHOW_CHAPTER then --章节引导
  396. GlobalEventSystem:Fire(EventName.PLAY_ENTER_WELCOME_VIEW, helpVo.chapter_id)
  397. -- elseif helpVo.help_type == HelpType.PLAY_SOUND then --变身降神
  398. -- if helpVo.sound and Trim(helpVo.sound) ~= "" then
  399. -- self:PlaySound(helpVo)
  400. -- end
  401. -- self:FinishCurrentHelpStep(helpVo)
  402. end
  403. --播放音效
  404. if helpVo.sound and Trim(helpVo.sound) ~= "" then
  405. self:PlaySound(helpVo)
  406. end
  407. GlobalEventSystem:Fire(EventName.TRIGGER_GUIDE_TYPE, helpVo)
  408. end
  409. -- 打开UI
  410. function GuideController:OpenUI(helpVo)
  411. if helpVo then
  412. local param = helpVo.param
  413. local arr = stringtotable(param)
  414. if arr and arr[1] then
  415. local winId = tostring(arr[1][1])
  416. local subId = tonumber(arr[1][2])
  417. local value = tonumber(arr[1][3])
  418. OpenFun.Open(winId, subId, value)
  419. end
  420. end
  421. end
  422. function GuideController:ShowModel(helpVo)
  423. -- if helpVo then
  424. -- local param = helpVo.param
  425. -- local arr = Split(param,",")
  426. -- if arr and #arr > 0 then
  427. -- GlobalEventSystem:Fire(EventName.OPEN_GUIDE_SHOW_VIEW,arr,helpVo.saying)
  428. -- end
  429. -- end
  430. local onDelay = function( )
  431. -- self:CheckHideUILayer(helpVo)
  432. GlobalEventSystem:Fire(EventName.TRIGGER_NEW_FUNC_OPEN_HELPER,helpVo)
  433. self:ChangeSound(helpVo)
  434. end
  435. setTimeout(onDelay, 0.1)
  436. end
  437. function GuideController:EnterMission(helpVo)
  438. local mission_id = tonumber(helpVo.param)
  439. BaseDungeonModel:getInstance():Fire(BaseDungeonModel.REQUEST_CCMD_EVENT, 61001, mission_id)
  440. end
  441. function GuideController:ExpandIconList( helpVo )
  442. if helpVo then
  443. local param = helpVo.param
  444. local arr = Split(param,",")
  445. if arr and #arr > 0 then
  446. GlobalEventSystem:Fire(EventName.EXPAND_LIST_SHOW,arr)
  447. end
  448. end
  449. end
  450. function GuideController:ShowIconListGuide( helpVo )
  451. if helpVo then
  452. local param = helpVo.param
  453. local arr = Split(param,",")
  454. if arr and #arr > 0 then
  455. GlobalEventSystem:Fire(EventName.EXPAND_LIST_GUIDE,arr)
  456. end
  457. end
  458. end
  459. -- 结束当前引导 ignore_prompt 一般用于引导最后一步 结束不关闭
  460. function GuideController:FinishCurrentHelpStep(helpVo,ignore_prompt)
  461. if helpVo == nil then
  462. return
  463. end
  464. --关掉界面 这些引导不关,避免把其他引导关了
  465. if not ignore_prompt then
  466. GlobalEventSystem:Fire(EventName.CLOSE_GUIDE_PROMPT_VIEW)
  467. end
  468. local show_small_ui = false
  469. if helpVo.show_small_ui then
  470. show_small_ui = true
  471. end
  472. local next_help_vo = self.model:GetNextHelpVo(helpVo)
  473. if next_help_vo then
  474. self:ExecuteHelps(next_help_vo)
  475. else
  476. --如果只配置了一个引导,而且是隐藏UI,则需要显示出来
  477. if helpVo.hide_small_ui then
  478. show_small_ui = true
  479. end
  480. self.model:FinishCurrHelper(helpVo)
  481. end
  482. if show_small_ui then
  483. self.model:SetHideSmallUI(false)
  484. ItemUseModel:getInstance():ShowItemUseView()
  485. self.model:ShowUILayUI()
  486. end
  487. end
  488. -- 场景切换清除数据跟特效
  489. function GuideController:ClearHelpDataAndRes()
  490. end
  491. -- 释放技能
  492. function GuideController:CastSkill(helpVo)
  493. --新手变身降神 不需要释放技能
  494. local god_id = RoleManager.Instance.mainRoleInfo.god_id
  495. if god_id > 0 then
  496. self:FinishCurrentHelpStep(helpVo)
  497. return
  498. end
  499. local career = RoleManager:getInstance():GetMainRoleCareer()
  500. local arr = Split(helpVo.param,",")
  501. if arr and arr[career] then
  502. local career = RoleManager:getInstance():GetMainRoleCareer()
  503. local skill_id = tonumber(arr[career])
  504. local movie_cfg = SkillManager.Instance:GetFightSkillMovie(skill_id)
  505. if movie_cfg and movie_cfg.back_swing then
  506. SkillManager:getInstance():setCurrentSkillId(skill_id)
  507. EventSystem.Fire(GlobalEventSystem,FightEvent.RELEASE_MAIN_SKILL,nil,nil,nil,SkillManager.SKILL_ATTACK_TYPE.ONLY_FIRE_ATTACK,true)
  508. local delay_fun = function ()
  509. self:FinishCurrentHelpStep(helpVo)
  510. end
  511. setTimeout(delay_fun, movie_cfg.back_swing + 0.15)
  512. end
  513. end
  514. end
  515. function GuideController:ChangeSound( helpVo )
  516. if helpVo.sound and Config.ConfigSound.SoundTime[Trim(helpVo.sound)] then
  517. local onDealy = function ( )
  518. self.time_id = nil
  519. if self.old_value then
  520. LuaSoundManager:getInstance():ChangeVolume(self.old_value)
  521. end
  522. end
  523. if not self.time_id then
  524. self.old_value = soundMgr.volume
  525. LuaSoundManager:getInstance():ChangeVolume(self.old_value*0.2)
  526. self.time_id = setTimeout(onDealy, Config.ConfigSound.SoundTime[Trim(helpVo.sound)])
  527. end
  528. end
  529. end
  530. --延迟执行
  531. function GuideController:DelayTime(helpVo)
  532. local time = tonumber(helpVo.param)
  533. local delay_fun = function ()
  534. self:FinishCurrentHelpStep(helpVo)
  535. end
  536. setTimeout(delay_fun, time)
  537. end
  538. --继续执行任务
  539. function GuideController:ContinumTask(helpVo)
  540. self:FinishCurrentHelpStep(helpVo)
  541. EventSystem.Fire(GlobalEventSystem,EventName.FORCE_TO_DO_TASK)
  542. end
  543. --开始检测站街自动任务
  544. function GuideController:StartCheckAutoDoTask()
  545. self:StopCheckAutoDoTask()
  546. if RoleManager.Instance.mainRoleInfo.level > GuideModel.AUTO_DOTASK.level then return end
  547. local function auto_onhook_check()
  548. local main_role = Scene.Instance:GetMainRole()
  549. if not Scene.Instance:GetMainRole() or not SceneManager:getInstance():IsMainCityAndFieldScene() then
  550. return
  551. end
  552. if RoleManager.Instance.mainRoleInfo.level > GuideModel.AUTO_DOTASK.level then
  553. self:StopCheckAutoDoTask()
  554. return
  555. end
  556. local stand_time = self.model.auto_task_stand_time ~= 0 and Time.time - self.model.auto_task_stand_time or 0
  557. local touch_time = GlobalUserOperateTime ~= 0 and Time.time - GlobalUserOperateTime or 0
  558. if stand_time > GuideModel.AUTO_DOTASK.time and touch_time > GuideModel.AUTO_DOTASK.time then
  559. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK)
  560. GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK)
  561. end
  562. end
  563. self.start_autotask_timer_id = GlobalTimerQuest:AddPeriodQuest(auto_onhook_check, 5, -1)
  564. end
  565. function GuideController:StopCheckAutoDoTask()
  566. if self.start_autotask_timer_id then
  567. GlobalTimerQuest:CancelQuest(self.start_autotask_timer_id)
  568. self.start_autotask_timer_id = false
  569. end
  570. end
  571. function GuideController:TriggerStory(task_id)
  572. if task_id == 10360 then
  573. if RoleManager.Instance.mainRoleInfo.career == 1 or RoleManager.Instance.mainRoleInfo.career == 2 then
  574. task_id = 1036001
  575. else
  576. task_id = 1036002
  577. end
  578. end
  579. local story_cfg = Config.Story[99999][task_id]
  580. if story_cfg then
  581. local main_role = Scene.Instance.main_role
  582. if story_cfg and main_role then
  583. main_role:DoStory(story_cfg)
  584. end
  585. end
  586. end