local UISubjectMonthChallenge = UIViewClass() local SingleBossGuideTipsIdBase = LuaConst.NoteID.BossChallenge * 1000 local Common2DScenePrefab = ConstAssetPathConfig.Common2DScenePrefab local HeadImgPath = ConstAssetPathConfig.HeadImgPath local GreenColor = "70BE84" function UISubjectMonthChallenge:OnOpened(context) if not CTL.SubjectMonth.IsSubActivityOpen(MDL.SubjectMonth.SubActivityType.BossChallenge) then self:CloseView(true) return end self:RegistSystemEvent(EventID.UI_SubjectMonth_UpdateBossChallengeInfo, self.RefreshBossList) self:RegistSystemEvent(EventID.UI_SubjectMonth_UpdateRankInfo, self.SetRankInfo) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self.modeId = CTL.SubjectMonth.GetSubActivityModeId(MDL.SubjectMonth.SubActivityType.BossChallenge) self.activityId = MDL.SubjectMonth.GetActivityId() UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_VersionsActivity_ChildName3) self.modelComponentHandle = UTL.UIRender.CreateModelComponentDatas(self.BossShowScene) local bgTexturePath = ConstAssetPathConfig.bgTexturePath5 UTL.UIRender.Create2DSceneTrans(self.modelComponentHandle, Common2DScenePrefab, 1600, 0, 1600, bgTexturePath, false) MDL.MonthBossChallenge.GetSubjectMonthBossChallengeInfoReq() local bigSeasonCfg = DataSheetManager.KingChallengeSeason:GetDataByID(MDL.KingChallenge.GetCurBigSeasonId()) UIUtils.SetImageByAssetBundle(self.img_Bg, bigSeasonCfg.SeasonPic) UIUtils.SetLabelText(self.lab_tittle, Const_IDS[bigSeasonCfg.SeasonName]) UTL.Item.SetLocalizationImage(self.Loc_tittle, self.img_tittle, bigSeasonCfg.SeasonArtName) UIManager.ActiveUIModle(false, "UISubjectMonthChallenge") end function UISubjectMonthChallenge:RefreshBossList() if not self.bossId then self.bossId = MDL.MonthBossChallenge.GetCurBossId() end local bossList = CTL.MonthBossChallenge.GetShowBossList() self.group_Scroll:ReloadAll(bossList) local index = 0 for i, v in ipairs(bossList) do if self.bossId == v then index = i - 1 end end self.group_Scroll:SelectIndex(index) end function UISubjectMonthChallenge:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.group_Scroll then local bossData = DataSheetManager.VersionsBossChallengeBoss:GetDataByID(data) UIUtils.SetImageByAssetBundle(cellTable.img_Icon, string.format(HeadImgPath, bossData.Icon)) UIUtils.SetLabel(cellTable.txt_BossName, string.split(UIUtils.GetLocalizedTxt(Const_IDS[bossData.BossChallengeName]),"-")[2]) local state, leftTime = CTL.MonthBossChallenge.GetStateByBossId(data) if state == CTL.Activities.ActivityState.NotOpen then cellTable.state_Tag:SetState(0) local dayStr = string.FormatByIdsId(Const_IDS.IDS_GuildActivity_Preview, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_1)) local hourStr = string.FormatByIdsId(Const_IDS.IDS_GuildActivity_Preview, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_2)) local minStr = string.FormatByIdsId(Const_IDS.IDS_GuildActivity_Preview, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_3)) local secStr = string.FormatByIdsId(Const_IDS.IDS_GuildActivity_Preview, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_4)) cellTable.txt_OpenTime:SetDHMSStr(dayStr, hourStr, minStr, secStr) cellTable.txt_OpenTime:ResetAndBeginCustomTimer(false, leftTime, 0, nil, 1) elseif state == CTL.Activities.ActivityState.Opening then cellTable.state_Tag:SetState(1) elseif state == CTL.Activities.ActivityState.End then cellTable.state_Tag:SetState(2) end cellTable.cell:SetRedPoint(CTL.MonthBossChallenge.CanReceiveScoreRewardByBossId(data)) end end function UISubjectMonthChallenge:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.group_Scroll then self:SelectBoss(data) end end function UISubjectMonthChallenge:SelectBoss(bossId) self.bossId = bossId MDL.SubjectMonth.GetSubjectMonthRankRecordReq(MDL.SubjectMonth.SubActivityType.BossChallenge, self.bossId, true) self:SetBossTime() self:SetRightPanelInfo() self:SetBossModel() end function UISubjectMonthChallenge:SetBossTime() local bossData = DataSheetManager.VersionsBossChallengeBoss:GetDataByID(self.bossId) local state, leftTime = CTL.MonthBossChallenge.GetStateByBossId(self.bossId) local color = GreenColor if state == CTL.Activities.ActivityState.End then color = UTL.Color.Red end UIUtils.SetLabel(self.txt_Time, UTL.Color.FormatTextByColor(color, CTL.MonthBossChallenge.GetOpenTimeByBossId(self.bossId))) UIUtils.SetImageByAssetBundle(self.img_Icon, string.format(HeadImgPath, bossData.Icon)) end function UISubjectMonthChallenge:InitPanelBaseInfo() local bossData = DataSheetManager.VersionsBossChallengeBoss:GetDataByID(self.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 = CTL.MonthBossChallenge.GetLevelCfg(self.bossId) 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 local state, leftTime = CTL.MonthBossChallenge.GetStateByBossId(self.bossId) if state == CTL.Activities.ActivityState.NotOpen then local dayStr = string.FormatByIdsId(Const_IDS.IDS_VersionsActivity_Boss_Hint4, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_1)) local hourStr = string.FormatByIdsId(Const_IDS.IDS_VersionsActivity_Boss_Hint4, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_2)) local minStr = string.FormatByIdsId(Const_IDS.IDS_VersionsActivity_Boss_Hint4, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_3)) local secStr = string.FormatByIdsId(Const_IDS.IDS_VersionsActivity_Boss_Hint4, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_4)) self.txt_Preview:SetDHMSStr(dayStr, hourStr, minStr, secStr) self.txt_Preview:ResetAndBeginCustomTimer(false, leftTime, 0, nil) self.state_Btn:SetState(0) elseif state == CTL.Activities.ActivityState.Opening then self.state_Btn:SetState(1) elseif state == CTL.Activities.ActivityState.End then self.state_Btn:SetState(2) end end function UISubjectMonthChallenge:SetRightPanelInfo() self:InitPanelBaseInfo() self:SetRankInfo() self.btn_ScoreReward:SetRedPoint(MDL.MonthBossChallenge.HasReward()) end function UISubjectMonthChallenge:SetRankInfo() --分数相关 UIUtils.SetLabel(self.txt_TotalScore, MDL.MonthBossChallenge.GetScoreByBossId(self.bossId)) --排名相关 local myRank = MDL.SubjectMonth.GetMyRankInfo(MDL.SubjectMonth.SubActivityType.BossChallenge, self.bossId) if myRank and myRank.index > 0 then UIUtils.SetLabel(self.txt_Rank, myRank.index) else UIUtils.SetLabelText(self.txt_Rank, Const_IDS.IDS_3v3UnRanked) end end function UISubjectMonthChallenge:SetBossModel() UTL.UIRender.DisposePlayerModel(self.modelComponentHandle) local bossData = DataSheetManager.VersionsBossChallengeBoss:GetDataByID(self.bossId) 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 UISubjectMonthChallenge:OnClosed() UTL.UIRender.DisposeModelComponentData(self.modelComponentHandle) UIManager.ActiveUIModle(true, "UISubjectMonthChallenge") if self.effectResult then self.effectResult:Dispose() self.effectResult = nil end end function UISubjectMonthChallenge:OnClickChallenge() local state, leftTime = CTL.MonthBossChallenge.GetStateByBossId(self.bossId) if state == CTL.Activities.ActivityState.NotOpen then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_3307_InfoCode_GVGFight_SeasonNotOpen"]) elseif state == CTL.Activities.ActivityState.Opening then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISubjectMonthChallengeFormation, {bossId = self.bossId}, Const_UI_Lua.UIEnum.UIBossChallengeFormation) elseif state == CTL.Activities.ActivityState.End then CTL.Tips.AddTipsMsg(Const_IDS["IDS_GoldHeroActivity_TimeHint3"]) end end function UISubjectMonthChallenge: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 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.MonthBossChallenge, params = {[1] = CTL.MonthBossChallenge.GetRankSettlementTime()} }) elseif comp == self.btn_Rank then UIManager.OpenView(Const_UI_Lua.UIEnum.UISubjectMonthRewardMain, {type = 1, bossId = self.bossId}) elseif comp == self.btn_Challenge then self:OnClickChallenge() elseif comp == self.btn_Strategy then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = SingleBossGuideTipsIdBase + self.bossId}) elseif comp == self.btn_BuffInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UISubjectMonthChallengeBuff, {bossId = self.bossId}, Const_UI_Lua.UIEnum.UIBossChallengeBuff) elseif comp == self.btn_RankReward then UIManager.OpenView(Const_UI_Lua.UIEnum.UISubjectMonthRewardMain, {type = 2, bossId = self.bossId}) elseif comp == self.btn_ScoreReward then UIManager.OpenView(Const_UI_Lua.UIEnum.UISubjectMonthRewardMain, {type = 3, bossId = self.bossId}) else for i, v in ipairs(self.group_BuffInfos) do if comp == v then CTL.Tips.CloseSkillTips(self.SkillTips) local buffId = CTL.MonthBossChallenge.GetLevelCfg(self.bossId).BuffID[i] CTL.Tips.OpenSkillTips(buffId, self.SkillTips, CTL.Tips.SkillType.ConstantBuff) return end end end end function UISubjectMonthChallenge:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView(true) end end end return UISubjectMonthChallenge