源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

453 lines
15 KiB

  1. --[[
  2. ]]
  3. NewFuncOpenView = NewFuncOpenView or BaseClass(BaseView)
  4. local NewFuncOpenView = NewFuncOpenView
  5. function NewFuncOpenView:__init()
  6. self.base_file = "func"
  7. self.layout_file = "NewFuncOpenView"
  8. self.layer_name = "Top"
  9. self.destroy_imm = true
  10. self.change_scene_close = true
  11. self.open_guide_close = nil
  12. self.is_set_zdepth = true
  13. self.blur_activity_bg = true
  14. self.model = FuncOpenModel:getInstance()
  15. self.model.is_open_func_model_view = true
  16. self.time_diff = 15
  17. FosterModel:GetInstance().wait_new_func_open = true
  18. self.load_callback = function ()
  19. self:LoadSuccess()
  20. self:AddEvent()
  21. end
  22. self.open_callback = function ( )
  23. self:OpenSuccess()
  24. end
  25. self.close_callback = function ()
  26. self:CloseSuccess()
  27. end
  28. self.destroy_callback = function ( )
  29. self:DestroySuccess()
  30. end
  31. end
  32. function NewFuncOpenView:Open( voList )
  33. -- self.model.is_newFuncOpenView_opening = true --为了战力后显示,先记录界面是否打开
  34. self.voList = voList
  35. BaseView.Open(self)
  36. end
  37. function NewFuncOpenView:LoadSuccess()
  38. self.center_obj = self:GetChild("mid/center_cont").gameObject
  39. self.mask_obj = self:GetChild("mid/mask_img").gameObject
  40. self.mask_img = self:GetChild("mid/mask_img"):GetComponent("Image")
  41. self.title_img = self:GetChild("mid/center_cont/title_img"):GetComponent("Image")
  42. self.name_txt = self:GetChild("mid/center_cont/up_cont/name_txt"):GetComponent(typeof(TMPro.TextMeshProUGUI))
  43. self.desc_txt = self:GetChild("mid/center_cont/up_cont/desc_txt"):GetComponent(typeof(TMPro.TextMeshProUGUI))
  44. self.time_txt = self:GetChild("mid/center_cont/time_txt"):GetComponent(typeof(TMPro.TextMeshProUGUI))
  45. self.icon_cont = self:GetChild("icon_cont")
  46. self.icon_cont_obj = self:GetChild("icon_cont").gameObject
  47. self.effect = self:GetChild("mid/center_cont/effect")
  48. self.up_cont = self:GetChild("mid/center_cont/up_cont").gameObject
  49. self.skill_name_txt = self:GetChild("mid/center_cont/up_cont/skill_name_txt"):GetComponent(typeof(TMPro.TextMeshProUGUI))
  50. local nodes = {
  51. "mid/center_cont/bg_img:img",
  52. "mid/center_cont/up_cont/desc_bg:obj",
  53. "mid/center_cont/up_cont/icon_img:img","icon_raw",
  54. }
  55. self:GetChildren(nodes)
  56. -- self:AddUIEffect("ui_guangxiao", self.effect, self.layer_name, nil, 1, true)
  57. -- self:SetGameObjectDepth(self.up_cont, true)
  58. self.mask_img.alpha = 0.8
  59. self.mask_obj.transform.sizeDelta = Vector2(ScreenWidth,ScreenHeight)
  60. -- self.transform.sizeDelta = Vector2(ScreenWidth,ScreenHeight)
  61. self.transform:SetInsetAndSizeFromParentEdge(self.transform.EdgeLeft, 0, ScreenWidth)
  62. end
  63. function NewFuncOpenView:AddEvent()
  64. local function on_click( target )
  65. if target == self.mask_obj then
  66. if Scene.Instance.main_role then
  67. local cfg = Scene.Instance.main_role:GetMainRoleStorycfg(PoseState.STORY)
  68. if cfg and cfg.ignore_click then
  69. return
  70. end
  71. end
  72. self:PlayAction()
  73. end
  74. end
  75. AddClickEvent(self.mask_obj, on_click)
  76. end
  77. function NewFuncOpenView:OpenSuccess()
  78. GlobalEventSystem:Fire(SceneEventType.CLOSE_DIALOGUE_VIEW)
  79. self:UpdateView()
  80. --是否忽略任务状态,不主动停止,也不主动继续任务
  81. local is_ignore_auto_task = false
  82. if self.cur_vo and self.cur_vo.ignore_auto_task then
  83. is_ignore_auto_task = true
  84. end
  85. if not is_ignore_auto_task then
  86. self.is_auto_fight = AutoFightManager:getInstance():GetAutoFightState()
  87. if self.is_auto_fight then
  88. GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT) --停止自动挂机
  89. self.need_close_fight = true
  90. end
  91. self.is_auto_task = TaskModel:getInstance():GetTaskAutoFlag()
  92. if self.is_auto_task then
  93. GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK) --停止自动任务
  94. self.need_close_task = true
  95. end
  96. end
  97. self:PlaySound()
  98. end
  99. function NewFuncOpenView:PlaySound( )
  100. if IsTableEmpty(self.cur_vo) then
  101. return
  102. end
  103. if self.cur_vo then
  104. lua_soundM:StopEffect(self, LuaSoundManager.SOUND_TYPE.FUNC, self.sound_id)
  105. if self.cur_vo.sound and Trim(self.cur_vo.sound) ~= "" then
  106. if lua_soundM then
  107. self.sound_id = lua_soundM:PlayEffect(self, Trim(self.cur_vo.sound),false,LuaSoundManager.SOUND_TYPE.FUNC)
  108. end
  109. end
  110. end
  111. end
  112. function NewFuncOpenView:UpdateView()
  113. if self.voList then
  114. self.cur_vo = self.voList[1]
  115. local bg_res = self.cur_vo.type == 2 and "open_func_skill_bg" or "open_func_fun_bg"
  116. lua_resM:setOutsideImageSprite(self, self.bg_img_img, GameResPath.GetFuncIcon(bg_res),true)
  117. local effect_res = false
  118. if self.cur_vo.type == 2 then --技能
  119. effect_res = "huodexinjineng"
  120. self.desc_bg_obj:SetActive(true)
  121. else
  122. SetAnchoredPosition(self.bg_img,1,6)
  123. SetAnchoredPosition(self.title_img.transform,-2,180)
  124. SetAnchoredPosition(self.time_txt.transform,2,-230)
  125. SetAnchoredPosition(self.desc_txt.transform,10,-190)
  126. SetAnchoredPosition(self.name_txt.transform,1,-146)
  127. SetAnchoredPosition(self.effect.transform,0,6)
  128. self.desc_txt.fontSize = 24
  129. self.name_txt.fontSize = 24
  130. SetTMPSharedMaterial(self.name_txt, ShaderTools.TMPSharedMaterialType.HKYTW7SDFOutlineBrightBlueTitle)
  131. effect_res = "jiesuoxingongneng"
  132. self.desc_bg_obj:SetActive(false)
  133. end
  134. if effect_res then
  135. local function delay_method( )
  136. self:AddUIEffect(effect_res, self.effect, self.layer_name, nil, 1, true)
  137. end
  138. setTimeout(delay_method, 0.02)
  139. end
  140. local name = self.cur_vo.name or ""
  141. local desc = self.cur_vo.saying
  142. if self.cur_vo then
  143. lua_resM:setImageSprite(self, self.title_img, "func_asset", "open_func_title1", true)
  144. self.image_obj = UiFactory.createChild(self.icon_cont, UIType.ImageExtend)
  145. self.image_obj.transform.sizeDelta = Vector2(78, 78)
  146. self.image_icon = self.image_obj:GetComponent("ImageExtend")
  147. --资源可能有多个地址,默认activityIcon
  148. local ab_name, res_name = "activityIcon_asset", ""
  149. local is_out_res = false
  150. if self.cur_vo.winId and self.cur_vo.subId then
  151. local fun_vo = OpenFun.LinkWin[self.cur_vo.winId.."@"..self.cur_vo.subId]
  152. if fun_vo then
  153. res_name = fun_vo.icon_res
  154. end
  155. end
  156. --右上角玩法
  157. if self.cur_vo.type == 1 then
  158. if self.cur_vo.tabId and self.cur_vo.tabId ~= 0 then
  159. is_out_res = true
  160. res_name = self.cur_vo.tabId
  161. end
  162. -- name = self.cur_vo.saying
  163. -- desc = ""
  164. --技能
  165. elseif self.cur_vo.type == 2 then
  166. local list = SkillManager.Instance:getCfgInitiativeSkillList()
  167. if list then
  168. local id = list[self.cur_vo.id + 1]
  169. ab_name = "mainUI_asset"
  170. res_name = id or self.cur_vo.skill_id
  171. if self.cur_vo.id ~= 0 and id then
  172. self.cur_vo.skill_id = id
  173. -- local skill_cfg = SkillManager.Instance:getSkillFromConfig(skill_id)
  174. -- self.cur_vo.saying = (skill_cfg and skill_cfg.name or "获取新技能")
  175. local skill_vo = SkillManager.Instance:getSkill(id)
  176. name = skill_vo and skill_vo:getName() or "获取新技能"
  177. if not self.cur_vo.saying or self.cur_vo.saying == "" then
  178. self.cur_vo.saying = skill_vo and skill_vo:GetDesc() or ""
  179. end
  180. end
  181. else
  182. Message.show("没有技能配置")
  183. end
  184. lua_resM:setImageSprite(self, self.title_img, "func_asset", "open_func_title2", true)
  185. if Config.ConfigHelper.PassiveSkillDesc[self.cur_vo.skill_id] then--禁跳神技特殊处理
  186. desc = Config.ConfigHelper.PassiveSkillDesc[self.cur_vo.skill_id]
  187. end
  188. --右下角功能
  189. elseif self.cur_vo.type == 3 then
  190. -- name = self.cur_vo.saying
  191. -- desc = ""
  192. if self.cur_vo.tabId and self.cur_vo.tabId ~= 0 then
  193. is_out_res = true
  194. res_name = self.cur_vo.tabId
  195. local skill_vo = SkillManager.Instance:getSkill(self.cur_vo.tabId)
  196. if skill_vo then
  197. name = skill_vo and skill_vo:getName() or "获取新技能"
  198. end
  199. end
  200. --背包
  201. elseif self.cur_vo.type == 4 then
  202. if self.cur_vo.id == 152 then--装备
  203. res_name = "icon_152_1"
  204. else
  205. res_name = "icon_29_bb"
  206. end
  207. --人格主动技能
  208. elseif self.cur_vo.type == 5 then
  209. res_name = self.cur_vo.skill_id
  210. local skill_vo = SkillManager.Instance:getSkill(id)
  211. name = skill_vo and skill_vo:getName() or name
  212. if not self.cur_vo.saying or self.cur_vo.saying == "" then
  213. self.cur_vo.saying = skill_vo and Trim(skill_vo:GetDesc()) or self.cur_vo.saying
  214. end
  215. -- lua_resM:setImageSprite(self, self.title_img, "func_asset", "func_skill_font", true)
  216. --支线任务
  217. elseif self.cur_vo.type == 6 then
  218. res_name = "icon_300_2"
  219. end
  220. if self.cur_vo.ab_name then
  221. ab_name = self.cur_vo.ab_name
  222. end
  223. if self.cur_vo.res_name then
  224. ab_name = self.cur_vo.res_name
  225. end
  226. if self.cur_vo.show_time then
  227. self.time_diff = self.cur_vo.show_time
  228. end
  229. local size_width = 60
  230. local size_height = 60
  231. if self.cur_vo.winId == 145 and self.cur_vo.subId == 0 then--套装收集
  232. ab_name, res_name = "activityIcon_asset","zjmui_equipCollect_btn_2"
  233. size_width = 58
  234. size_height = 62
  235. elseif self.cur_vo.winId == 450 and self.cur_vo.subId == 22 then--V3激活
  236. ab_name, res_name = "vip_asset","vip3_icon"
  237. elseif self.cur_vo.winId == 460 and self.cur_vo.subId == 0 then--异域幻魔
  238. ab_name, res_name = "mainUI_asset","zjmui_mapbtn1"
  239. size_width = 64
  240. size_height = 127
  241. elseif self.cur_vo.winId == 610 and self.cur_vo.subId == 2 then--经验副本宝箱
  242. res_name = nil
  243. local data = {
  244. father_node = self,
  245. transform = self.icon_raw,
  246. fashion_type = FuncOpenModel.TypeId.Monster,
  247. clothe_res_id = 10010401,
  248. size = Vector2(128, 128),
  249. scale = 250,
  250. can_rotate = false,
  251. action_name_list = {"idle"},
  252. position = Vector3(0, 110, 0),
  253. rotate = Vector3(0, 0, 0),
  254. ui_model_type = UIModelCommon.ModelType.RT,
  255. callBack = function( )
  256. end
  257. }
  258. FuncOpenModel:getInstance():SetModelRes(data)
  259. end
  260. --设置图标
  261. self.center_obj:SetActive(true)
  262. self.image_obj:SetActive(true)
  263. local function callback( ... )
  264. if ab_name == "activityIcon_asset" or (self.cur_vo.winId == 460 and self.cur_vo.subId == 0) then
  265. self.image_obj.transform.sizeDelta = Vector2(size_width, size_height)
  266. SetSizeDelta(self.icon_img,size_width,size_height)
  267. end
  268. end
  269. if res_name and res_name ~= "" then
  270. if self.cur_vo.outside_res then
  271. lua_resM:setOutsideImageSprite(self, self.image_icon, self.cur_vo.outside_res, true,callback)
  272. lua_resM:setOutsideImageSprite(self, self.icon_img_img, self.cur_vo.outside_res, true,callback)
  273. elseif is_out_res then
  274. local path = GameResPath.GetDailyImage(res_name)
  275. if res_name == 110006 then
  276. path = GameResPath.GetSkillIcon(res_name)
  277. end
  278. lua_resM:setOutsideImageSprite(self, self.image_icon, path, true,callback)
  279. lua_resM:setOutsideImageSprite(self, self.icon_img_img, path, true,callback)
  280. else
  281. lua_resM:setImageSprite(self, self.image_icon, ab_name, res_name, ab_name ~= "activityIcon_asset",callback)
  282. lua_resM:setImageSprite(self, self.icon_img_img, ab_name, res_name, ab_name ~= "activityIcon_asset",callback)
  283. end
  284. end
  285. --设置文本
  286. if self.cur_vo.type == 2 then
  287. self.skill_name_txt.text = name or ""
  288. self.name_txt.text = ""
  289. else
  290. self.skill_name_txt.text = ""
  291. self.name_txt.text = name or ""
  292. end
  293. self.desc_txt.text = desc
  294. --倒计时
  295. self:StartTimer()
  296. end
  297. end
  298. end
  299. --动画开始
  300. function NewFuncOpenView:PlayAction( )
  301. if self.tween_id then
  302. TweenLite.Stop(self.tween_id)
  303. self.tween_id = nil
  304. end
  305. local callback = function()
  306. if self.cur_vo and self.cur_vo.type == 2 then
  307. GlobalEventSystem:Fire(EventName.GET_SKILL_SHAKE_ANI,self.cur_vo.id)
  308. end
  309. if self.cur_vo.winId == 450 and self.cur_vo.subId == 22 then
  310. GlobalEventSystem:Fire(EventName.OPEN_VIP_VIEW,VipModel.TabType.Noble,3)
  311. end
  312. self:Close()
  313. end
  314. if self.cur_vo and self.cur_vo.ignore_fly then
  315. callback()
  316. return
  317. end
  318. local pos = self.cur_vo and self.cur_vo.pos and self.cur_vo.pos or Vector3.zero
  319. --被动技能引导技能引导,坐标现在才获取
  320. if self.cur_vo then
  321. pos = self.model:GetFlyPos(self.cur_vo)
  322. end
  323. if pos and self.image_obj then--飞图标拉
  324. self.center_obj:SetActive(false)
  325. self.icon_cont_obj:SetActive(true)
  326. local transform = self.cur_vo.winId == 610 and self.cur_vo.subId == 2 and self.icon_raw.transform or self.image_obj.transform
  327. self.tween_id = TweenLite.to(self, transform, TweenLite.UiAnimationType.POS, pos, 0.8, callback)
  328. else
  329. callback()
  330. end
  331. end
  332. --开始倒计时
  333. function NewFuncOpenView:StartTimer( )
  334. if self.time_id == nil then
  335. self.time_txt.text = HtmlColorTxt(self.time_diff, "#2cf89a") .. " 秒后自动关闭"
  336. local function onTimer()
  337. self.time_diff = self.time_diff - 1
  338. if self.time_diff >= 0 then
  339. self.time_txt.text = HtmlColorTxt(self.time_diff, "#2cf89a") .. " 秒后自动关闭"
  340. else
  341. if self.time_id then
  342. GlobalTimerQuest:CancelQuest(self.time_id)
  343. self.time_id = nil
  344. end
  345. self:PlayAction()
  346. end
  347. end
  348. self.time_id = GlobalTimerQuest:AddPeriodQuest(onTimer,1,-1)
  349. end
  350. end
  351. --[[function NewFuncOpenView:ReShowFightingUp()--存储的战力提交再次显示
  352. self.model.is_newFuncOpenView_opening = false
  353. local fight_num = RoleManager.Instance.mainRoleInfo.fighting
  354. if self.model.old_fightNum and fight_num > self.model.old_fightNum then
  355. GlobalEventSystem:Fire(FightingUpEvent.FIGHTING_UP, self.model.old_fightNum, fight_num)
  356. end
  357. end--]]
  358. --关闭界面后做什么
  359. function NewFuncOpenView:CloseSuccess( )
  360. if self.image_obj then
  361. self.image_obj:SetActive(false)
  362. end
  363. GlobalEventSystem:Fire(EventName.SHOW_FUNC_OPEN_ICON,self.voList)
  364. --完成引导
  365. local main_role = Scene.Instance.main_role
  366. if main_role and main_role:IsInState(PoseState.STORY) then
  367. main_role:ChangeState(PoseState.STAND)
  368. end
  369. if self.need_close_fight then
  370. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT) --启动自动挂机
  371. end
  372. local helpVo, endVo = GuideModel:getInstance():GetHelpVo(HelpType.NEW_FUNC_OPEN,1)
  373. if helpVo and not endVo then
  374. GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
  375. else
  376. if self.cur_vo and self.cur_vo.ignore_auto_task then
  377. else
  378. -- if not self.cur_vo.is_angry then--怒气技能不继续做任务
  379. --当前没有引导才继续做任务
  380. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK)
  381. -- end
  382. local task_data = TaskModel:getInstance():GetMainTask()
  383. if self.need_close_task and task_data and task_data.id > 0 then
  384. GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK) --启动自动任务
  385. end
  386. end
  387. end
  388. -- end
  389. -- self:ReShowFightingUp()
  390. -- local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.NEW_FUNC_OPEN,1)
  391. -- or GuideModel:getInstance():GetHelpVo(HelpType.NEW_FUNC_OPEN,2)
  392. -- if helpVo then
  393. -- GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
  394. -- end
  395. end
  396. function NewFuncOpenView:DestroySuccess( )
  397. self.model.is_open_func_model_view = false
  398. self:ClearUIEffect(self.effect)
  399. if self.tween_id then
  400. TweenLite.Stop(self.tween_id)
  401. self.tween_id = nil
  402. end
  403. if self.time_id then
  404. GlobalTimerQuest:CancelQuest(self.time_id)
  405. self.time_id = nil
  406. end
  407. FosterModel:GetInstance().wait_new_func_open = false
  408. GlobalEventSystem:Fire(EventName.BOARD_CLOSE_FUNC_OPEN_VIEW)
  409. if self.cur_vo and self.cur_vo.winId == 157 and self.cur_vo.subId == 0 then
  410. TaskModel.getInstance():ShowMainLineTips(true)
  411. end
  412. end