local UICharacterTeamLevelUp = UIViewClass() local UIShowGsChangeDurationTime = 0.25 -- 展示旧战力和额外战力时间 local UIChangeGsDurationTime = 1 -- 战力变化持续时间 local UIHideGsDurationTime = UIShowGsChangeDurationTime + UIChangeGsDurationTime -- 隐藏额外战力时间 local UIHideCurGsDurationTime = UIHideGsDurationTime + UIChangeGsDurationTime -- 展示新战力时间 local UIChangeFrequency = 0.02 -- 战力变化频率 local POP_VIEW_CLOSE_TIME = 0.1 function UICharacterTeamLevelUp:OnOpened(context) if context.timeSinceUpdate and context.timeSinceUpdate > POP_VIEW_CLOSE_TIME then context.timeSinceUpdate = nil self:CloseView() return end ---在prefab中勾选playOnStartup的话,在界面播放动画的时候回屏蔽所有点击,导致无法响应UIHeroLevelUp界面的OnPointerUp事件 ---这里手动调一下动画,防止上述事情的发生 self.group_Bottom:PlayAnim() self:StartRepeatFunc(self.OnUpdateFun, 0) self.newGsNum = context[1] self.oldGsNum = context[2] self.addGsNum = self.newGsNum - self.oldGsNum UIUtils.SetLabel(self.Txt_MainNum, tostring(self.oldGsNum)) UIUtils.SetLabel(self.Txt_AddNum, "+"..tostring(self.addGsNum)) if self.loc_Zhanli.CurState == 0 then UIUtils.SetLocalizationImage(self.sprint_Level, "zdlts_msz_zl.png") end CTL.Sound.PlayGameSound("UI_mvp") end function UICharacterTeamLevelUp:HideAddedGs() UIUtils.SetLabel(self.Txt_MainNum, tostring(self.newGsNum)) UIUtils.SetActive(self.Txt_AddNum, false) end function UICharacterTeamLevelUp:HideCurrentGs() UIUtils.SetActive(self.Txt_MainNum, false) end function UICharacterTeamLevelUp:OnUpdateFun(deltaTime, timeSinceUpdate) self.context.timeSinceUpdate = timeSinceUpdate if timeSinceUpdate >= UIHideCurGsDurationTime then self:HideCurrentGs() self:CloseView() elseif timeSinceUpdate >= UIHideGsDurationTime then self.Txt_MainNum.text = self.newGsNum elseif timeSinceUpdate >= UIShowGsChangeDurationTime then local ratio = (timeSinceUpdate - UIShowGsChangeDurationTime) / UIChangeGsDurationTime self.Txt_MainNum.text = math.ceil(self.oldGsNum + ratio * self.addGsNum) end end return UICharacterTeamLevelUp