local UIFunctionUnlockShow = UIViewClass() local EventSystem = require('Event/EventSystem') local WAIT_TIME = 1 --开始播放动效等待的时间 local MOVE_TIME = 2.3 --开始移动等待的时间 local CLOSE_TIME = 3.5 --界面持续的时间 local MOVE_DURATION = 0.5 --移动的时间 local EFFECT_TIME = 2.6 --播结束特效等待的时间 local OFFSET_EFFECT_Y = -180--特效位置Y轴偏移 function UIFunctionUnlockShow:OnOpened(context) self.tarNode = self.context.Node self:StartRepeatFunc(self.OnDelayExcute, 0.05, 1) end function UIFunctionUnlockShow:OnDelayExcute() self:InitIcon(self.context.Config) end function UIFunctionUnlockShow:InitIcon(config) --查找对应的节点 local homeMainTrans = UIManager.FindViewTransform(Const_UI_Lua.UIEnum.UIHomeMain, nil, false) if homeMainTrans then local node = UTL.UIRender.FindInChildren(homeMainTrans, config.FlyButton) self.tarNode = node end if self.tarNode == nil then logging.error(LTAG.ERROR, "功能解锁表现找不到这个节点,请策划检查节点名字", config.FlyButton) self:CloseView() return end --先将对应的节点设置不可见,scaleX设为0 UIUtils.SetActive(self.tarNode, true) self.tarNode:SetLocalScale(0, 1, 1) self:RegistSystemEvent(EventID.UI_FunctionNotice_BreakExp, self.OnExpBreak) UIUtils.SetImageByAssetBundle(self.img_icon, config.FunctionIcon) UIUtils.SetLabelText(self.txt_NewFunctionName, Const_IDS[config.FunctionName]) self:StartRepeatFunc(self.OnUpdateFun, 0.1) CTL.Sound.PlayGameSound("UI_deblock") end function UIFunctionUnlockShow:OnExpBreak() CTL.FunctionNotice.DelayUnlockExp() self:CloseView() end function UIFunctionUnlockShow:MoveToTarget() local target = self.tarNode if target == nil then return end local oriParent = self.group_anim.parent self.group_anim:SetParent(target, false) self.group_anim:SetParent(oriParent, true) local targetX, targetY, _ = self.group_anim:GetLocalPosition() self.group_anim:SetLocalPosition(0, 0, 0) self.group_anim:SetLocalScale(1, 1, 1) self.uieffect_finish.transform:SetLocalPosition(targetX, targetY + OFFSET_EFFECT_Y, 0) self.moveAnim = self:MoveToPos(self.group_anim, targetX, targetY, MOVE_DURATION, false) end function UIFunctionUnlockShow:OnUpdateFun(deltaTime, timeSinceUpdate) if timeSinceUpdate >= WAIT_TIME and self.expAnim == nil then self.expAnim = self:PlayUIAnimation("UIAinmationZoom", false) end if timeSinceUpdate >= MOVE_TIME and self.moveAnim == nil then self:MoveToTarget() end if timeSinceUpdate >= EFFECT_TIME and self.hasPlayEffect == nil then self.hasPlayEffect = true self.uieffect_finish:PlayUIEffect() CTL.Sound.PlayGameSound("UI_deblock_add") end if timeSinceUpdate >= CLOSE_TIME then self:SetTargetAndClose() end end function UIFunctionUnlockShow:SetTargetAndClose() MDL.FunctionNotice.RemoveExpInfo(self.context.Config) self:CloseView() if self.tarNode ~= nil then self.tarNode:SetLocalScale(1, 1, 1) end EventSystem.Dispatch(EventID.UI_UpdateFunctionNoticeExpEnd) end return UIFunctionUnlockShow