local UIBossMainPanel = UIViewClass() local FuncImagePath = { [MDL.Unlock.FunctionType.CountryWorldBoss] = ConstAssetPathConfig.Path43, [MDL.Unlock.FunctionType.WorldBoss] = ConstAssetPathConfig.AssetPath175, [MDL.Unlock.FunctionType.GVGFight] = ConstAssetPathConfig.AssetPath176, } function UIBossMainPanel:OnCreated() UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_GVGFight_NewEntrance) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self.itemUIDic = {} self.funcDealwith = { {FunctionType = MDL.Unlock.FunctionType.CountryWorldBoss, UnlockFunc = self.IsUnlockCountryWorldBoss, UpdateUI = self.UpdateWarZoneRewardTimes}, {FunctionType = MDL.Unlock.FunctionType.WorldBoss, UnlockFunc = self.IsUnlockWorldBoss, UpdateUI = self.UpdateWorldRewardTimes}, {FunctionType = MDL.Unlock.FunctionType.GVGFight, UnlockFunc = self.IsUnlockGVGFight, UpdateUI = self.UpdateGVGFight}, } end function UIBossMainPanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_WorldBoss_UpdateRewardTimes, self.UpdateWorldRewardTimes) self:RegistSystemEvent(EventID.UI_UpdateCountryWorldBossRewardTimes, self.UpdateWarZoneRewardTimes) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.BossMain_WarZone, self.UpdateCountryWorldBossRed) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.BossMain_World, self.UpdateWorldBossRed) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.GVGFight, self.UpdateGVGFightRP) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.CheckIfFuncUnlock) self:RefreshUI() end function UIBossMainPanel:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end function UIBossMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIBossMainPanel:OnButtonClicked(comp) if self.UITemplateTitlePanel.btn_close == comp then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() else for functionType, itemIndex in pairs(self.itemUIDic) do if self.group_TeamDungeon[itemIndex].btn_Select == comp then if functionType == MDL.Unlock.FunctionType.CountryWorldBoss then CTL.CountryWorldBoss.OpenCountryWorldBossPanel() elseif functionType == MDL.Unlock.FunctionType.WorldBoss then CTL.WorldBoss.OpenMainPanel() elseif functionType == MDL.Unlock.FunctionType.GVGFight then CTL.GVGFight.OpenGVGFightMain() end end end end end function UIBossMainPanel:RefreshUI() -- 先设置解锁的UI local itemIndex = 1 for _, func in ipairs(self.funcDealwith) do if func.UnlockFunc(self) then self.itemUIDic[func.FunctionType] = itemIndex itemIndex = itemIndex + 1 func.UpdateUI(self) end end -- 再设置解锁的UI for _, func in ipairs(self.funcDealwith) do if not func.UnlockFunc(self) then self.itemUIDic[func.FunctionType] = itemIndex itemIndex = itemIndex + 1 func.UpdateUI(self) end end end function UIBossMainPanel:SetPowerColor(text, haveRewardCount, totalAwardTimes) local str = string.format("%d/%d", haveRewardCount, totalAwardTimes) if haveRewardCount == 0 then str = UTL.Color.FormatRedColor(str) elseif haveRewardCount > totalAwardTimes then str = UTL.Color.FormatGreenColor(str) end UIUtils.SetLabel(text, str) end function UIBossMainPanel:CheckIfFuncUnlock(funcId, isUnlock) if funcId and (funcId == MDL.Unlock.FunctionType.WorldBoss or funcId == MDL.Unlock.FunctionType.CountryWorldBoss or funcId == MDL.Unlock.FunctionType.GVGFight) then CTL.Unlock.CheckIfFuncUnlock(funcId, self, true) end end ------------------- Start 国家世界首领 Start ------------------- function UIBossMainPanel:IsUnlockCountryWorldBoss() return CTL.WarZone.IsWarZoneOpen() and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.CountryWorldBoss) end function UIBossMainPanel:UpdateCountryWorldBossRed() local itemIndex = self.itemUIDic[MDL.Unlock.FunctionType.CountryWorldBoss] self.group_TeamDungeon[itemIndex].btn_Select:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.BossMain_WarZone)) end function UIBossMainPanel:UpdateWarZoneRewardTimes() local itemIndex = self.itemUIDic[MDL.Unlock.FunctionType.CountryWorldBoss] local obj = self.group_TeamDungeon[itemIndex] local isUnlock = self:IsUnlockCountryWorldBoss() obj.state:SetState(isUnlock and 0 or 1) -- 设置标题 UIUtils.SetLabelText(obj.txt_ComingSoon, Const_IDS.IDS_ActivityName_WarZoneBoss) -- 设置背景图 UIUtils.SetImageByAssetBundle(obj.img_OpenShow, FuncImagePath[MDL.Unlock.FunctionType.CountryWorldBoss]) UIUtils.SetImageByAssetBundle(obj.img_LockShow, FuncImagePath[MDL.Unlock.FunctionType.CountryWorldBoss]) if isUnlock then local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.CountryWorldBoss) local totalAwardTimes = activityData.DailyRefreshTimes UIUtils.SetLabelText(obj.lab_Times, Const_IDS.IDS_WorldBoss_RewardTme) self:SetPowerColor(obj.txt_Times, MDL.CountryWorldBoss.GetRewardCountLeft(), totalAwardTimes) self:UpdateCountryWorldBossRed() else UIUtils.SetLabelText(obj.txt_Lock, Const_IDS.IDS_Country_CountryNotOpen) end end --------------------- End 国家世界首领 End --------------------- ------------------- Start 世界首领 Start ------------------- function UIBossMainPanel:IsUnlockWorldBoss() return MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.WorldBoss) end function UIBossMainPanel:UpdateWorldBossRed() local itemIndex = self.itemUIDic[MDL.Unlock.FunctionType.WorldBoss] self.group_TeamDungeon[itemIndex].btn_Select:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.BossMain_World)) end function UIBossMainPanel:UpdateWorldRewardTimes() local itemIndex = self.itemUIDic[MDL.Unlock.FunctionType.WorldBoss] local obj = self.group_TeamDungeon[itemIndex] local isUnlock = self:IsUnlockWorldBoss() obj.state:SetState(isUnlock and 0 or 1) -- 设置标题 UIUtils.SetLabelText(obj.txt_ComingSoon, Const_IDS.IDS_ActivityName_WorldBoss) -- 设置背景图 UIUtils.SetImageByAssetBundle(obj.img_OpenShow, FuncImagePath[MDL.Unlock.FunctionType.WorldBoss]) UIUtils.SetImageByAssetBundle(obj.img_LockShow, FuncImagePath[MDL.Unlock.FunctionType.WorldBoss]) if isUnlock then local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.WorldBoss) local totalAwardTimes = activityData.DailyRefreshTimes UIUtils.SetLabelText(obj.lab_Times, Const_IDS.IDS_WorldBoss_RewardTme) self:SetPowerColor(obj.txt_Times, MDL.WorldBoss.RewardCountLeft, totalAwardTimes) obj.btn_Select:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.BossMain_World)) self:UpdateWorldBossRed() else UIUtils.SetLabelText(obj.txt_Lock, Const_IDS.IDS_BossChallenge_NotOpen) end end --------------------- End 世界首领 End --------------------- ------------------- Start 攻城略地 Start ------------------- function UIBossMainPanel:IsUnlockGVGFight() local isUnlock = CTL.Activities.IsOpen(LuaConst.ActivityType.GVGFight) return isUnlock end function UIBossMainPanel:UpdateGVGFightRP() local itemIndex = self.itemUIDic[MDL.Unlock.FunctionType.GVGFight] self.group_TeamDungeon[itemIndex].btn_Select:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.GVGFight)) end function UIBossMainPanel:UpdateGVGFight() local itemIndex = self.itemUIDic[MDL.Unlock.FunctionType.GVGFight] local obj = self.group_TeamDungeon[itemIndex] local isUnlock, condition = CTL.Activities.IsOpen(LuaConst.ActivityType.GVGFight) obj.state:SetState(isUnlock and 0 or 1) -- 设置标题 UIUtils.SetLabelText(obj.txt_ComingSoon, Const_IDS.IDS_GVGFight_Name) -- 设置背景图 UIUtils.SetImageByAssetBundle(obj.img_OpenShow, FuncImagePath[MDL.Unlock.FunctionType.GVGFight]) UIUtils.SetImageByAssetBundle(obj.img_LockShow, FuncImagePath[MDL.Unlock.FunctionType.GVGFight]) if isUnlock then UIUtils.SetLabelText(obj.lab_Times, Const_IDS.IDS_ClimbTower_SpeedLastTime) UIUtils.SetLabelText(obj.txt_Times, Const_IDS.IDS_Activity_NoLimitTimes) self:UpdateGVGFightRP() else UIUtils.SetLabel(obj.txt_Lock, condition) obj.btn_Select:SetRedPoint(false) end end --------------------- End 攻城略地 End --------------------- return UIBossMainPanel