local UIGoldenHeroBossMain = UIViewClass() local EventSystem = require('Event/EventSystem') local timeHintText = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_Help_Hint12) local Common2DScenePrefab = ConstAssetPathConfig.Common2DScenePrefab local SweepTipsTime = "SweepTipsTime_Key" local function StringFormat(ids) return string.format(timeHintText, UIUtils.GetLocalizedTxt(Const_IDS[ids])) end function UIGoldenHeroBossMain:OnOpened(context) self.heroType = context.heroType self.activityId = context.activityId self.activityType = MDL.OperationActivity.ActivityType.GoldenHero local heroTypeData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType) --标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[heroTypeData.BossName]) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_UpdateSupportCD, self.SetShareCD) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_LocateBoss, self.LocateBossCell) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_RefreshFilter, self.ShowBossList) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_UpdateNewBoss, self.InsertBossCell) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_UpdateExistBoss, self.UpdateBossCell) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_UpdateDeadBoss, self.RemoveBossCell) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_UpdateExpiredBoss, self.RemoveBossCell) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_RefreshRankData, self.RefreshSelfRank) self:RegistSystemEvent(EventID.UI_GoldenHeroBoss_RefreshDailyPoint, self.RefreshSelfRank) self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].BossPointReward, self.RefreshDailyRewardRedPoint) -- 金将体验关入口红点 self:RegistSystemEvent(CTL.GoldenHeroMain.RpEventId[self.activityId].BossFindReward, self.RefreshFindRewardRedPoint) -- 金将体验关入口红点 self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.BossShowScene) CTL.GoldenHeroBoss.SetItemEnoughRedPoint(self.activityId) CTL.GoldenHeroMain.OpenCurrencyPanel(self.heroType, self.__viewClassPath, self.currency_Info, {activityType = self.activityType, activityId = self.activityId, energyType = MDL.GoldenHeroMain.EnergyType.Boss, title = "IDS_DrawCard_Title_QuickBuy"}) UIUtils.SetLabelText(self.lab_NoBossHint, Const_IDS.IDS_GoldHeroActivity_SynergyBoss_NoneHint) UIUtils.SetLabelText(self.group_SeekHelp.lab_NoFriend, Const_IDS.IDS_Achievement_Share_NoFriend) UIUtils.SetLabelText(self.group_SeekHelp.lab_NoGuild, Const_IDS.IDS_GoldHeroActivity_SynergyBoss_Help_Hint8) self.group_SeekHelp.timer_WorldSupportCD:SetDHMSStr(StringFormat("IDS_PreviewTime1"), StringFormat("IDS_PreviewTime2"), StringFormat("IDS_PreviewTime3"), StringFormat("IDS_PreviewTime4")) self.group_SeekHelp.timer_GuildSupportCD:SetDHMSStr(StringFormat("IDS_PreviewTime1"), StringFormat("IDS_PreviewTime2"), StringFormat("IDS_PreviewTime3"), StringFormat("IDS_PreviewTime4")) if context.bossId then local bossInfo = MDL.GoldenHeroBoss.GetBossInfoByBossId(self.activityId, context.bossId) if bossInfo then self.group_BossTab:SelectIndex(bossInfo.finder == BattleDataGetter.GetAcID() and 0 or 1) else self.group_BossTab:SelectIndex(context.tabIndex) end else self.group_BossTab:SelectIndex(0) end self:RefreshEndTime() self:RefreshDailyRewardRedPoint(MDL.RedPoint.GetNodeStateByLogicParams(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].BossPointReward)) self:RefreshFindRewardRedPoint(MDL.RedPoint.GetNodeStateByLogicParams(CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].BossFindReward)) MDL.RedPoint.UpdateNodeStateByLogicParams(false, CTL.GoldenHeroMain.RpEventId[self.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[self.activityId].BossLogin) UIManager.ActiveUIModle(false, "UIGoldenHeroBossMain") MDL.GoldenHeroBoss.GoldHeroGetRankRecordReq(self.activityId, MDL.GoldenHeroBoss.BossRankType.SynergyBossTotalRank) self:StartRepeatFunc(function() MDL.GoldenHeroBoss.GoldHeroGetRankRecordReq(self.activityId, MDL.GoldenHeroBoss.BossRankType.SynergyBossTotalRank) end, 300, -1) end function UIGoldenHeroBossMain:RefreshEndTime() local timeId = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).DailyRankEndTime self.group_BossInfo.txt_TimeHint.text = string.FormatByIdsKey("IDS_GoldHeroActivity_NewHint_3", UTL.Time.GetDiffLocalStrById(timeId)) local deltaTime = UTL.Time.GetServerIntervalTimeByTimeId(timeId) if UTL.Time.IsServerInOpeningTime(1, timeId) then self:StartRepeatFunc(self.RefreshEndTime, math.abs(deltaTime), 1) self.state_Btn:SetState(0) else self.state_Btn:SetState(1) end end function UIGoldenHeroBossMain:OnClosed() UIManager.ActiveUIModle(true, "UIGoldenHeroBossMain") UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end function UIGoldenHeroBossMain:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView(true) end end end function UIGoldenHeroBossMain:OnBackButtonPressed() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGoldenHeroBossPurchase) then UIManager.CloseView(Const_UI_Lua.UIEnum.UIGoldenHeroBossPurchase) else self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end end function UIGoldenHeroBossMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then local params = {} local levelEnergyType = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).BossEnergyType local itemName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.ItemData:GetDataByID(levelEnergyType).Name]) table.insert(params, itemName) for k,v in DataSheetManager.GoldHeroEnergyGet:GetEnumerator() do if v.Type == 2 then local _,timeStr = UTL.Time.GetDateDescAndTime({v.Time}) table.insert(params, timeStr) end end UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.GoldHeroBoss, params = params}) elseif comp == self.btn_Rank then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroBossRank, {heroType = self.heroType, activityId = self.activityId}) elseif comp == self.btn_RankReward then CTL.GoldenHeroBoss.CheckMyRankAndOpenReward(self.activityId, self.heroType, 1) --查看自己的排名是否为空,为空则向服务器请求 elseif comp == self.btn_FightInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroBossRecord, {heroType = self.heroType, activityId = self.activityId}) elseif comp == self.btn_PointReward then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroBossPointsReward, {heroType = self.heroType, activityId = self.activityId}) elseif comp == self.group_SeekHelp.btn_SupportClose or comp == self.btn_SupportBack then self:ShowSupportWindow(false) elseif comp == self.btn_Support then self:ShowSupportWindow(not self.group_SeekHelp.gameObject.activeSelf) elseif comp == self.btn_Refresh then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_RefreshHint) elseif comp == self.btn_Filter then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroBossFilter, {heroType = self.heroType, activityId = self.activityId}) elseif comp == self.btn_Sweep then if self.hasDamage then if CTL.GoldenHeroBoss.IsBossCostItemEnough(self.activityId, self.bossId) then local timeValue = PersistentData.PlayerData:Get(SweepTipsTime, 0) if timeValue > 0 and UTL.Time.IsTimestampCrossDay(timeValue) then PersistentData.PlayerData:Remove(SweepTipsTime) timeValue = PersistentData.PlayerData:Get(SweepTipsTime, 0) end if timeValue <= 0 then local desc = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_Battle_Hint14) UTL.MessageBox.ShowOKCancelToggleBox(nil, desc, UIUtils.GetLocalizedTxt(Const_IDS.IDS_WarZoneAuction_27), -- 确认按钮回调 function() MDL.GoldenHeroBoss.GoldHeroBossSweepReq(self.activityId, self.bossId) end, -- 勾选框回调 function(isOn) if isOn then PersistentData.PlayerData:Set(SweepTipsTime, UTL.Time.GetServerTimestamp(), true) else PersistentData.PlayerData:Remove(SweepTipsTime) end end) else MDL.GoldenHeroBoss.GoldHeroBossSweepReq(self.activityId, self.bossId) end else -- 讨伐道具不足 if not CTL.GoldenHeroMain.OpenEnergyBuyViewByAttack(self.activityId, MDL.GoldenHeroMain.EnergyType.Boss) then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_GoldHeroActivity_ActivityLevel_WrongHint1, UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.ItemData:GetDataByID(DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).BossEnergyType).Name]))) end end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_Battle_Hint2) -- 通关一次讨伐目标后可解锁 end elseif comp == self.btn_Fight then if CTL.GoldenHeroBoss.IsBossCostItemEnough(self.activityId, self.bossId) then local bossInfo = MDL.GoldenHeroBoss.GetBossInfoByBossId(self.activityId, self.bossId) local bossConfigId = bossInfo.bossCfgId local bossData = DataSheetManager.GoldHeroSynergyBossData[self.heroType]:GetDataByID(bossConfigId) MDL.GoldenHeroBoss.EnterGoldenHeroBoss(self.activityId, self.bossId, bossConfigId, bossData.BossLevelID) else if not CTL.GoldenHeroMain.OpenEnergyBuyViewByAttack(self.activityId, MDL.GoldenHeroMain.EnergyType.Boss) then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_GoldHeroActivity_ActivityLevel_WrongHint1, UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.ItemData:GetDataByID(DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).BossEnergyType).Name]))) end end elseif comp == self.group_SeekHelp.btn_WorldSupport then MDL.GoldenHeroBoss.GoldHeroShareBossReq(self.activityId, self.bossId, MDL.GoldenHeroBoss.BossShare.ShareWorld) elseif comp == self.group_SeekHelp.btn_GuildSupport then MDL.GoldenHeroBoss.GoldHeroShareBossReq(self.activityId, self.bossId, MDL.GoldenHeroBoss.BossShare.ShareGuild) elseif comp == self.group_BossInfo.btn_HeroAddBg then self:ShowAddHeroDetailInfo(false) elseif comp == self.group_BossInfo.btn_HeroAdd then self:ShowAddHeroDetailInfo(not self.group_BossInfo.group_HeroAddInfo.gameObject.activeSelf) elseif comp == self.btn_Purchase then local timeId = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).DailyRankEndTime if UTL.Time.IsServerInOpeningTime(1, timeId) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroBossPurchase, {heroType = self.heroType, activityId = self.activityId}) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_NewHint_2) end end end function UIGoldenHeroBossMain:OnValueChanged(comp, index) if comp == self.group_BossTab then self:ShowSupportWindow(false) self:ShowBossList(index == 0) --index为0是我的讨伐,为1是协同讨伐 elseif comp == self.group_SeekHelp.group_SupportTab then self:ShowSupportContent(index == 0) --index为0是好友面板,为1是频道 end end function UIGoldenHeroBossMain:RefreshSelfRank() local group_BossInfo = self.group_BossInfo group_BossInfo.txt_CumulativePoint.text = MDL.GoldenHeroBoss.GetTodayScore(self.activityId) local rank = MDL.GoldenHeroBoss.GetMyBossRank(self.activityId, MDL.GoldenHeroBoss.BossRankType.SynergyBossTotalRank) if rank <= 0 then UIUtils.SetLabelText(group_BossInfo.txt_Rank, Const_IDS.IDS_GoldHeroActivity_SynergyBoss_NewHint6) else group_BossInfo.txt_Rank.text = rank end group_BossInfo.txt_Times.text = MDL.GoldenHeroBoss.GetParticipateTimes(self.activityId) local rewardLevel, isScoreEnough = MDL.GoldenHeroBoss.GetCurrentIndexOfRewardRank(self.activityId, MDL.GoldenHeroBoss.BossRankType.SynergyBossTotalRank) local rewardData if rewardLevel > 0 then rewardData = DataSheetManager.GoldHeroSynergyBossTotalRank[self.heroType]:GetDataByRankID(rewardLevel) end if rewardData then UIUtils.SetLabelText(group_BossInfo.txt_RankName, Const_IDS[rewardData.RankName]) if group_BossInfo.loop_RankReward.Count > 0 then group_BossInfo.loop_RankReward:ClearCells() end group_BossInfo.state_RankReward:SetState(0) for i, v in ipairs(rewardData.Reward_Table) do group_BossInfo.loop_RankReward:AddData(v, 0) end else UIUtils.SetLabelText(group_BossInfo.txt_RankName, Const_IDS.IDS_SuperGoldHeroActivity_NewHint_10) group_BossInfo.state_RankReward:SetState(1) end end function UIGoldenHeroBossMain:RefreshDailyRewardRedPoint(state) self.btn_PointReward:SetRedPoint(state) end function UIGoldenHeroBossMain:RefreshFindRewardRedPoint(state) self.btn_FightInfo:SetRedPoint(state) end ---在处理Cell的操作时候需要考虑到筛选条件,先判断是否符合条件,不符合则直接不考虑 function UIGoldenHeroBossMain:InsertBossCell(activityId, bossId) if activityId == self.activityId then local bossInfo = MDL.GoldenHeroBoss.GetBossInfoByBossId(activityId, bossId) if (bossInfo.finder == BattleDataGetter.GetAcID()) == self.isMine then if self.isMine or CTL.GoldenHeroBoss.IsBossSuitFilter(activityId, bossId) then self.loop_BossList:InsertData(0, bossInfo, 0) table.insert(self.bossList, 1, bossId) if self.loop_BossList.Count == 1 then --说明插入boss之前是没有boss的状态 self.loop_BossList:SelectIndex(0) end end end end end function UIGoldenHeroBossMain:UpdateBossCell(activityId, bossId) if activityId == self.activityId then local index = self:FindIndexInBossList(bossId) if index >= 0 then self.loop_BossList:UpdateIndex(index, MDL.GoldenHeroBoss.GetBossInfoByBossId(activityId, bossId)) end if bossId == self.bossId then local bossInfo = MDL.GoldenHeroBoss.GetBossInfoByBossId(activityId, bossId) local maxHp = bossInfo.maxHp if not maxHp or maxHp <= 0 then maxHp = MDL.GoldenHeroBoss.GetBossMaxHpByConfigId(self.activityId, bossInfo.bossCfgId) end self.img_BossHp.fillAmount = bossInfo.hp / maxHp self.txt_BossHP.text = bossInfo.hp .. "/" .. maxHp end end end function UIGoldenHeroBossMain:RemoveBossCell(activityId, bossId) if activityId == self.activityId then if bossId == self.bossId then --说明现在正选中的BOSS被击杀,需要打开击杀界面 local bossInfo = MDL.GoldenHeroBoss.GetBossInfoByBossId(activityId, bossId) if bossInfo.hp == 0 then --有可能是因为过期导致的,所以需要判断一下血量 CTL.GoldenHeroMain.AddGoldenHeroDelayFunc(Const_UI_Lua.UIEnum.UIGoldenHeroBossMain, activityId, CTL.GoldenHeroBoss.ShowBossFindView, activityId, bossId, bossInfo.bossCfgId, bossInfo.killName) end end local index = self:FindIndexInBossList(bossId) if index >= 0 then self.loop_BossList:RemoveIndex(index) table.removebyvalue(self.bossList, bossId) end if self.loop_BossList.Count == 0 then self:ShowNoBossHint() else if self.bossId == bossId then self:ShowSupportWindow(false) self.loop_BossList:SelectIndex(0, true) end end end end function UIGoldenHeroBossMain:LocateBossCell(activityId, bossId) if activityId == self.activityId then local index = self:FindIndexInBossList(bossId) if index >= 0 then self.loop_BossList:SelectIndex(index, true) else if self.loop_BossList.Count > 0 then self.loop_BossList:SelectIndex(0, true) else self:ShowNoBossHint() end end end end function UIGoldenHeroBossMain:FindIndexInBossList(bossId) local bossInfo = MDL.GoldenHeroBoss.GetBossInfoByBossId(self.activityId, bossId) if bossInfo then if (bossInfo.finder == BattleDataGetter.GetAcID()) == self.isMine then if self.isMine or CTL.GoldenHeroBoss.IsBossSuitFilter(self.activityId, bossId) then for i, v in ipairs(self.bossList) do if v == bossId then return i - 1 end end end end end return -1 end function UIGoldenHeroBossMain:ShowSupportWindow(isShow) UIUtils.SetActive(self.group_SeekHelp.gameObject, isShow) UIUtils.SetActive(self.btn_SupportBack, isShow) UIUtils.SetActive(self.group_BossInfo.gameObject, not isShow) self:ActiveBossInfo(not isShow) UIUtils.SetActive(self.group_FightBtn.gameObject, not isShow) if isShow then self.group_SeekHelp.group_SupportTab:SelectIndex(0) end end function UIGoldenHeroBossMain:ShowBossList(isMine) if isMine ~= nil then self.isMine = isMine end if self.loop_BossList.Count > 0 then self.loop_BossList:ClearCells() end self.bossList = {} UIUtils.SetActive(self.group_BtnBottom.gameObject, not self.isMine) local bossInfoList = MDL.GoldenHeroBoss.GetBossInfoList(self.activityId) if bossInfoList then if self.isMine then for i, v in ipairs(bossInfoList) do if v.finder == BattleDataGetter.GetAcID() then self.loop_BossList:AddData(v, 0) table.insert(self.bossList, v.bossId) end end else for i, v in ipairs(bossInfoList) do if v.finder ~= BattleDataGetter.GetAcID() then local bossId = v.bossId if CTL.GoldenHeroBoss.IsBossSuitFilter(self.activityId, bossId) then self.loop_BossList:AddData(v, 0) table.insert(self.bossList, v.bossId) end end end end end if self.loop_BossList.Count > 0 then self.loop_BossList:SelectIndex(0) else self:ShowNoBossHint() end end function UIGoldenHeroBossMain:ShowNoBossHint() UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) UTL.UIRender.Create2DTextureBgScene(self.modelComponentDataHandle, ConstAssetPathConfig.DefaultImage, nil, nil) self:ShowSupportWindow(false) self:ActiveBossInfo(false) UIUtils.SetActive(self.group_BossBlood, false) UIUtils.SetActive(self.group_FightBtn, false) UIUtils.SetActive(self.lab_NoBossHint, true) end function UIGoldenHeroBossMain:ActiveBossInfo(active) local group_BossInfo = self.group_BossInfo --UIUtils.SetActive(group_BossInfo.btn_HeroAddBg, active) UIUtils.SetActive(group_BossInfo.group_HeroAddition, active) UIUtils.SetActive(group_BossInfo.group_Boss, active) end function UIGoldenHeroBossMain:ShowSupportContent(isFriend) local seekComp = self.group_SeekHelp local loop = seekComp.loop_FriendList if loop.Count > 0 then loop:ClearCells() end if isFriend then UIUtils.SetActive(seekComp.group_Friend.gameObject, true) UIUtils.SetActive(seekComp.group_Channel.gameObject, false) local friends = MDL.Friend.GetSortedList(MDL.Friend.ListType.Friend) for i = 1, #friends do loop:AddData(friends[i], 0) end UIUtils.SetActive(seekComp.lab_NoFriend, loop.Count == 0) else UIUtils.SetActive(seekComp.group_Friend.gameObject, false) UIUtils.SetActive(seekComp.group_Channel.gameObject, true) UIUtils.SetActive(seekComp.lab_NoGuild, not MDL.Guild.IsHasGuild()) end end function UIGoldenHeroBossMain:SelectBoss() UIUtils.SetActive(self.group_BossInfo.gameObject, true) self:ActiveBossInfo(true) UIUtils.SetActive(self.group_BossBlood.gameObject, true) UIUtils.SetActive(self.group_FightBtn.gameObject, true) UIUtils.SetActive(self.lab_NoBossHint, false) local bossInfo = MDL.GoldenHeroBoss.GetBossInfoByBossId(self.activityId, self.bossId) local bossConfigId = bossInfo.bossCfgId --右上boss信息 local group_BossInfo = self.group_BossInfo local isSelf = BattleDataGetter.GetAcID() == bossInfo.finder UIUtils.SetActive(group_BossInfo.group_Finder.gameObject, not isSelf) group_BossInfo.txt_FinderName.text = isSelf and BattleDataGetter.GetPlayerName() or bossInfo.finderName UIUtils.SetActive(group_BossInfo.group_MaxDamage.gameObject, bossInfo.highestDamage ~= 0) group_BossInfo.txt_MaxDamage.text = bossInfo.highestScore local bossData = DataSheetManager.GoldHeroSynergyBossData[self.heroType]:GetDataByID(bossConfigId) UIUtils.SetLabelText(group_BossInfo.txt_BossName, Const_IDS[bossData.BossName]) local originGs = bossInfo.recommendGs if not originGs or originGs <= 0 then --保底机制:如果随着BOSS过来的推荐战力不正确就用外面的这个推荐战力字段 originGs = MDL.GoldenHeroBoss.GetRecommendGs(self.activityId) end local targetGs = math.floor(originGs * bossData.BossBattleScoreRate + 0.5) group_BossInfo.txt_GsNum.text = CTL.GoldenHeroBoss.GetSubjugateGsText(targetGs) CTL.GoldenHeroBoss.ShowBossStar(group_BossInfo.group_Star, bossData.BossStar) local heroTypeData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType) local maxHp = bossInfo.maxHp if not maxHp or maxHp <= 0 then maxHp = MDL.GoldenHeroBoss.GetBossMaxHpByConfigId(self.activityId, bossConfigId) end self.img_BossHp.fillAmount = bossInfo.hp / maxHp self.txt_BossHP.text = bossInfo.hp .. "/" .. maxHp self:SetBossTimer(self.group_Time, bossInfo.endTime) self.hasDamage = MDL.GoldenHeroBoss.ShowSweepBtn(self.activityId, bossConfigId) self.btn_Sweep:SetGray(not self.hasDamage, true) --是否显示支援按钮 UIUtils.SetActive(self.btn_Support, bossData.HelpType and isSelf) --显示boss模型 self:ShowBossModel(bossData) --显示该boss求援按钮的cd self:SetShareCD(self.activityId, self.bossId) --显示boss消耗货币数 self.txt_AttackItemNum.text = bossData.EnergyNum UTL.Item.ItemIconWithoutBg(self.img_AttackItemIcon, heroTypeData.BossEnergyType) UIUtils.SetActive(group_BossInfo.group_HeroAddInfo, false) self:ShowAddHeroBasicInfo() end function UIGoldenHeroBossMain:ShowBossModel(bossData) -- 加载模型和设置2D背景图 UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, Common2DScenePrefab, 1600, 0, 1600, ConstAssetPathConfig.DefaultImage, true) UTL.UIRender.CreateNonPlayerModel(self.modelComponentDataHandle, bossData.BossShow, bossData.ModelScale, bossData.ShowEquipmentID, bossData.ModelLight) UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, 0, -1.1, 0) UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, -10, 0) end function UIGoldenHeroBossMain:SetBossTimer(timer, endTime) local time = endTime - UTL.Time.GetServerTimestamp() timer:ResetAndBeginTimer(false, time) end function UIGoldenHeroBossMain:OnUpdateFun(deltaTime, timeSinceUpdate) self:SetShareCD(self.activityId, self.bossId) end function UIGoldenHeroBossMain:SetShareCD(activityId, bossId) if self.activityId == activityId and self.bossId == bossId then local seekComp = self.group_SeekHelp local guildCDTime = MDL.Guild.IsHasGuild() and MDL.GoldenHeroBoss.GetBossShareCD(activityId, bossId, MDL.GoldenHeroBoss.BossShare.ShareGuild) or 0 local worldCDTime = MDL.GoldenHeroBoss.GetBossShareCD(activityId, bossId, MDL.GoldenHeroBoss.BossShare.ShareWorld) UIUtils.SetActive(seekComp.btn_GuildSupport, MDL.Guild.IsHasGuild() and guildCDTime == 0) UIUtils.SetActive(seekComp.btn_WorldSupport, worldCDTime == 0) self:SetCDTimer(seekComp.timer_WorldSupportCD, worldCDTime) self:SetCDTimer(seekComp.timer_GuildSupportCD, guildCDTime) self:StopRepeatFunc(self.OnUpdateFun) if worldCDTime > 0 and guildCDTime > 0 then self:StartRepeatFunc(self.OnUpdateFun, worldCDTime < guildCDTime and worldCDTime or guildCDTime) elseif worldCDTime > 0 then self:StartRepeatFunc(self.OnUpdateFun, worldCDTime) elseif guildCDTime > 0 then self:StartRepeatFunc(self.OnUpdateFun, guildCDTime) end end end function UIGoldenHeroBossMain:SetCDTimer(timer, cdTime) if cdTime > 0 then timer:ResetAndBeginCustomTimer(false, cdTime, 0, nil) else timer:EndTimer() end end function UIGoldenHeroBossMain:ShowAddHeroBasicInfo() local groupInfo = self.group_BossInfo local addHeroId = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).SynergyBossHeroID UTL.Item.SetHeroIconByHeroId(groupInfo.img_HeroAddHead, addHeroId, MDL.HeroAwaken.GetIsHeroAwaken(addHeroId)) UTL.Item.SetHeroIconByHeroId(groupInfo.img_AddHero, addHeroId, MDL.HeroAwaken.GetIsHeroAwaken(addHeroId)) local level = MDL.GoldenHeroBoss.GetAddHeroAddLevel(addHeroId) local isUnlock = level > 0 groupInfo.state_Unlock:SetState(isUnlock and 1 or 0) UIUtils.SetGray(groupInfo.img_HeroAddHead, not isUnlock) UIUtils.SetGray(groupInfo.img_AddHero, not isUnlock) UIUtils.SetActive(groupInfo.group_AddNum, isUnlock) level = isUnlock and level or 1 --如果该武将突破等级不满足则置成1,找到初始数据进行显示 local addHeroData = DataSheetManager.GoldHeroSynergyBossHero:GetDataByHeroID_LevelID(addHeroId, level) local addNum = UTL.Attr.FormatNumberToPercentage(addHeroData.SynergyBossHeroNum, 0) groupInfo.txt_HeroAddNum.text = "+" .. addNum UIUtils.SetLabelText(groupInfo.txt_SkillName, Const_IDS[addHeroData.SkillName]) groupInfo.txt_Lv.text = level local firstAddHeroData = DataSheetManager.GoldHeroSynergyBossHero:GetDataByHeroID_LevelID(addHeroId, 1) local heroName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroNum:GetDataByID(addHeroId).NameIDS]) groupInfo.txt_SkillInfo.text = string.FormatByIdsId(Const_IDS[firstAddHeroData.SkillDes], heroName, UTL.Attr.FormatNumberToPercentage(firstAddHeroData.SynergyBossHeroNum, 0)) end function UIGoldenHeroBossMain:ShowAddHeroDetailInfo(isShow) UIUtils.SetActive(self.group_BossInfo.btn_HeroAddBg, isShow) UIUtils.SetActive(self.group_BossInfo.group_HeroAddInfo, isShow) if isShow then local loopScroll = self.group_BossInfo.loop_HeroAddInfo if loopScroll.Count > 0 then loopScroll:ClearCells() end local addHeroId = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(self.heroType).SynergyBossHeroID for i, v in DataSheetManager.GoldHeroSynergyBossHero:GetDataByHeroID_LevelID(addHeroId) do if i > 1 then loopScroll:AddData(v, 0) end end end end function UIGoldenHeroBossMain:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_BossList then self.bossId = data.bossId self:SelectBoss() CTL.GoldenHeroBoss.RemoveBossFromNew(self.activityId, self.bossId) cellTable.cell:SetRedPoint(false) end end local HeroIconPath = ConstAssetPathConfig.HeadImgPath function UIGoldenHeroBossMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.group_SeekHelp.loop_FriendList then CTL.Character.SetPortraitAndFrame(cellTable.UIHeroHead150, data.portraitId, data.frameId, data.level) UIUtils.SetLabel(cellTable.txt_FriendName, data.name) cellTable.state_Button:SetState(0) cellTable.state_Online:SetState(data.isOnline and 1 or 0) elseif scrollRect == self.loop_BossList then local bossConfigId = data.bossCfgId local bossData = DataSheetManager.GoldHeroSynergyBossData[self.heroType]:GetDataByID(bossConfigId) UIUtils.SetLabelText(cellTable.txt_BossName, Const_IDS[bossData.BossName]) local icon = string.format(HeroIconPath, bossData.Icon) UIUtils.SetImageByAssetBundle(cellTable.img_BossHead, icon) local star = bossData.BossStar for i, v in ipairs(cellTable.group_Star) do UIUtils.SetActive(v, i <= star) end local maxHp = data.maxHp if not maxHp or maxHp <= 0 then maxHp = MDL.GoldenHeroBoss.GetBossMaxHpByConfigId(self.activityId, bossConfigId) end cellTable.img_BossHp.fillAmount = data.hp / maxHp self:SetBossTimer(cellTable.group_Time, data.endTime) cellTable.cell:SetRedPoint(CTL.GoldenHeroBoss.CheckNewBossRedPoint(self.activityId, data.bossId)) elseif scrollRect == self.group_BossInfo.loop_HeroAddInfo then local heroId = data.HeroID local level = MDL.GoldenHeroBoss.GetAddHeroAddLevel(heroId) local isUnlock = level >= data.LevelID cellTable.txt_Level.text = string.FormatByIdsId(Const_IDS.IDS_BreakThrough_Level, data.LevelID) cellTable.state_Unlock:SetState(isUnlock and 1 or 0) cellTable.txt_Desc.text = string.FormatByIdsId(Const_IDS[data.SkillDes], UTL.Attr.FormatNumberToPercentage(data.SynergyBossHeroNum, 0)) if not isUnlock then local heroName = DataSheetManager.HeroNum:GetDataByID(heroId).NameIDS cellTable.txt_Unlock.text = string.FormatByIdsId(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_SkillLock, UIUtils.GetLocalizedTxt(Const_IDS[heroName]), data.HeroStar) end elseif scrollRect == self.group_BossInfo.loop_RankReward then UTL.Item.SetItemCell(cellTable.item, data.Item, data.ItemNum) end end function UIGoldenHeroBossMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.group_SeekHelp.loop_FriendList then if target == cellTable.btn_SeekHelp then MDL.GoldenHeroBoss.GoldHeroShareBossReq(self.activityId, self.bossId, MDL.GoldenHeroBoss.BossShare.ShareFriend, data.acid) cellTable.state_Button:SetState(1) end elseif scrollRect == self.group_BossInfo.loop_RankReward then UTL.ItemTips.ShowCommonTipsById(data.Item) end end function UIGoldenHeroBossMain:OnFocusChanged(isFocus) if isFocus then CTL.GoldenHeroMain.SetGoldenHeroFocusTarget(Const_UI_Lua.UIEnum.UIGoldenHeroBossMain, self.activityId) EventSystem.Dispatch(EventID.UI_GoldenHero_FocusOnGoldenHeroView, Const_UI_Lua.UIEnum.UIGoldenHeroBossMain, self.activityId) else CTL.GoldenHeroMain.SetGoldenHeroFocusTarget(nil, nil) end end return UIGoldenHeroBossMain