源战役客户端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

374 righe
11 KiB

4 settimane fa
  1. NewerTaskMainView = NewerTaskMainView or BaseClass(BaseView)
  2. local NewerTaskMainView = NewerTaskMainView
  3. function NewerTaskMainView:__init()
  4. self.base_file = "newerTask"
  5. self.layout_file = "NewerTaskMainView"
  6. self.layer_name = "UI"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.change_scene_close = true
  10. self.append_to_ctl_queue = true --是否要添加进界面堆栈
  11. -- self.hide_maincancas = true
  12. self.need_show_money = false --是否要显示顶部的金钱栏
  13. self.close_fog = true
  14. self.ignore_use_anim = true
  15. self.use_show_anim = true
  16. self.use_hide_anim = false
  17. -- self.blur_activity_bg = true
  18. -- self:AddPreLoadList("newerTask", {"NewerTaskItem"})
  19. self.model = NewerTaskModel:getInstance()
  20. self.item_list = {}
  21. self.award_list = {}
  22. self.is_first_show = false --是否首次展示
  23. self.load_callback = function ()
  24. self:LoadSuccess()
  25. self:AddEvent()
  26. end
  27. self.open_callback = function ( )
  28. local help_vo = GuideModel:getInstance():GetCurHelpTypeAndStep()
  29. if help_vo then
  30. if (help_vo.help_type == HelpType.NEWER_TASK_AWARD_UNLOCK and help_vo.step == 2) then
  31. if help_vo.task_id == 10090 then
  32. self.is_first_show = true
  33. self.close_need_anim = true
  34. end
  35. GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
  36. end
  37. end
  38. self:OpenSuccess()
  39. end
  40. self.destroy_callback = function ( )
  41. self:DestroySuccess()
  42. end
  43. end
  44. function NewerTaskMainView:Open( auto_do_task )
  45. self.auto_do_task = auto_do_task
  46. BaseView.Open(self)
  47. end
  48. function NewerTaskMainView:Close( )
  49. self:OnCloseGuide()
  50. if not self.close_need_anim then
  51. self.use_hide_anim = true
  52. BaseView.Close(self)
  53. return
  54. end
  55. local target_pos = MainUIController.Instance:GetNewerTaskMotoPos( )
  56. target_pos.x = target_pos.x + 35
  57. target_pos.y = target_pos.y - 20
  58. local target_time = 0.3
  59. local target_scale = Vector3(0.1,0.1,0.1)
  60. local function call_back( )
  61. BaseView.Close(self)
  62. end
  63. TweenLite.to(self, self.transform, TweenLite.UiAnimationType.POS, target_pos, target_time)
  64. TweenLite.to(self, self.transform, TweenLite.UiAnimationType.SCALE, target_scale, target_time, call_back)
  65. TweenLite.to(self, self.bg.transform, TweenLite.UiAnimationType.POS, target_pos, target_time)
  66. TweenLite.to(self, self.bg.transform, TweenLite.UiAnimationType.SCALE, target_scale, target_time)
  67. self.model_parent_obj:SetActive(false)
  68. end
  69. function NewerTaskMainView:LoadSuccess()
  70. self.nodes = {
  71. "bg:raw", "close_btn:obj", "content",
  72. "model_parent:obj:raw", "title:img","line_cont:obj",
  73. "effect_1", "effect_3",
  74. "grey_img_1:obj", "grey_img_2:obj", "grey_img_3:obj", "grey_img_4:obj",
  75. }
  76. self:GetChildren(self.nodes)
  77. lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("newer_task_bg"),false)
  78. self:AddUIEffect("ui_motuoyindao01", self.effect_1, self.layer_name, nil, 1, true,nil,nil,nil,nil,nil,UIPartical.RenderingOther_List.UI)
  79. self:AddUIEffect("ui_motuoyindao03", self.effect_3, self.layer_name, {x=-177.7,y=-165.5}, {x=1,y=1,z=1}, true,nil,nil,nil,nil,nil,UIPartical.RenderingOther_List.UIBackward)
  80. -- self.line_list = {}
  81. -- for i=1,4 do
  82. -- self.line_list[i] = self.line_list[i] or {}
  83. -- local res_name = "line_cont/line_" .. i
  84. -- self.line_list[i].line_obj = self:GetChild(res_name).gameObject
  85. -- self.line_list[i].line_img = self:GetChild(res_name):GetComponent("Image")
  86. -- end
  87. local function bg_back_func( )
  88. -- 2021.7.14 界面修改为无模型
  89. -- if self.background_wnd and self.background_wnd_raw then
  90. -- self:MoveUIToBack(self.background_wnd)
  91. -- self:MoveUIToBack(self.bg)
  92. -- end
  93. end
  94. if self.background_wnd then
  95. bg_back_func()
  96. else
  97. self.bg_back_func = bg_back_func
  98. end
  99. end
  100. function NewerTaskMainView:AddEvent()
  101. local function on_click( obj )
  102. if obj == self.close_btn_obj then
  103. self:Close()
  104. end
  105. end
  106. AddClickEvent(self.close_btn_obj, on_click)
  107. local function on_award_update( )
  108. --摩托车切换到翅膀,也要播放首次动画
  109. local cur_type = self.model:GetCurShowType()
  110. if self.cur_type and cur_type ~= self.cur_type then
  111. self.is_first_show = true
  112. end
  113. self:UpdateView()
  114. end
  115. self:BindEvent(GlobalEventSystem, NewerTaskConst.UPDATE_AWARD_INFO, on_award_update)
  116. local function onGuideTrigger()
  117. self:OnTriggerGuide()
  118. end
  119. self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger)
  120. end
  121. function NewerTaskMainView:OpenSuccess()
  122. self:UpdateView()
  123. end
  124. function NewerTaskMainView:UpdateView()
  125. local info = self.model:GetCurShowInfo()
  126. if IsTableEmpty(info) then
  127. return
  128. end
  129. self.info = info
  130. --标题
  131. local cur_type = self.model:GetCurShowType()
  132. self.cur_type = cur_type
  133. local res_name = NewerTaskConst.TitleResName[cur_type]
  134. lua_resM:setImageSprite(self,self.title_img, "newerTask_asset", res_name)
  135. --模型
  136. self:OnUpdateModel(cur_type)
  137. --线条
  138. -- self.line_cont_obj:SetActive(not self.is_first_show)
  139. self.line_cont_obj:SetActive(true)
  140. -- for i=1,4 do
  141. -- local cfg = NewerTaskConst.LineInfo[i]
  142. -- SetAnchoredPosition(self.line_list[i].line_obj.transform, cfg.anchor_pos.x, cfg.anchor_pos.y)
  143. -- SetSizeDelta(self.line_list[i].line_obj.transform, cfg.size.x, cfg.size.y)
  144. -- end
  145. --进度
  146. -- self:OnUpdateProgress(cur_type)
  147. --解锁item/奖励图标
  148. for i=1,4 do
  149. if not self.item_list[i] then
  150. self.item_list[i] = NewerTaskItem.New(self.content)
  151. end
  152. self.item_list[i]:SetVisible(not self.is_first_show)
  153. self.item_list[i]:SetData(info[i], i, self.is_first_show, self.auto_do_task)
  154. local pos = NewerTaskConst.ItemPos[i]
  155. self.item_list[i]:SetPosition(pos.x, pos.y)
  156. -- 刷新主界面拼图状态
  157. local is_finished = self.model:IsAwardFinish(info[i].type, info[i].task_id)
  158. if is_finished then
  159. self["grey_img_" .. i .. "_obj"]:SetActive(false)
  160. else
  161. self["grey_img_" .. i .. "_obj"]:SetActive(true)
  162. end
  163. -- if not self.award_list[i] then
  164. -- self.award_list[i] = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.award_cont)
  165. -- end
  166. -- local award_vo = stringtotable(info[i].awards)
  167. -- award_vo = award_vo and award_vo[1] or {}
  168. -- local typeId, lock = GoodsModel:getInstance():GetMappingTypeId(award_vo[1], award_vo[2])
  169. -- self.award_list[i]:SetData(typeId, award_vo[3], nil, nil, lock)
  170. -- self.award_list[i]:SetItemSize(78, 78)
  171. -- self.award_list[i]:SetVisible(true)
  172. -- self.award_list[i]:SetPosition(237*(i-1), 0)
  173. end
  174. --首次打开的动画
  175. self:OnUpdateAnimation()
  176. end
  177. function NewerTaskMainView:OnUpdateModel( cur_type )
  178. if self.is_first_show then
  179. return
  180. end
  181. if self.last_model_type and self.last_model_type == cur_type then
  182. return
  183. end
  184. self.last_model_type = cur_type
  185. -- local model_res = NewerTaskConst.ModelImgRes[cur_type]
  186. -- lua_resM:setOutsideRawImage(self,self.model_img_raw,GameResPath.GetViewBigBg(model_res),true)
  187. local res_id, res_type = 1001, self.cur_type
  188. local temp_rotate = self.cur_type == 1 and 70 or 0
  189. local temp_scale = self.cur_type == 1 and 210 or 360
  190. local temp_position = self.cur_type == 1 and Vector3(-88,-67.5,725) or Vector3(0,110,0)
  191. local res_data = {
  192. father_node = self,
  193. transform = self.model_parent,
  194. fashion_type = res_type + 1000,
  195. figure_id = res_id,
  196. ui_model_type = UIModelCommon.ModelType.BackModel,
  197. can_rotate = false,
  198. action_name_list = {"show"},
  199. scale = temp_scale,
  200. rotate = temp_rotate,
  201. position = temp_position,
  202. }
  203. FuncOpenModel:getInstance():SetModelRes(res_data)
  204. end
  205. function NewerTaskMainView:OnUpdateProgress( cur_type )
  206. local cur_progress = self.model:GetProgress() or 0
  207. self.pro_bar_img.fillAmount = cur_progress/100
  208. end
  209. function NewerTaskMainView:OnUpdateAnimation( )
  210. if not self.is_first_show then
  211. return
  212. end
  213. self.is_first_show = false
  214. self:CancelAnimationTimer()
  215. self.anim_step = 1
  216. self.anim_pass_time = 0
  217. local step = 0.1
  218. local function on_animation( )
  219. self.anim_pass_time = self.anim_pass_time + step
  220. if self.anim_step == 1 then
  221. self.anim_step = 2
  222. self:OnAnimModel()
  223. elseif self.anim_pass_time > 0.1 and self.anim_step == 2 then
  224. self.anim_step = 3
  225. self:OnAnimItem(1)
  226. elseif self.anim_pass_time > 0.3 and self.anim_step == 3 then
  227. self.anim_step = 4
  228. self:OnAnimItem(2)
  229. elseif self.anim_pass_time > 0.5 and self.anim_step == 4 then
  230. self.anim_step = 5
  231. self:OnAnimItem(3)
  232. elseif self.anim_pass_time > 0.7 and self.anim_step == 5 then
  233. self.anim_step = 6
  234. self:OnAnimItem(4)
  235. elseif self.anim_pass_time > 0.9 and self.anim_step == 6 then
  236. self.anim_step = 7
  237. self:OnAnimImageModel()
  238. elseif self.anim_pass_time > 1.1 and self.anim_step == 7 then
  239. self.anim_step = 8
  240. self:OnLineShow()
  241. self:OnAnimUnLock()
  242. self:CancelAnimationTimer()
  243. end
  244. end
  245. self.animation_timer = GlobalTimerQuest:AddPeriodQuest(on_animation, step, -1)
  246. end
  247. function NewerTaskMainView:CancelAnimationTimer( )
  248. if self.animation_timer then
  249. GlobalTimerQuest:CancelQuest(self.animation_timer)
  250. self.animation_timer = nil
  251. end
  252. end
  253. function NewerTaskMainView:OnAnimModel( )
  254. local res_id, res_type = 1001, self.cur_type
  255. local temp_rotate = self.cur_type == 1 and 70 or 0
  256. local temp_scale = self.cur_type == 1 and 210 or 360
  257. local temp_position = self.cur_type == 1 and Vector3(-88,-67.5,725) or Vector3(0,110,0)
  258. local res_data = {
  259. father_node = self,
  260. transform = self.model_parent,
  261. fashion_type = res_type + 1000,
  262. figure_id = res_id,
  263. ui_model_type = UIModelCommon.ModelType.BackModel,
  264. can_rotate = false,
  265. action_name_list = {"show2","show"},
  266. scale = temp_scale,
  267. rotate = temp_rotate,
  268. position = temp_position,
  269. }
  270. FuncOpenModel:getInstance():SetModelRes(res_data)
  271. end
  272. function NewerTaskMainView:OnAnimItem(index)
  273. if self.item_list[index] then
  274. self.item_list[index]:OnAnimation()
  275. end
  276. end
  277. function NewerTaskMainView:OnAnimImageModel( )
  278. -- local model_res = NewerTaskConst.ModelImgRes[self.cur_type]
  279. -- lua_resM:setOutsideRawImage(self,self.model_img_raw,GameResPath.GetViewBigBg(model_res),true)
  280. -- self.model_parent_obj:SetActive(false)
  281. end
  282. function NewerTaskMainView:OnLineShow( )
  283. self.line_cont_obj:SetActive(true)
  284. end
  285. function NewerTaskMainView:OnAnimUnLock( )
  286. if self.item_list[1] then
  287. self.item_list[1]:OnUnLockHelper()
  288. end
  289. end
  290. function NewerTaskMainView:OnTriggerGuide( )
  291. if IsNull(self.gameObject) then
  292. return
  293. end
  294. local help_vo = GuideModel:getInstance():GetCurHelpTypeAndStep()
  295. if help_vo then
  296. if help_vo.help_type == HelpType.NEWER_TASK_AWARD_UNLOCK and help_vo.step == 3 then
  297. local button = self.close_btn_obj
  298. if button then
  299. local function call_back()
  300. self:Close()
  301. end
  302. GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW,button.transform,self.transform,call_back,help_vo)
  303. end
  304. end
  305. end
  306. end
  307. function NewerTaskMainView:OnCloseGuide( )
  308. local help_vo, help_type, step = GuideModel:getInstance():GetCurHelpTypeAndStep()
  309. if help_vo then
  310. if help_type == HelpType.NEWER_TASK_AWARD_UNLOCK then
  311. if step and step == 3 then
  312. GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,help_vo)
  313. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK)
  314. end
  315. end
  316. end
  317. GlobalEventSystem:Fire(EventName.CLOSE_GUIDE_PROMPT_VIEW)
  318. if self.auto_do_task then
  319. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK)
  320. end
  321. end
  322. function NewerTaskMainView:DestroySuccess( )
  323. for k,v in pairs(self.item_list) do
  324. v:DeleteMe()
  325. v = nil
  326. end
  327. self.item_list = {}
  328. for k,v in pairs(self.award_list) do
  329. UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, v)
  330. v = nil
  331. end
  332. self.award_list = {}
  333. self:CancelAnimationTimer()
  334. end