local UIBossChallengeMain = UIViewClass() local HeadImgPath = ConstAssetPathConfig.HeadImgPath local SingleBossGuideTipsIdBase = LuaConst.NoteID.BossChallenge * 1000 local Common2DScenePrefab = ConstAssetPathConfig.Common2DScenePrefab local Difficult_IDS = { "IDS_BossChallenge_Normal", "IDS_BossChallenge_Elite", "IDS_BossChallenge_Inferno", } function UIBossChallengeMain:OnOpened(context) if not CTL.Unlock.CheckIfFuncUnlock(MDL.Unlock.FunctionType.Boss, self, true) then return end self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.CheckIfFuncUnlock) self:RegistSystemEvent(EventID.UI_BossChallenge_RankRefresh, self.RefreshRankInfo) self:RegistSystemEvent(EventID.UI_FairPlay_BossChallengeSeasonInfoUpdate, self.InitPanel) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_BossChallenge) if MDL.RedPoint.GetOneTimeRedPointInfoByType(MDL.RedPoint.RedPointType.Boss) == 0 then if CTL.Unlock.JudgeIfSatisfiedUnlockTable(DataSheetManager.BossChallengeData:GetDataByID(1).Unlock_Table) then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Boss) MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.Boss, 1) end end self.effectResult = nil self.modelComponentHandle = UTL.UIRender.CreateModelComponentDatas(self.BossShowScene) self:InitPanel() --CameraController.Instance:SetDOF(true, 2.5, 7, 53, 4) UIManager.ActiveUIModle(false, "UIBossChallengeMain") end function UIBossChallengeMain:CheckIfFuncUnlock(funcId, isUnlock) if funcId and funcId == MDL.Unlock.FunctionType.Boss then CTL.Unlock.CheckIfFuncUnlock(funcId, self, true) end end function UIBossChallengeMain:InitPanel() self.seasonId = CTL.BossChallenge.GetSeasonId() self.difficult = CTL.BossChallenge.GetFirstUnPassBossDifficult(self.seasonId) self.bossLevelId = CTL.BossChallenge.GetSeasonBossLevelList(self.seasonId)[self.difficult] local bossId = DataSheetManager.BossChallengeLevel:GetDataByID(self.bossLevelId).BossID self:InitPanelBaseInfo(bossId) MDL.BossChallenge.GetRoleBossChallengeRankRequest(self.seasonId) self:RefreshSeasonTime() self:RefreshLeftBossDifficult(self.difficult) self:RefreshPanelInfo() local activityTimeData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.BossChallenge).Time_Table local desc, time = UTL.Time.GetDateDescAndTime(activityTimeData) self.txt_Time.text = string.Concat(desc, time) UIUtils.SetLabel(self.txt_Number,CTL.BossChallenge.GetSeasonId()) UIUtils.SetLabelText(self.txt_RankBtn, Const_IDS["IDS_Rank"]) if CTL.BossChallenge.IsWarZoneStyle() then UIUtils.SetLabelText(self.txt_RankBtn, Const_IDS["IDS_WarZone_Rank"]) end end function UIBossChallengeMain:OnUpdateFun(deltaTime, timeSinceUpdate) self.seasonId = CTL.BossChallenge.GetSeasonId() local leftTime = CTL.BossChallenge.GetLeftSeasonTime(self.seasonId) self.bg_Time:ResetAndBeginCustomTimer(false, leftTime, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_BossChallenge_SeasonLeftTime"]), 1) if leftTime >= 0 then self:StartRepeatFunc(self.OnUpdateFun, leftTime, 1) end self.bossLevelId = CTL.BossChallenge.GetSeasonBossLevelList(self.seasonId)[1] self:RefreshLeftBossDifficult(self.difficult) end function UIBossChallengeMain:RefreshLeftBossDifficult(index) self.difficult = index self:RefreshSelectedButtonState(index) end local SelectedScaleRatio = 1.2 function UIBossChallengeMain:RefreshSelectedButtonState(index) for i, v in ipairs(self.group_Difficult) do if i == index then v.gameObject.transform:SetLocalScale(SelectedScaleRatio, SelectedScaleRatio, SelectedScaleRatio) else v.gameObject.transform:SetLocalScale(1, 1, 1) end end end local bossNameImgPath = "UI_BOSSName/%s.png" function UIBossChallengeMain:InitPanelBaseInfo(bossId) local bossData = DataSheetManager.BossChallengeData:GetDataByID(bossId) UIUtils.SetLabelText(self.txt_heroIntroduction, Const_IDS[bossData.BossChallengeDes]) if self.loc_BossName.CurState == 0 then UIUtils.SetLabelText(self.txt_Name,Const_IDS[bossData.BossChallengeName]) else self.txt_BossName.text =string.split(UIUtils.GetLocalizedTxt(Const_IDS[bossData.BossChallengeName]),"-")[2] end local bossLevelData = DataSheetManager.BossChallengeLevel:GetDataByID(self.bossLevelId) local buffTable = bossLevelData.BuffID for i, v in ipairs(buffTable) do local iconPath = DataSheetManager.BuffData:GetDataByBuffID(v).BuffIcon UIUtils.SetImageByAssetBundle(self.group_BuffInfos[i].gameObject:GetComponent(typeof(Image)), iconPath) end self:SetDifficultButtonUnlockState() self:SetBossModel(bossId) end function UIBossChallengeMain:SetDifficultButtonUnlockState() for i, v in ipairs(self.group_Difficult) do local isUnlock = CTL.BossChallenge.IsBossDifficultUnlock(i, self.seasonId) UIUtils.SetComponentGray(v.gameObject.transform, not isUnlock) if isUnlock then local scoreText = MDL.BossChallenge.GetBossDifficultScoreByDifficultAndSeason(i, self.seasonId) if i ~= MDL.BossChallenge.Difficult.Nightmare then local scoreData = DataSheetManager.BossChallengeScore:GetDataByID(i) v.lab_Score.text = string.FormatByIdsId(Const_IDS["IDS_BossChallenge_Score_ShowMax"], scoreText, scoreData.MaxScore) else v.lab_Score.text = string.FormatByIdsId(Const_IDS["IDS_BossChallenge_Score_NoMax"], scoreText) end UIUtils.SetActive(v.lab_Score, true) else UIUtils.SetActive(v.lab_Score, false) end end end function UIBossChallengeMain:RefreshSeasonTime() UIUtils.SetActive(self.bg_Time.gameObject, false) local ifUnlock = CTL.BossChallenge.IsSeasonOpen(self.seasonId) if ifUnlock then UIUtils.SetLabelText(self.txt_Tip1, Const_IDS["IDS_BossChallenge_SeasonLeftTimeTip"]) UIUtils.SetLabelText(self.txt_Term, Const_IDS["IDS_RankOptimization_Season"]) else UIUtils.SetLabelText(self.txt_Tip1, Const_IDS["IDS_BossChallenge_NextSeasonOpenTimeTip"]) UIUtils.SetLabelText(self.txt_Term, Const_IDS["IDS_RankOptimization_SeasonOff"]) end local leftTime = CTL.BossChallenge.GetLeftSeasonTime(self.seasonId) self.bg_Time:ResetAndBeginCustomTimer(false, leftTime, 0, " "..UIUtils.GetLocalizedTxt(Const_IDS["IDS_BossChallenge_SeasonLeftTime"]), 1) if leftTime >= 0 then self:StartRepeatFunc(self.OnUpdateFun, leftTime, 1) end UIUtils.SetActive(self.bg_Time.gameObject, true) end function UIBossChallengeMain:RefreshPanelInfo() --local ifUnlock = (not self.isGap) and CTL.BossChallenge.IfBossLevelIdUnlock(bossLevelId, self.seasonId) or false if not CTL.BossChallenge.IsBossDifficultUnlock(self.difficult, self.seasonId) then logging.error(LTAG.ERROR, "此难度没有解锁,不应该跳转到此方法中!") return end local ifUnlock = CTL.BossChallenge.IsSeasonOpen(self.seasonId) if ifUnlock then self.btn_Challenge:SetGray(false, true) self.btn_Challenge:SetText(UIUtils.GetLocalizedTxt(Const_IDS.IDS_BossChallenge_Button)) else self.btn_Challenge:SetGray(true, true) self.btn_Challenge:SetText(UIUtils.GetLocalizedTxt(Const_IDS.IDS_RankOptimization_SeasonOff)) end self:RefreshRankInfo() end function UIBossChallengeMain:RefreshRankInfo() ---分数相关 UIUtils.SetLabel(self.txt_TotalScore, MDL.BossChallenge.GetTotalBossScoreBySeasonId(self.seasonId)) ---排名相关 local myRank = MDL.BossChallenge.GetBossRankByBossLevelId() if myRank and myRank > 0 then UIUtils.SetLabel(self.txt_Rank, myRank) else UIUtils.SetLabelText(self.txt_Rank, Const_IDS.IDS_3v3UnRanked) end end function UIBossChallengeMain:SetBossModel(bossId) local bossData = DataSheetManager.BossChallengeData:GetDataByID(bossId) local bgTexturePath = ConstAssetPathConfig.bgTexturePath UTL.UIRender.Create2DSceneTrans(self.modelComponentHandle, Common2DScenePrefab, 1600, 0, 1600, bgTexturePath, false) UTL.UIRender.CreateNonPlayerModel(self.modelComponentHandle, bossData.BossShow, bossData.ModelScale, bossData.ShowEquipmentID, bossData.ModelLight, bossData.ModelOffset) UTL.UIRender.SetHeroParentPos(self.modelComponentHandle, 0.16, -1.2, 0) UTL.UIRender.SetHeroParentRot(self.modelComponentHandle, 0, -10, 0) if not self.effectResult then self.effectResult = CTL.FairPlay.CreateFogEffectInScene(UTL.UIRender.GetSceneTrans(self.modelComponentHandle)) end end function UIBossChallengeMain:OnClosed() UTL.UIRender.DisposeModelComponentData(self.modelComponentHandle) UIManager.ActiveUIModle(true, "UIBossChallengeMain") if self.effectResult then self.effectResult:Dispose() self.effectResult = nil end end function UIBossChallengeMain:OnClickChallenge() if CTL.Activities.IsOpeningTime(LuaConst.ActivityType.BossChallenge) then if MDL.BossChallenge.GetBossChallengeState() == MDL.FairPlay.SeasonState.SeasonOpening then if CTL.BossChallenge.IfBossLevelIdUnlock(self.bossLevelId, self.seasonId) then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIBossChallengeFormation, {bossLevelId = self.bossLevelId, seasonId = self.seasonId}) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_BossChallenge_NotOpen"]) CTL.Sound.PlayGameSound("UI_invalid") end end else CTL.Tips.AddTipsMsg(Const_IDS["IDS_FairPlay_3v3NotOpen"]) CTL.Sound.PlayGameSound("UI_invalid") end end function UIBossChallengeMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIBossChallengeMain: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.event_Rank then CTL.Rank.OpenRankPanelByType(MDL.Rank.RankType.BossChallenge, {bossLevelId = self.bossLevelId, seasonId = self.seasonId}) elseif comp == self.btn_Challenge then self:OnClickChallenge() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.BossChallenge}) elseif comp == self.btn_Strategy then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = (SingleBossGuideTipsIdBase + DataSheetManager.BossChallengeLevel:GetDataByID(self.bossLevelId).BossID)}) elseif comp == self.btn_BuffInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UIBossChallengeBuff, {bossLevelId = self.bossLevelId}) elseif comp == self.event_Reward then UIManager.OpenView(Const_UI_Lua.UIEnum.UIBossChallengeReward) elseif comp == self.btn_Shop then --店铺 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.GongPing}) else for i, v in ipairs(self.group_BuffInfos) do if comp == v then CTL.Tips.CloseSkillTips(self.SkillTips) local buffId = DataSheetManager.BossChallengeLevel:GetDataByID(self.bossLevelId).BuffID[i] CTL.Tips.OpenSkillTips(buffId, self.SkillTips, CTL.Tips.SkillType.ConstantBuff) return end end for i, v in ipairs(self.group_Difficult) do if comp == v.btn_Difficult then if not CTL.BossChallenge.IsBossDifficultUnlock(i, self.seasonId) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_BossChallenge_Unlock"]) return end if self.difficult ~= i then self.bossLevelId = CTL.BossChallenge.GetSeasonBossLevelList(self.seasonId)[i] self:RefreshLeftBossDifficult(i) self:RefreshPanelInfo() return end end end end end return UIBossChallengeMain