local UIBattleBossBattleInfoView = require("View/Battle/UIBattleBossBattleInfoView") local UIGuildBossBattleView = UIViewClass(UIBattleBossBattleInfoView) local HP_STYLE_COUNT = 3 --血条颜色变化数量 local ANIM_DURATION = 0.3 --不是多层血条 或者 多层血条最后一层的运动是时间 local ANIM_DURATION_QUICK = 0.1 -- 多层血条的最初血条运动时间 快速的消失 function UIGuildBossBattleView:OnOpened(context) self:RegistSystemEvent(EventID.UI_GuildBoss_Stagefresh, self.SetStage) self.hpValue1.text = "x??" self:SetStage() self.curBossHpLayer = 10 end function UIGuildBossBattleView:OnHPChanged(hp, layerHp , entityID, delta) if entityID == self.bindingEntityID then self:DoAnimation(hp, layerHp, delta) if hp <= 0 then self:CloseView() end end end function UIGuildBossBattleView:DoAnimation(hp, layerHp, delta) if not self.curHp then self.curHp = layerHp return end if delta then delta = - delta else delta = 0 end self.isDamage = delta > 0 if self.curBossHpLayer > 0 then -- 如果层数大于0 local nextLayerValue = 0 if delta - self.curHp > 0 then nextLayerValue = math.ceil( (delta - self.curHp) / layerHp) end if nextLayerValue > 0 then -- 当前伤害掉层数了 local scaleValue = (delta - self.curHp ) % layerHp / layerHp self.nextScaleValue = scaleValue --下一次动画 缩放比例 local targetDestinationPos = self.isDamage and 0 or 1 --- 因为掉层了 0.1秒把当前层缩放到0 然后在把下一层的动画开启 local playingID = self.hpAnimWithCallBack[self.curIndex] self:FinishUIAnimationByIndex(self.curIndex, false) self:FinishUIAnimationByIndex(self.curIndex, true) if playingID then self:ScaleToSize(playingID, targetDestinationPos, 1, ANIM_DURATION_QUICK) else playingID = self:ScaleToSize(self.hpGroup[self.curIndex].transform, targetDestinationPos, 1, ANIM_DURATION_QUICK, true) self.hpAnimWithCallBack[self.curIndex] = playingID end self.hpAnimWithCallBackParams[playingID] = scaleValue self.curHp = layerHp - (delta - self.curHp) else local scaleValue = (self.curHp - delta) / layerHp self.curHp = self.curHp - delta self:FinishUIAnimationByIndex(self.curIndex, true) if self.hpAnimSimple[self.curIndex] then self:ScaleToSize(self.hpAnimSimple[self.curIndex], scaleValue, 1, ANIM_DURATION) else self.hpAnimSimple[self.curIndex] = self:ScaleToSize(self.hpGroup[self.curIndex].transform, scaleValue, 1, ANIM_DURATION, false) end --将当前掉血的血条放到最上边 self.hpGroup[self.curIndex].transform:SetAsLastSibling() end end end function UIGuildBossBattleView:SetStage() local curStateTimeInfo = MDL.GuildBoss.GetCurStateTimeInfo() if curStateTimeInfo.stageOrder > MDL.GuildBoss.Stage.Ready and curStateTimeInfo.stageOrder <= MDL.GuildBoss.Stage.Fight3 then local bossStage = DataSheetManager.GuildBossStage:GetDataByID_Order(1,curStateTimeInfo.stageOrder) UIUtils.SetLabelText(self.BossName, Const_IDS[bossStage.PhaseName]) local timeStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildBoss_PhaseCountdown) local time = curStateTimeInfo.stageEndTimeStamp - UTL.Time.GetServerTimestamp() self.lab_Info:ResetAndBeginCustomTimer(false,time,0,timeStr,1) end end return UIGuildBossBattleView