源战役客户端
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.

285 rivejä
11 KiB

1 kuukausi sitten
  1. -- <*
  2. -- @Author: Saber
  3. -- @Description: 转职成功后弹出界面
  4. -- *>
  5. ReinSucceedView = ReinSucceedView or BaseClass(BaseView)
  6. local ReinSucceedView = ReinSucceedView
  7. local SetSizeDeltaY = SetSizeDeltaY
  8. local SetAnchoredPositionX = SetAnchoredPositionX
  9. function ReinSucceedView:__init()
  10. self.base_file = "reincarnation"
  11. self.layout_file = "ReinSucceedView"
  12. self.layer_name = "Activity"
  13. self.destroy_imm = true
  14. self.use_background = true --全屏界面默认使用这个参数
  15. self.hide_maincancas = true
  16. self.use_show_anim = true
  17. self.use_hide_anim = true
  18. self.change_scene_close = true --是否切换场景时关闭(弹出界面使用)
  19. self.append_to_ctl_queue = true --是否要添加进界面堆栈
  20. self.close_fog = true
  21. self.click_bg_toClose = true
  22. self.close_delay_time = 60 -- 几秒后自动关闭
  23. self.model = ReincarnationModel:getInstance()
  24. self.main_vo = RoleManager.Instance.mainRoleInfo
  25. self.rein_lv = 1
  26. self.rein_stage_cfg = {} -- 当前转生等级的阶段任务属性配置
  27. self.skill_item = {} -- 界面中的技能图标
  28. self.equip_item = {} -- 界面中的技能图标
  29. self.role_img_pos = {
  30. [1] = Vector2(-314.5, 11),
  31. [2] = Vector2(-359.5, 0),
  32. [3] = Vector2(-211, 9.5),
  33. [4] = Vector2(-350, 0),
  34. }
  35. self.load_callback = function ()
  36. self:LoadSuccess()
  37. self:AddEvent()
  38. end
  39. self.open_callback = function ( )
  40. self:UpdateView()
  41. end
  42. self.destroy_callback = function ( )
  43. self:DestroySuccess()
  44. end
  45. end
  46. function ReinSucceedView:Open(rein_lv)
  47. self.rein_lv = rein_lv
  48. self.rein_stage_cfg = self.model:GetReinLvStageData(self.rein_lv)
  49. BaseView.Open(self)
  50. end
  51. function ReinSucceedView:LoadSuccess()
  52. local nodes = {
  53. "bg:raw",
  54. -- 左侧立绘
  55. "role_con:rawex",
  56. -- 右侧信息部分,分为动画父节点和内部的信息节点
  57. -- 转职头像和名称
  58. "head_anim_con:cg",
  59. "head_anim_con/head_before_bg/head_before:raw",
  60. "head_anim_con/head_new_bg/head_new:raw",
  61. "head_anim_con/pname_before:tmp", "head_anim_con/pname_new:tmp",
  62. -- 属性节点和技能解锁容器
  63. "attr_skill_anim_con:cg",
  64. "attr_skill_anim_con/attr_scroll", "attr_skill_anim_con/attr_scroll/Viewport/attr_con",
  65. "attr_skill_anim_con/skill_con",
  66. -- 装备代数解锁容器
  67. "equip_anim_con:cg",
  68. "equip_anim_con/equip_con", "equip_anim_con/title3:tmp",
  69. -- 关闭倒计时
  70. "timer:tmp",
  71. }
  72. self:GetChildren(nodes)
  73. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("rein_succeed_bg"))
  74. end
  75. function ReinSucceedView:AddEvent()
  76. end
  77. function ReinSucceedView:UpdateView()
  78. self:UpdateRoleRP() -- 更新立绘
  79. self:UpdateRoleHead() -- 更新头像相关
  80. self:UpdateAttrData() -- 更新战斗力和属性
  81. self:UpdateUnlockItems() -- 更新新增技能
  82. self:StartReinSucceedAnim()
  83. self:StartCloseTimer()
  84. end
  85. -- 更新立绘
  86. function ReinSucceedView:UpdateRoleRP( )
  87. -- 加载立绘
  88. self.role_con_rawex.alpha = 0
  89. lua_resM:setOutsideRawImage(self, self.role_con_rawex, GameResPath.GetRoleBg("rein_success_role" .. self.main_vo.career), true)
  90. end
  91. -- 更新转职系统头像
  92. function ReinSucceedView:UpdateRoleHead( )
  93. -- 先获取上个转职阶段的默认头像
  94. local career_cfg = self.model:GetReinCareerHeadData(self.main_vo.career, self.rein_lv - 1)
  95. lua_resM:setOutsideRawImage(self, self.head_before_raw, GameResPath.GetHeadIcon(career_cfg and career_cfg.image_id or 1001))
  96. self.pname_before_tmp.text = career_cfg and Trim(career_cfg.name) or ""
  97. -- 获取当前转职的头像
  98. career_cfg = self.model:GetReinCareerHeadData(self.main_vo.career, self.rein_lv)
  99. lua_resM:setOutsideRawImage(self, self.head_new_raw, GameResPath.GetHeadIcon(career_cfg and career_cfg.image_id or 1001))
  100. self.pname_new_tmp.text = career_cfg and Trim(career_cfg.name) or ""
  101. end
  102. -- 更新转职属性提升数据
  103. function ReinSucceedView:UpdateAttrData( )
  104. -- 获取配置
  105. local attr_list = stringtotable(self.rein_stage_cfg[#self.rein_stage_cfg].attr_list)
  106. attr_list = SortAttrList(attr_list)
  107. self.attr_item_creator = self.attr_item_creator or self:AddUIComponent(UI.ItemListCreator)
  108. local info = {
  109. data_list = attr_list,
  110. scroll_view = self.attr_scroll,
  111. item_con = self.attr_con,
  112. prefab_ab_name = "reincarnation",
  113. prefab_res_name = "ReinSucceedAttrItem",
  114. item_height = 30,
  115. create_frequency = 0.01,
  116. alignment = UnityEngine.TextAnchor.UpperLeft,
  117. child_names = {"attr_name:tmp", "attr_up:tmp"},
  118. on_update_item = function(item, i, v)
  119. item.attr_name_tmp.text = WordManager:GetProperties(v[1])
  120. item.attr_up_tmp.text = WordManager:GetPropertyValue(v[1], v[2])
  121. end,
  122. }
  123. self.attr_item_creator:UpdateItems(info)
  124. end
  125. -- 更新转职解锁内容
  126. function ReinSucceedView:UpdateUnlockItems( )
  127. local unlock_data = self.model:GetReinSucceedUnlockData(self.rein_lv)
  128. -- 解锁的技能
  129. for k, v in ipairs(unlock_data.skill_list) do
  130. self.skill_item[k] = self.skill_item[k] or ReinTaskSkillItem.New(self.skill_con)
  131. self.skill_item[k]:SetTransformSize(62)
  132. local row, col = (k - 1) % 4, math.floor((k - 1) / 4)
  133. self.skill_item[k]:SetAnchoredPosition(81.5 * row, -74 * col)
  134. self.skill_item[k]:SetData(v.skill_data)
  135. end
  136. -- 解锁的装备
  137. for k, v in ipairs(unlock_data.equip_list) do
  138. self.equip_item[k] = self.equip_item[k] or UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.equip_con)
  139. self.equip_item[k]:SetAnchoredPosition((k - 1) * 78 + 9, 0)
  140. self.equip_item[k]:SetItemSize(62, 62)
  141. self.equip_item[k]:SetVisible(true)
  142. self.equip_item[k]:SetData(v.equip_data)
  143. end
  144. -- 装备栏标题
  145. self.title3_tmp.text = string.format("解锁 %s代装备", ChineseNumber(unlock_data.equip_series))
  146. end
  147. -- 播放界面动画效果
  148. function ReinSucceedView:StartReinSucceedAnim( )
  149. local bg_action_time = 0.5
  150. local bg_action_delay_time = 0.8
  151. local role_rp_action_time = 0.5
  152. local right_info_delay = 0.2
  153. local head_action_time = 0.5
  154. local a_s_action_time = 0.5
  155. local equip_action_time = 0.5
  156. local function east_func(percent)
  157. percent = percent - 1.0
  158. local real_pec = percent * percent * percent * percent * percent + 1
  159. return real_pec
  160. end
  161. -- 背景图恢复效果
  162. local target_bg_size_y = 501
  163. local function bg_size_y_func(percent)
  164. percent = east_func(percent)
  165. SetSizeDeltaY(self.bg, target_bg_size_y * percent)
  166. end
  167. local bg_action = cc.Sequence.New(cc.DelayTime.New(bg_action_delay_time), cc.CustomUpdate.New(bg_action_time, bg_size_y_func))
  168. cc.ActionManager:getInstance():addAction(bg_action, self.bg)
  169. -- 左侧立绘淡入和位移
  170. local pos = self.role_img_pos[self.main_vo.career]
  171. SetAnchoredPosition(self.role_con, pos.x - 300, pos.y)
  172. local function role_rp_action_func(percent)
  173. percent = east_func(percent)
  174. self.role_con_rawex.alpha = percent
  175. SetAnchoredPositionX(self.role_con, pos.x - 300 * (1 - percent))
  176. end
  177. local role_rp_action = cc.Sequence.New(
  178. cc.DelayTime.New(bg_action_delay_time + bg_action_time),
  179. cc.CustomUpdate.New(role_rp_action_time, role_rp_action_func)
  180. )
  181. cc.ActionManager:getInstance():addAction(role_rp_action, self.role_con)
  182. -- 右侧信息淡入和位移
  183. -- (自上而下)头像框
  184. local head_pos_x = 249
  185. SetAnchoredPositionX(self.head_anim_con, head_pos_x + 200)
  186. local function head_action_func(percent)
  187. percent = east_func(percent)
  188. self.head_anim_con_cg.alpha = percent
  189. SetAnchoredPositionX(self.head_anim_con, head_pos_x + 200 * (1 - percent))
  190. end
  191. local head_action = cc.Sequence.New(
  192. cc.DelayTime.New(bg_action_delay_time + bg_action_time),
  193. cc.CustomUpdate.New(head_action_time, head_action_func)
  194. )
  195. cc.ActionManager:getInstance():addAction(head_action, self.head_anim_con)
  196. -- 属性和技能解锁
  197. local a_s_pos_x = 249
  198. SetAnchoredPositionX(self.attr_skill_anim_con, a_s_pos_x + 200)
  199. local function attr_skill_action_func(percent)
  200. percent = east_func(percent)
  201. self.attr_skill_anim_con_cg.alpha = percent
  202. SetAnchoredPositionX(self.attr_skill_anim_con, a_s_pos_x + 200 * (1 - percent))
  203. end
  204. local a_s_action = cc.Sequence.New(
  205. cc.DelayTime.New(bg_action_delay_time + bg_action_time + right_info_delay),
  206. cc.CustomUpdate.New(a_s_action_time, attr_skill_action_func)
  207. )
  208. cc.ActionManager:getInstance():addAction(a_s_action, self.attr_skill_anim_con)
  209. -- 装备代数
  210. local equip_pos_x = 249
  211. SetAnchoredPositionX(self.equip_anim_con, equip_pos_x + 200)
  212. local function equip_action_func(percent)
  213. percent = east_func(percent)
  214. self.equip_anim_con_cg.alpha = percent
  215. SetAnchoredPositionX(self.equip_anim_con, equip_pos_x + 200 * (1 - percent))
  216. end
  217. local equip_action = cc.Sequence.New(
  218. cc.DelayTime.New(bg_action_delay_time + bg_action_time + right_info_delay * 2),
  219. cc.CustomUpdate.New(equip_action_time, equip_action_func)
  220. )
  221. cc.ActionManager:getInstance():addAction(equip_action, self.equip_anim_con)
  222. end
  223. -- 开始倒计时
  224. function ReinSucceedView:StartCloseTimer( )
  225. local end_time = Status.NowTime + self.close_delay_time
  226. if self.close_timer_id == nil then
  227. local function timer_func()
  228. local left_time = end_time - Status.NowTime
  229. if left_time >= 0 then
  230. self.timer_tmp.text = string.format("<color=#2cf86f>%d</color> 秒后自动关闭", left_time)
  231. else
  232. if self.close_timer_id then
  233. GlobalTimerQuest:CancelQuest(self.close_timer_id)
  234. self.close_timer_id = nil
  235. end
  236. self:Close()
  237. end
  238. end
  239. self.close_timer_id = GlobalTimerQuest:AddPeriodQuest(timer_func, 0.5, -1)
  240. timer_func()
  241. end
  242. end
  243. function ReinSucceedView:DestroySuccess( )
  244. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.bg)
  245. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.head_anim_con)
  246. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.role_con)
  247. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.attr_skill_anim_con)
  248. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.equip_anim_con)
  249. self:CheckGuide()
  250. for k, v in pairs(self.skill_item) do
  251. v:DeleteMe()
  252. v = nil
  253. end
  254. for k, v in pairs(self.equip_item) do
  255. UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, v)
  256. end
  257. self.equip_item = {}
  258. if self.close_timer_id then
  259. GlobalTimerQuest:CancelQuest(self.close_timer_id)
  260. self.close_timer_id = nil
  261. end
  262. end
  263. --触发套装引导
  264. function ReinSucceedView:CheckGuide( )
  265. local guide_key = ReincarnationConst.GuideKey[self.rein_lv]
  266. if guide_key then
  267. GlobalEventSystem:Fire(EventName.TEST_HELP_STEP,guide_key)
  268. end
  269. end