-- 暴风关卡主界面 local UIStormMain = UIViewClass() local SETTLEMENT_TIME_ID = 6011 local DIFF_PERCENT = DataSheetManager.ConstData:GetDataByID("StormRecommendedDifficulty").IntValue / 100 function UIStormMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_Storm_RefreshMain, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_FreeLineUp_RefreshUI, self.RefreshGSAndLineup) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) UIUtils.SetActive(self.event_Rank, false) UIUtils.SetLabelText(self.lab_Event, Const_IDS["IDS_Storm_SeeAll"]) self:RefreshPanel() self:StartRepeatFunc(self.OnUpdateFun, 1) self.leftTime = UTL.Time.TotalSecondsOneDay - UTL.Time.GetServerSecondsIntervalFromZero() self:RefreshRecommendGS() end function UIStormMain:OnUpdateFun(deltaTime, timeSinceUpdate) self.leftTime = self.leftTime - 1 if self.leftTime <= 0 then self:CloseView() CTL.Tips.AddTipsMsg(Const_IDS["IDS_DemonGod_UI_54"]) end end function UIStormMain:RefreshAllDifficultInfo() for index, collectin in ipairs(self.group_Lineup) do UIUtils.SetLabelText(collectin.lab_Event, Const_IDS["IDS_Storm_EachArmyFightCapacity2"]) self:RefreshDifficultInfo(index) end end function UIStormMain:RefreshGSAndLineup() self:UpdatePlayerRankHead() self:UpdateHeroLineUpInfo() end function UIStormMain:RefreshPanel() self.stormInfo = MDL.Storm.GetStormInfo() -- 当前关卡名称 local data = MDL.Storm.GetStormOpenLevelData() local levelNameIDS = Const_IDS[data.LevelName] UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, levelNameIDS) UIUtils.SetLabelText(self.txt_Name, levelNameIDS) UIUtils.SetLabelText(self.lab_Title02, Const_IDS.IDS_DemonGod_UI_21) UIUtils.SetLabel(self.txt_Rank, self.stormInfo.myRank) UIUtils.SetImageByAssetBundle(self.Bg1, data.LandscapeImage) self.Bg1:SetNativeSize() UTL.Item.SetLocalizationImage(self.loc_Txt, self.Img_Name, data.NamePath) self.event_Reward:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Storm_AchievementReward)) -- 限定国别 self.state_countries:SetState(self.stormInfo.countryId - 1) -- 我的积分 UIUtils.SetLabel(self.txt_Scores, MDL.Storm.GetTodayMaxScore()) -- 阵容、排行、推荐等级 self:RefreshGSAndLineup() self:RefreshAllDifficultInfo() --挑战倒计时 local dayStr = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_53, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_1)) local hourStr = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_53, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_2)) local minStr = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_53, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_3)) local secStr = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_53, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_4)) self.txt_Time:SetDHMSStr(dayStr, hourStr, minStr, secStr) self.txt_Time:ResetAndBeginCustomTimer(false, MDL.Storm.GetCurActivityLeftTime(), 0, nil) end function UIStormMain:RefreshRecommendGS() for index, v in ipairs(self.group_Lineup) do if v.curDifficultData.ID ~= v.recommendLevelData.ID then self:SetDifficultLevel(index, v.recommendLevelData.ID) end end end -- 更新排行 function UIStormMain:UpdatePlayerRankHead() for i, compCollection in ipairs(self.group_Rank_Arr) do UIUtils.SetLabel(compCollection.lab_Rank, i) if self.stormInfo.topPlayer and self.stormInfo.topPlayer[i] then compCollection.UIHeroHead95.obj_HeadState:SetState(0) UIUtils.SetActive(compCollection.group_PlayerName.gameObject, true) local playerInfo = self.stormInfo.topPlayer[i] CTL.Player.OperateGenderImage(compCollection.image_Gender, playerInfo.sex) CTL.Character.SetPortraitAndFrame(compCollection.UIHeroHead95, playerInfo.PortraitId, playerInfo.FrameId) UIUtils.SetLabel(compCollection.lab_HeroName, playerInfo.name) UIUtils.SetLabel(compCollection.lab_Empty, "") else CTL.Character.SetHeadEmpty(compCollection.UIHeroHead95) UIUtils.SetActive(compCollection.group_PlayerName.gameObject, false) UIUtils.SetLabelText(compCollection.lab_Empty, Const_IDS.IDS_Guild_BlankContent) end end end function UIStormMain:UpdateHeroLineUpInfo() local lineupArr = self.stormInfo.simpleLineUp for index, collection in ipairs(self.group_Lineup) do collection.curDifficultData = DataSheetManager.StormLevelBR:GetDataByID(MDL.Storm.GetLastSelectDifficultID(index)) collection.recommendLevelData = self:GetRecommendBR(index, collection) local lineupInfo = lineupArr[index] local isShowChallengeBtn = true if lineupInfo.mainHeroId > 0 then for i, headCollection in ipairs(collection.hero_Head_Arr) do headCollection.StateSwitch:SetState(1) local quality if i == 1 then UIUtils.SetLabel(headCollection.txt_BR, lineupInfo.mainGs) quality = CTL.HeroAwaken.GetHeroQuality(lineupInfo.mainHeroId, lineupInfo.mainHeroAwaken) UTL.Item.SetHeroIconByHeroId(headCollection.img_SelectedHero, lineupInfo.mainHeroId, lineupInfo.mainHeroAwaken) else UIUtils.SetLabel(headCollection.txt_BR, lineupInfo.otherGs) if lineupInfo.otherHeroId > 0 then quality = CTL.HeroAwaken.GetHeroQuality(lineupInfo.otherHeroId, lineupInfo.otherHeroAwaken) UTL.Item.SetHeroIconByHeroId(headCollection.img_SelectedHero, lineupInfo.otherHeroId, lineupInfo.otherHeroAwaken) end end if quality then headCollection.StateSwitch:SetState(0) UTL.Color.SetQualityImageByType(headCollection.img_QualityFrame, quality, UTL.Color.QualityType.HeroSelectFrame) UTL.Color.SetQualityImageByType(headCollection.img_QualityHead, quality, UTL.Color.QualityType.HeroSelectBg) end end collection.txt_BR.text = CTL.Storm.GetFormattedSubjugateGS(collection.curDifficultData.SubjugateDataPVE, lineupInfo.gs, lineupInfo.gs) collection.txt_Score.text = lineupInfo.score > 0 and UTL.Color.FormatGreenColor(lineupInfo.score) or UIUtils.GetLocalizedTxt(Const_IDS["IDS_Storm_NoRecord"]) else isShowChallengeBtn = false for i, headCollection in ipairs(collection.hero_Head_Arr) do headCollection.StateSwitch:SetState(1) end collection.txt_BR.text = CTL.Storm.GetFormattedSubjugateGS(collection.curDifficultData.SubjugateDataPVE, 0, 0) collection.txt_Score.text = UIUtils.GetLocalizedTxt(Const_IDS["IDS_Storm_NoRecord"]) end -- 槽位解锁标识 if MDL.FreeLineUp.IsTeamSlotLocked(index) then UIUtils.SetActive(collection.group_info.gameObject, false) UIUtils.SetActive(collection.event_Difficulty.gameObject, false) UIUtils.SetActive(collection.group_Ban.gameObject, true) UIUtils.SetActive(collection.txt_Challenge, false) local tlData = DataSheetManager.TeamLevelData:GetDataByTeamLevel(MDL.FreeLineUp.FreeLineUpSlotUnlockList[index]) if tlData then local _levelStr = UTL.Item.GetNobilityByTeamLevel(tlData.TeamLevel) -- 爵位转换 local teamLevelName = string.FormatByIdsId(Const_IDS[tlData.TeamLevelName], _levelStr) UIUtils.SetLabel(collection.lab_Title01, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_51, teamLevelName)) end else UIUtils.SetActive(collection.group_info.gameObject, true) UIUtils.SetActive(collection.event_Difficulty.gameObject, true) UIUtils.SetActive(collection.group_Ban.gameObject, false) UIUtils.SetActive(collection.txt_Challenge, true) end UIUtils.SetActive(collection.btn_Challenge, isShowChallengeBtn) end end function UIStormMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIStormMain:OnButtonClicked(comp) if comp == self.btn_Recommend then -- 进入排行榜前更新一下主界面最新状态 MDL.Storm.GetStormMainPanelInfoReq() UIManager.OpenView(Const_UI_Lua.UIEnum.UIStormRank) elseif comp == self.event_Reward then UIManager.OpenView(Const_UI_Lua.UIEnum.UIStormRewardMain) elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Team then self:OpenLineUp() elseif comp == self.UITemplateTitlePanel.btn_Info then CTL.Storm.OpenNoteView() elseif comp == self.btn_Shop then if GameAppInfo.IsVietnamPackage() then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.TiaoZhan}) -- 跳转兽魂商店 else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.Storm}) -- 跳转暴风商店 end else for index, v in ipairs(self.group_Lineup) do if comp == v.btn_Challenge then self:OnClickChallenge(v, index) return elseif comp == v.event_Difficulty then self.curSelectLine = index self:OnShowDifficultLoop(v ,true) CTL.Sound.PlayGameSound("UI_expand") elseif comp == self.event_CloseDifficulty then self:OnShowDifficultLoop(v, false) CTL.Sound.PlayGameSound("UI_fold") elseif comp == v.btn_Recommend then -- 推荐难度 self:SetDifficultLevel(index, v.recommendLevelData.ID) elseif comp == v.button_click then self:OpenLineUp() end end end end function UIStormMain:OpenLineUp() if not MDL.Storm.IsOpen() then CTL.Storm.PopNotInTimeTip() return end UIManager.OpenView( Const_UI_Lua.UIEnum.UIStormSelectOfficer, { freeLineupFuncType = MDL.FreeLineUp.FuncType.Storm, activityType = LuaConst.ActivityType.Storm }, Const_UI_Lua.UIEnum.UIDemonGodSelectOfficer ) end function UIStormMain:OnClickChallenge(collection, lineNum) if not MDL.Storm.IsOpen() then CTL.Storm.PopNotInTimeTip() return end -- 点击刷新当前军推荐战力 collection.lastChallengeLine = lineNum collection.recommendLevelData = self:GetRecommendBR(lineNum, collection) local recommendData = collection.recommendLevelData local curDifficultID = collection.curDifficultData.ID local diffBRVal = math.abs(MDL.Storm.GetLineupGS_LineNum(lineNum) - collection.curDifficultData.RecommendBRClientShow) local levelDiffVal = DIFF_PERCENT * collection.curDifficultData.RecommendBRClientShow if curDifficultID ~= recommendData.ID and diffBRVal > levelDiffVal then -- 非推荐战力且差值绝对值大于当前难度推荐战力 UTL.String.FormatCombineTextByID(recommendData.LevelNameColorful) local showStr = string.FormatByIdsId( Const_IDS["IDS_Storm_DifficultyTips2"], UTL.String.FormatCombineTextByID(recommendData.LevelNameColorful)) UTL.MessageBox.ShowOKCancelBox( nil, showStr, function() self:SetDifficultLevel(lineNum, recommendData.ID) UIManager.OpenView(Const_UI_Lua.UIEnum.UIStormChooseSkill, { lineNum = lineNum, levelID = recommendData.ID }) -- 确认 end, function() UIManager.OpenView(Const_UI_Lua.UIEnum.UIStormChooseSkill, { lineNum = lineNum, levelID = curDifficultID }) -- 取消 end, UIUtils.GetLocalizedTxt(Const_IDS. IDS_Storm_Select1), UIUtils.GetLocalizedTxt(Const_IDS. IDS_Storm_Select2) ) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIStormChooseSkill, { lineNum = lineNum, levelID = curDifficultID }) end end --region ------- 推荐难度相关 -------------------- function UIStormMain:RefreshDifficultInfo(index) local collection = self.group_Lineup[index] local recommendData = collection.recommendLevelData collection.txt_Difficulty.text = UTL.String.FormatCombineTextByID(collection.curDifficultData.LevelNameColorful) UIUtils.SetActive(collection.btn_Recommend, collection.curDifficultData.ID ~= recommendData.ID) local showGSStr = CTL.Storm.GetFormattedSubjugateGS(collection.curDifficultData.SubjugateDataPVE, MDL.Storm.GetLineupGS_LineNum(collection.lastChallengeLine or index), collection.curDifficultData.RecommendBRClientShow) UIUtils.SetLabel(collection.txt_Challenge, string.FormatByIdsId(Const_IDS["IDS_Storm_ScoreMultiple"], collection.curDifficultData.LevelScoreCoef)) --UIUtils.SetLabel(self.txt_ScoresTips, string.FormatByIdsId(Const_IDS["IDS_Storm_ScoreMultiple"], collection.curDifficultData.LevelScoreCoef)) UIUtils.SetLabel(collection.txt_RecScores, string.FormatByIdsId(Const_IDS["IDS_Storm_EachArmyFightCapacity"], showGSStr)) end -- 显隐难度等级 function UIStormMain:OnShowDifficultLoop(collection, isShow) if self.loop_Difficulty.gameObject.activeInHierarchy ~= isShow then if isShow then UIUtils.SetActive(collection.img_Arrow01, false) UIUtils.SetActive(collection.img_Arrow02, true) UIUtils.SetActive(self.loop_Difficulty, true) -- 四国最大通关 self.passedRecord = MDL.Storm.GetMaxPassedLevels() self.loop_Difficulty:ClearCells() local selectIndex = 0 local maxShowLevelID = collection.recommendLevelData.LevelShow for i, v in DataSheetManager.StormLevelBR:GetEnumerator() do if v.LevelID == collection.recommendLevelData.LevelID then if collection.curDifficultData.ID == v.ID then selectIndex = i - 1 end if v.ID <= maxShowLevelID then self.loop_Difficulty:AddData(v, 0) end end end self.loop_Difficulty:MoveIndex(selectIndex) else UIUtils.SetActive(collection.img_Arrow01, true) UIUtils.SetActive(collection.img_Arrow02, false) UIUtils.SetActive(self.loop_Difficulty, false) end end end function UIStormMain:OnCellInit(scrollRect, index, cellTable, data) for lineNum, collection in ipairs(self.group_Lineup) do if lineNum == self.curSelectLine then -- 最大通关字符 local maxPassedStr = "" for i = 1, 4 do if self.passedRecord[i] == data.ID then maxPassedStr = maxPassedStr .. CTL.Country.GetCountryNameWithColorAndColon(i) end end if #maxPassedStr > 0 then UIUtils.SetLabel(cellTable.txt_HighestPassDifficulty, string.FormatByIdsId(Const_IDS["IDS_Storm_HighestPassDifficulty"], maxPassedStr)) else UIUtils.SetLabel(cellTable.txt_HighestPassDifficulty, maxPassedStr) end -- 推荐战力 local brTxtShow = CTL.Storm.GetFormattedSubjugateGS( data.SubjugateDataPVE, MDL.Storm.GetLineupGS_LineNum(collection.lastChallengeLine or lineNum), data.RecommendBRClientShow ) UIUtils.SetLabel(cellTable.txt_RecommendBR, string.FormatByIdsId(Const_IDS["IDS_Storm_RecommendFightingCapacity"], brTxtShow)) -- 难度等级名称 cellTable.txt_DifficultyChoose.text = UTL.String.FormatCombineTextByID(data.LevelNameColorful) UIUtils.SetActive(cellTable.img_DifficultySelected.gameObject, data.ID == collection.curDifficultData.ID) UIUtils.SetActive(cellTable.txt_DifficultyChoose, data.ID == data.ID) end end end function UIStormMain:OnCellSelect(scrollRect, index, cellTable, data) for lineNum, collection in ipairs(self.group_Lineup) do if lineNum == self.curSelectLine then self:SetDifficultLevel(lineNum, data.ID) end end end function UIStormMain:SetDifficultLevel(lineNum, ID) local collection = self.group_Lineup[lineNum] -- 选择难度刷新 collection.curDifficultData = DataSheetManager.StormLevelBR:GetDataByID(ID) -- 本地保存选中记录 MDL.Storm.SetLastSelectDifficultID(lineNum, ID) self:RefreshGSAndLineup() self:OnShowDifficultLoop(collection, false) self:RefreshDifficultInfo(lineNum) end function UIStormMain:GetRecommendBR(lineNum, collection) local data = MDL.Storm.GetStormOpenLevelData() return MDL.Storm.GetRecommendBR(collection.lastChallengeLine or lineNum, data.LevelID) end --endregion --------------------------- return UIStormMain