local UIExpelMonsterBattle = UIViewClass() local floor = math.floor function UIExpelMonsterBattle:OnCreated() UIUtils.SetActive(self.group_Bossdamage.gameObject, false) UIUtils.SetActive(self.group_HeroTips.gameObject, false) end function UIExpelMonsterBattle:OnOpened(context) self:RegistSystemEvent(EventID.UIBattle_Level_OnBossBorn, self.OnBossBorn) self:RegistSystemEvent(EventID.UI_ExpelMonster_BossTips, self.OnBossTips) self:RegistSystemEvent(EventID.UIBattle_BossHPChanged, self.OnUpdateDmg) self:RegistSystemEvent(EventID.UIBattle_Level_SetUpBoss, self.SetUpBoss) self.comboViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleCombo), {isShowComboType = LuaConst.ComboType.Default}) self.dmgRecord = MDL.ExpelMonster.GetTodayMaxDamage() self.txt_NumberRecord.text = self.dmgRecord self.txt_NumberNow.text = 0 self.rewardBox1Num = 0 self.rewardBox2Num = 0 self.rewardBox3Num = 0 self.curLevel = 0 self.damageGroupID = CTL.ExpelMonster.GetDamageGroupID() self.isRewardMax = false self.curDmg = 0 self.bossHp = 1 self:StartRepeatFunc(self.OnUpdateFun, 1) self:RefreshRewardProgross() if not BattleDataGetter.IsReplayBattle() then self.subViewRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleMissionPanel)) end end function UIExpelMonsterBattle:OnUpdateFun(deltaTime, timeSinceUpdate) local curTimer = BattleDataGetter.GetRemainTime() UIUtils.SetLabel(self.txt_time, UTL.Time.FormatTimeBySeconds(curTimer)) local floorTimer = math.floor(curTimer) if floorTimer > 0 and floorTimer < 6 then UIUtils.SetActive(self.CountDown, true) self.number.text = floorTimer self.CountDownShowed = true CTL.Sound.PlayCountDown(floorTimer, true) elseif self.CountDownShowed or curTimer <= 0 then UIUtils.SetActive(self.CountDown, false) self.CountDownShowed = false end end function UIExpelMonsterBattle:OnBossBorn(entity) self.lifebarview = self.bossHPRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDemonGodBossHp), {entityID = entity.EntityID}, "GuildBoss/UIGuildBossBattleView") local mainBoss = BattleDataGetter.GetMainBoss() if mainBoss then self.bossHp = mainBoss:GetAttrValueNum("hplmt") --最大血量 end self:OnUpdateDmg() end function UIExpelMonsterBattle:SetUpBoss(active, monsterId, entityID) if active then self.lifebarview:ActiveUI({entityID = entityID}) else self.lifebarview:HideUI() end end function UIExpelMonsterBattle:OnUpdateDmg() self.curDmg = floor(BattleDataGetter.GetMyDamageToBoss()) self.txt_NumberNow.text = self.curDmg if self.curDmg > self.dmgRecord then self.dmgRecord = self.curDmg self.txt_NumberRecord.text = self.curDmg end self:RefreshRewardProgross() self:RefreshRewardBox() end function UIExpelMonsterBattle:OnBossTips(tipsType, ids) local rootGo local textComp if tipsType == 1 then rootGo = self.group_Bossdamage.gameObject textComp = self.txt_Bossdamage elseif tipsType == 2 then rootGo = self.group_HeroTips.gameObject textComp = self.txt_HeroTips else logging.error(LTAG.ERROR, "HYW : tipsType bad value!") return end if string.isNilOrEmpty(ids) then UIUtils.SetActive(rootGo, false) else UIUtils.SetActive(rootGo, true) UIUtils.SetLabelText(textComp, Const_IDS[ids]) end end function UIExpelMonsterBattle:RefreshRewardBox() if self.isRewardMax then return end local damageNumber = self.curDmg / self.bossHp local level = self.curLevel + 1 local succ, data = DataSheetManager.ActivityBossFightDamageReward:TryGetDataByDamageGroupID_ChildID(self.damageGroupID, level) if succ then if damageNumber >= data.DamageNumber then self.Effect_RewardGet:PlayUIEffect() if data.BoxReward == 1 then self.rewardBox1Num = self.rewardBox1Num + 1 elseif data.BoxReward == 2 then self.rewardBox2Num = self.rewardBox2Num + 1 elseif data.BoxReward == 3 then self.rewardBox3Num = self.rewardBox3Num + 1 end self.curLevel = self.curLevel + 1 self:RefreshRewardProgross() self:RefreshRewardBox() end else self.isRewardMax = true end end function UIExpelMonsterBattle:RefreshRewardProgross() --宝箱数量 self.Num1.text = "X"..self.rewardBox1Num self.Num2.text = "X"..self.rewardBox2Num self.Num3.text = "X"..self.rewardBox3Num --宝箱进度 if self.curLevel == 0 then local cfg = DataSheetManager.ActivityBossFightDamageReward:GetDataByDamageGroupID_ChildID(self.damageGroupID, 1) self.slider_Score.value = self.curDmg / (self.bossHp*cfg.DamageNumber) local boxIcon = DataSheetManager.ActivityBossFightBox:GetDataByBoxReward(cfg.BoxReward).BoxIcon UIUtils.SetImageByAssetBundle(self.img_Item, boxIcon) else local cfg = DataSheetManager.ActivityBossFightDamageReward:GetDataByDamageGroupID_ChildID(self.damageGroupID, self.curLevel) local succ, nextCfg = DataSheetManager.ActivityBossFightDamageReward:TryGetDataByDamageGroupID_ChildID(self.damageGroupID, self.curLevel + 1) if succ then self.slider_Score.value = (self.curDmg - self.bossHp*cfg.DamageNumber) / (self.bossHp*nextCfg.DamageNumber - self.bossHp*cfg.DamageNumber) local boxIcon = DataSheetManager.ActivityBossFightBox:GetDataByBoxReward(nextCfg.BoxReward).BoxIcon UIUtils.SetImageByAssetBundle(self.img_Item, boxIcon) else self.slider_Score.value = 1 end end end function UIExpelMonsterBattle:OnButtonClicked(comp) if comp == self.event_Setting then UIManager.OpenView(Const_UI_Lua.UIEnum.UISettingMainPanel) elseif comp == self.btn_Exit then CTL.Setting.BackToTown() end end return UIExpelMonsterBattle