-- <* -- @Author: Saber -- @Description: 转职成功后弹出界面 -- *> ReinSucceedView = ReinSucceedView or BaseClass(BaseView) local ReinSucceedView = ReinSucceedView local SetSizeDeltaY = SetSizeDeltaY local SetAnchoredPositionX = SetAnchoredPositionX function ReinSucceedView:__init() self.base_file = "reincarnation" self.layout_file = "ReinSucceedView" self.layer_name = "Activity" self.destroy_imm = true self.use_background = true --全屏界面默认使用这个参数 self.hide_maincancas = true self.use_show_anim = true self.use_hide_anim = true self.change_scene_close = true --是否切换场景时关闭(弹出界面使用) self.append_to_ctl_queue = true --是否要添加进界面堆栈 self.close_fog = true self.click_bg_toClose = true self.close_delay_time = 60 -- 几秒后自动关闭 self.model = ReincarnationModel:getInstance() self.main_vo = RoleManager.Instance.mainRoleInfo self.rein_lv = 1 self.rein_stage_cfg = {} -- 当前转生等级的阶段任务属性配置 self.skill_item = {} -- 界面中的技能图标 self.equip_item = {} -- 界面中的技能图标 self.role_img_pos = { [1] = Vector2(-314.5, 11), [2] = Vector2(-359.5, 0), [3] = Vector2(-211, 9.5), [4] = Vector2(-350, 0), } self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:UpdateView() end self.destroy_callback = function ( ) self:DestroySuccess() end end function ReinSucceedView:Open(rein_lv) self.rein_lv = rein_lv self.rein_stage_cfg = self.model:GetReinLvStageData(self.rein_lv) BaseView.Open(self) end function ReinSucceedView:LoadSuccess() local nodes = { "bg:raw", -- 左侧立绘 "role_con:rawex", -- 右侧信息部分,分为动画父节点和内部的信息节点 -- 转职头像和名称 "head_anim_con:cg", "head_anim_con/head_before_bg/head_before:raw", "head_anim_con/head_new_bg/head_new:raw", "head_anim_con/pname_before:tmp", "head_anim_con/pname_new:tmp", -- 属性节点和技能解锁容器 "attr_skill_anim_con:cg", "attr_skill_anim_con/attr_scroll", "attr_skill_anim_con/attr_scroll/Viewport/attr_con", "attr_skill_anim_con/skill_con", -- 装备代数解锁容器 "equip_anim_con:cg", "equip_anim_con/equip_con", "equip_anim_con/title3:tmp", -- 关闭倒计时 "timer:tmp", } self:GetChildren(nodes) lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("rein_succeed_bg")) end function ReinSucceedView:AddEvent() end function ReinSucceedView:UpdateView() self:UpdateRoleRP() -- 更新立绘 self:UpdateRoleHead() -- 更新头像相关 self:UpdateAttrData() -- 更新战斗力和属性 self:UpdateUnlockItems() -- 更新新增技能 self:StartReinSucceedAnim() self:StartCloseTimer() end -- 更新立绘 function ReinSucceedView:UpdateRoleRP( ) -- 加载立绘 self.role_con_rawex.alpha = 0 lua_resM:setOutsideRawImage(self, self.role_con_rawex, GameResPath.GetRoleBg("rein_success_role" .. self.main_vo.career), true) end -- 更新转职系统头像 function ReinSucceedView:UpdateRoleHead( ) -- 先获取上个转职阶段的默认头像 local career_cfg = self.model:GetReinCareerHeadData(self.main_vo.career, self.rein_lv - 1) lua_resM:setOutsideRawImage(self, self.head_before_raw, GameResPath.GetHeadIcon(career_cfg and career_cfg.image_id or 1001)) self.pname_before_tmp.text = career_cfg and Trim(career_cfg.name) or "" -- 获取当前转职的头像 career_cfg = self.model:GetReinCareerHeadData(self.main_vo.career, self.rein_lv) lua_resM:setOutsideRawImage(self, self.head_new_raw, GameResPath.GetHeadIcon(career_cfg and career_cfg.image_id or 1001)) self.pname_new_tmp.text = career_cfg and Trim(career_cfg.name) or "" end -- 更新转职属性提升数据 function ReinSucceedView:UpdateAttrData( ) -- 获取配置 local attr_list = stringtotable(self.rein_stage_cfg[#self.rein_stage_cfg].attr_list) attr_list = SortAttrList(attr_list) self.attr_item_creator = self.attr_item_creator or self:AddUIComponent(UI.ItemListCreator) local info = { data_list = attr_list, scroll_view = self.attr_scroll, item_con = self.attr_con, prefab_ab_name = "reincarnation", prefab_res_name = "ReinSucceedAttrItem", item_height = 30, create_frequency = 0.01, alignment = UnityEngine.TextAnchor.UpperLeft, child_names = {"attr_name:tmp", "attr_up:tmp"}, on_update_item = function(item, i, v) item.attr_name_tmp.text = WordManager:GetProperties(v[1]) item.attr_up_tmp.text = WordManager:GetPropertyValue(v[1], v[2]) end, } self.attr_item_creator:UpdateItems(info) end -- 更新转职解锁内容 function ReinSucceedView:UpdateUnlockItems( ) local unlock_data = self.model:GetReinSucceedUnlockData(self.rein_lv) -- 解锁的技能 for k, v in ipairs(unlock_data.skill_list) do self.skill_item[k] = self.skill_item[k] or ReinTaskSkillItem.New(self.skill_con) self.skill_item[k]:SetTransformSize(62) local row, col = (k - 1) % 4, math.floor((k - 1) / 4) self.skill_item[k]:SetAnchoredPosition(81.5 * row, -74 * col) self.skill_item[k]:SetData(v.skill_data) end -- 解锁的装备 for k, v in ipairs(unlock_data.equip_list) do self.equip_item[k] = self.equip_item[k] or UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.equip_con) self.equip_item[k]:SetAnchoredPosition((k - 1) * 78 + 9, 0) self.equip_item[k]:SetItemSize(62, 62) self.equip_item[k]:SetVisible(true) self.equip_item[k]:SetData(v.equip_data) end -- 装备栏标题 self.title3_tmp.text = string.format("解锁 %s代装备", ChineseNumber(unlock_data.equip_series)) end -- 播放界面动画效果 function ReinSucceedView:StartReinSucceedAnim( ) local bg_action_time = 0.5 local bg_action_delay_time = 0.8 local role_rp_action_time = 0.5 local right_info_delay = 0.2 local head_action_time = 0.5 local a_s_action_time = 0.5 local equip_action_time = 0.5 local function east_func(percent) percent = percent - 1.0 local real_pec = percent * percent * percent * percent * percent + 1 return real_pec end -- 背景图恢复效果 local target_bg_size_y = 501 local function bg_size_y_func(percent) percent = east_func(percent) SetSizeDeltaY(self.bg, target_bg_size_y * percent) end local bg_action = cc.Sequence.New(cc.DelayTime.New(bg_action_delay_time), cc.CustomUpdate.New(bg_action_time, bg_size_y_func)) cc.ActionManager:getInstance():addAction(bg_action, self.bg) -- 左侧立绘淡入和位移 local pos = self.role_img_pos[self.main_vo.career] SetAnchoredPosition(self.role_con, pos.x - 300, pos.y) local function role_rp_action_func(percent) percent = east_func(percent) self.role_con_rawex.alpha = percent SetAnchoredPositionX(self.role_con, pos.x - 300 * (1 - percent)) end local role_rp_action = cc.Sequence.New( cc.DelayTime.New(bg_action_delay_time + bg_action_time), cc.CustomUpdate.New(role_rp_action_time, role_rp_action_func) ) cc.ActionManager:getInstance():addAction(role_rp_action, self.role_con) -- 右侧信息淡入和位移 -- (自上而下)头像框 local head_pos_x = 249 SetAnchoredPositionX(self.head_anim_con, head_pos_x + 200) local function head_action_func(percent) percent = east_func(percent) self.head_anim_con_cg.alpha = percent SetAnchoredPositionX(self.head_anim_con, head_pos_x + 200 * (1 - percent)) end local head_action = cc.Sequence.New( cc.DelayTime.New(bg_action_delay_time + bg_action_time), cc.CustomUpdate.New(head_action_time, head_action_func) ) cc.ActionManager:getInstance():addAction(head_action, self.head_anim_con) -- 属性和技能解锁 local a_s_pos_x = 249 SetAnchoredPositionX(self.attr_skill_anim_con, a_s_pos_x + 200) local function attr_skill_action_func(percent) percent = east_func(percent) self.attr_skill_anim_con_cg.alpha = percent SetAnchoredPositionX(self.attr_skill_anim_con, a_s_pos_x + 200 * (1 - percent)) end local a_s_action = cc.Sequence.New( cc.DelayTime.New(bg_action_delay_time + bg_action_time + right_info_delay), cc.CustomUpdate.New(a_s_action_time, attr_skill_action_func) ) cc.ActionManager:getInstance():addAction(a_s_action, self.attr_skill_anim_con) -- 装备代数 local equip_pos_x = 249 SetAnchoredPositionX(self.equip_anim_con, equip_pos_x + 200) local function equip_action_func(percent) percent = east_func(percent) self.equip_anim_con_cg.alpha = percent SetAnchoredPositionX(self.equip_anim_con, equip_pos_x + 200 * (1 - percent)) end local equip_action = cc.Sequence.New( cc.DelayTime.New(bg_action_delay_time + bg_action_time + right_info_delay * 2), cc.CustomUpdate.New(equip_action_time, equip_action_func) ) cc.ActionManager:getInstance():addAction(equip_action, self.equip_anim_con) end -- 开始倒计时 function ReinSucceedView:StartCloseTimer( ) local end_time = Status.NowTime + self.close_delay_time if self.close_timer_id == nil then local function timer_func() local left_time = end_time - Status.NowTime if left_time >= 0 then self.timer_tmp.text = string.format("%d 秒后自动关闭", left_time) else if self.close_timer_id then GlobalTimerQuest:CancelQuest(self.close_timer_id) self.close_timer_id = nil end self:Close() end end self.close_timer_id = GlobalTimerQuest:AddPeriodQuest(timer_func, 0.5, -1) timer_func() end end function ReinSucceedView:DestroySuccess( ) cc.ActionManager:getInstance():removeAllActionsFromTarget(self.bg) cc.ActionManager:getInstance():removeAllActionsFromTarget(self.head_anim_con) cc.ActionManager:getInstance():removeAllActionsFromTarget(self.role_con) cc.ActionManager:getInstance():removeAllActionsFromTarget(self.attr_skill_anim_con) cc.ActionManager:getInstance():removeAllActionsFromTarget(self.equip_anim_con) self:CheckGuide() for k, v in pairs(self.skill_item) do v:DeleteMe() v = nil end for k, v in pairs(self.equip_item) do UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, v) end self.equip_item = {} if self.close_timer_id then GlobalTimerQuest:CancelQuest(self.close_timer_id) self.close_timer_id = nil end end --触发套装引导 function ReinSucceedView:CheckGuide( ) local guide_key = ReincarnationConst.GuideKey[self.rein_lv] if guide_key then GlobalEventSystem:Fire(EventName.TEST_HELP_STEP,guide_key) end end