local UIKingChallengeMainPanel = UIViewClass() function UIKingChallengeMainPanel:OnOpened() CTL.KingChallenge.TryAutoOpenBuffUI() MDL.KingChallenge.OpenKingChallengePanelRequest() self:RegistSystemEvent(EventID.UI_KingChallenge_MainRefresh, self.RefreshSeasonData) self:RegistSystemEvent(EventID.UI_KingChallenge_RewardBoxRefresh, self.RefreshRewardBox) self:InitBigSeasonInfo() self:RefreshRewardBox() local KingChallengeSpecialSeasonID = DataSheetManager.ConstData:GetDataByID("KingChallengeSpecialSeasonID").IntValue UIUtils.SetActive(self.img_treble, MDL.KingChallenge.GetCurBigSeasonId() == KingChallengeSpecialSeasonID) self.lab_Weektotal.text = string.FormatByIdsId(Const_IDS["IDS_KingChallenge_Hint5"], CTL.KingChallenge.GetCurSeasonReachRewardCondition()) end function UIKingChallengeMainPanel:InitBigSeasonInfo() self.curBigSeasonId = MDL.KingChallenge.GetCurBigSeasonId() UIUtils.SetActive(self.btn_history, self.curBigSeasonId > 1) --首赛季不显示赛季回顾按钮 local bigSeasonCfg = DataSheetManager.KingChallengeSeason:GetDataByID(self.curBigSeasonId) if self.Loc_tuttle.CurState == 1 then self.Loc_tuttle:SetText(0, UIUtils.GetLocalizedTxt(Const_IDS[bigSeasonCfg.SeasonName])) else self.Loc_tuttle:SetImage(0, bigSeasonCfg.SeasonArtName, true) end UIUtils.SetActive(self.buff_btn, CTL.KingChallenge.IsHasSeasonBuff()) UIUtils.SetImageByAssetBundle(self.img_Bg, bigSeasonCfg.SeasonPic) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_KingChallenge_Title) end function UIKingChallengeMainPanel:RefreshSeasonData() self.curLittleSeasonNum = MDL.KingChallenge.GetCurLittleSeasonNum() local curBigSeasonInfo = MDL.KingChallenge.GetCurSeasonInfo() local startTime = os.date(UTL.Time.FormatDateEnum.YMD, curBigSeasonInfo.seasonStartTime) local endFuncTime = os.date(UTL.Time.FormatDateEnum.YMD, curBigSeasonInfo.seasonEndTime) self.lab_time.text = " "..startTime .. "-" .. endFuncTime self.startLittleSeasonId = MDL.KingChallenge.GetCurStartLittleSeasonId() self.curLittleSeasonId = MDL.KingChallenge.GetCurLittleSeasonId() local index for i = 1, self.curLittleSeasonNum do UIUtils.SetActive(self.group_season_left[i].gameObject, true) UIUtils.SetActive(self.group_season_right[i].gameObject, true) local littleSeasonId = self.startLittleSeasonId + i - 1 UIUtils.SetLabel(self.group_season_left[i].lab_season, string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint2, littleSeasonId)) UIUtils.SetLabel(self.group_season_right[i].lab_season, string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint2, littleSeasonId)) if littleSeasonId > self.curLittleSeasonId then -- 赛季未开启 置灰 self:RefreshFutureSeasonStatus(i) elseif littleSeasonId == self.curLittleSeasonId then -- 当前赛季 self:RefreshCurSeasonStatus(i, littleSeasonId) else -- 已过赛季 self:RefreshPastSeasonStatus(i, littleSeasonId) end index = i end for i = index + 1, #self.group_season_left do UIUtils.SetActive(self.group_season_left[i].gameObject, false) UIUtils.SetActive(self.group_season_right[i].gameObject, false) end if self.curLittleSeasonNum == 4 then --当四个小赛季时更换布局 self.group_PosState:SetState(1) self.group_PosState2:SetState(1) self.group_ScaleState:SetState(1) else self.group_PosState:SetState(0) self.group_PosState2:SetState(0) self.group_ScaleState:SetState(0) end end function UIKingChallengeMainPanel:RefreshFutureSeasonStatus(i) UIUtils.SetActive(self.group_season_left[i].sprite_Activities_gray, true) UIUtils.SetActive(self.group_season_right[i].sprite_Activities_gray, true) self.group_season_left[i].state_ResultMark:SetState(3) self.group_season_right[i].state_ResultMark:SetState(3) UIUtils.SetActive(self.group_season_left[i].img_endtime, false) UIUtils.SetActive(self.group_season_right[i].img_endtime, false) end function UIKingChallengeMainPanel:RefreshCurSeasonStatus(i, littleSeasonId) UIUtils.SetActive(self.group_season_left[i].sprite_Activities_gray, false) UIUtils.SetActive(self.group_season_right[i].sprite_Activities_gray, false) local isReach, isPlayReachEffect = MDL.KingChallenge.Is1V1ReachKingInCurBigSeason(littleSeasonId) if isReach then --1v1达标 self.group_season_left[i].state_ResultMark:SetState(1) if isPlayReachEffect then -- 播放达成特效 self.group_season_left[i].effect_Unlock:PlayUIEffect() end else self.group_season_left[i].state_ResultMark:SetState(2) end local isReach, isPlayReachEffect = MDL.KingChallenge.Is3v3ReachKingInCurBigSeason(littleSeasonId) if isReach then --3v3达标 self.group_season_right[i].state_ResultMark:SetState(1) if isPlayReachEffect then -- 播放达成特效 self.group_season_right[i].effect_Unlock:PlayUIEffect() end else self.group_season_right[i].state_ResultMark:SetState(2) end if MDL.SyncSolo.IsSeasonOpen() then UIUtils.SetActive(self.group_season_left[i].img_endtime, true) UIUtils.SetActive(self.group_season_right[i].img_endtime, true) self:RefreshCurLittleSeasonLeftTime(self.group_season_left[i].lab_endtime, MDL.SyncSolo.GetNextTime()) self:RefreshCurLittleSeasonLeftTime(self.group_season_right[i].lab_endtime, MDL.SyncSolo.GetNextTime()) else UIUtils.SetActive(self.group_season_left[i].img_endtime, false) UIUtils.SetActive(self.group_season_right[i].img_endtime, false) end end function UIKingChallengeMainPanel:RefreshPastSeasonStatus(i, littleSeasonId) UIUtils.SetActive(self.group_season_left[i].sprite_Activities_gray, false) UIUtils.SetActive(self.group_season_right[i].sprite_Activities_gray, false) if MDL.KingChallenge.Is1V1ReachKingInCurBigSeason(littleSeasonId) then self.group_season_left[i].state_ResultMark:SetState(1) --已达成 else self.group_season_left[i].state_ResultMark:SetState(0) --未达成 end if MDL.KingChallenge.Is3v3ReachKingInCurBigSeason(littleSeasonId) then self.group_season_right[i].state_ResultMark:SetState(1) --已达成 else self.group_season_right[i].state_ResultMark:SetState(0) --未达成 end UIUtils.SetActive(self.group_season_left[i].img_endtime, false) UIUtils.SetActive(self.group_season_right[i].img_endtime, false) end function UIKingChallengeMainPanel:RefreshCurLittleSeasonLeftTime(lab_endtime, leftTime) local dayStr = string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint3, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_1)) local hourStr = string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint3, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_2)) local minStr = string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint3, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_3)) local secStr = string.FormatByIdsId(Const_IDS.IDS_KingChallenge_Hint3, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_4)) lab_endtime:SetDHMSStr(dayStr, hourStr, minStr, secStr) lab_endtime:ResetAndBeginCustomTimer(false, leftTime, 0, nil) end function UIKingChallengeMainPanel:RefreshRewardBox() local rewardStatus = MDL.KingChallenge.GetRewardStatus() if rewardStatus == MDL.KingChallenge.KingChallengeRewardStatus.RewardNotReach then self.state_box:SetState(0) elseif rewardStatus == MDL.KingChallenge.KingChallengeRewardStatus.RewardCanGet then self.state_box:SetState(1) else self.state_box:SetState(2) end end function UIKingChallengeMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.btn_Close) end function UIKingChallengeMainPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.KingChallenge}) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_history then UIManager.OpenView(Const_UI_Lua.UIEnum.UIKingChallengeSeasonReview) elseif comp == self.group_box then local rewardStatus = MDL.KingChallenge.GetRewardStatus() if rewardStatus == MDL.KingChallenge.KingChallengeRewardStatus.RewardCanGet then MDL.KingChallenge.KingChallengeReceiveRewardRequest() else UIManager.OpenView(Const_UI_Lua.UIEnum.UIKingChallengeRewardPopUp) end elseif comp == self.buff_btn then UIManager.OpenView(Const_UI_Lua.UIEnum.UIKingChallengeSeasonBuffPopUp) else for i = 1, self.curLittleSeasonNum do if comp == self.group_season_left[i].img_Bgseason then self:OnClickSeasonBtn(i, true) return elseif comp == self.group_season_right[i].img_Bgseason then self:OnClickSeasonBtn(i, false) return end end end end function UIKingChallengeMainPanel:OnClickSeasonBtn(i, is1v1) self.startLittleSeasonId = MDL.KingChallenge.GetCurStartLittleSeasonId() local littleSeasonId = self.startLittleSeasonId + i - 1 if littleSeasonId > self.curLittleSeasonId then -- 赛季未开启 CTL.Tips.AddTipsMsg(Const_IDS["IDS_KingChallenge_Hint24"]) else local isReach if is1v1 then isReach= MDL.KingChallenge.Is1V1ReachKingInCurBigSeason(littleSeasonId) else isReach = MDL.KingChallenge.Is3v3ReachKingInCurBigSeason(littleSeasonId) end if isReach then CTL.Tips.AddTipsMsg(Const_IDS["IDS_KingChallenge_Hint26"]) else if littleSeasonId == self.curLittleSeasonId then -- 当前赛季 CTL.Tips.AddTipsMsg(Const_IDS["IDS_KingChallenge_Hint25"]) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_KingChallenge_Hint27"]) end end end end return UIKingChallengeMainPanel