-- 暴风选关界面 local UIStormEntrance = UIViewClass() function UIStormEntrance:OnOpened(context) self:RegistSystemEvent(EventID.UI_Storm_RefreshMain, self.RefreshLevelInfo) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Storm, self.RefreshLevelInfo) -- 标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_ActivityName_Storm"]) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self.openInfo = MDL.Storm.GetStormInfo() if CTL.Activities.IsOpeningTime(LuaConst.ActivityType.Storm) then MDL.Storm.GetStormMainPanelInfoReq() else self:RefreshLevelInfo() end end function UIStormEntrance:UpdateLevelInfo() for index, collection in ipairs(self.Content) do self:SetOpenLevelInfo(index, collection) end end function UIStormEntrance:RefreshLevelInfo() -- 刷新入口显示 self:UpdateLevelInfo() -- 奖励按钮红点 self.event_Reward:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Storm_AchievementReward)) local rankIndex = MDL.Storm.GetMyRankIndex() -- 我的排名 if rankIndex > 0 then UIUtils.SetLabel(self.txt_Rank, string.FormatByIdsId(Const_IDS["IDS_Storm_DailyRank"], rankIndex)) UIUtils.SetActive(self.Bottom.gameObject, true) -- 排名奖励 self.RewardScroll:ReloadAll(MDL.Storm.GetRankRewardData(rankIndex)) else UIUtils.SetLabel(self.txt_Rank, string.FormatByIdsId(Const_IDS["IDS_Storm_DailyRank"], UIUtils.GetLocalizedTxt(Const_IDS["IDS_GuildBoss_NoDamage"]))) UIUtils.SetActive(self.Bottom.gameObject, false) end end function UIStormEntrance:SetOpenLevelInfo(index, collection) -- 关卡名称 local levelData = DataSheetManager.StormLevel:GetDataByID(index) UIUtils.SetLabelText(collection.txt_Name, Const_IDS[levelData.LevelName]) local leftTime = UTL.Time.TotalSecondsOneDay - UTL.Time.GetServerSecondsIntervalFromZero() UIUtils.SetActive(collection.img_RedPoint.gameObject, false) UIUtils.SetImageByAssetBundle(collection.img_Frame_Task, levelData.VerticalImage) UTL.Item.SetLocalizationImage(collection.loc_Txt, collection.img_Name, levelData.NamePath) if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Storm) then -- 功能未解锁 collection.state:SetState(0) collection.txt_LimitTime:EndTimer() collection.txt_LimitTime:SetCDLabel(UIUtils.GetLocalizedTxt(Const_IDS["IDS_Storm_NotYetOpen"])) elseif not CTL.Activities.IsOpeningTime(LuaConst.ActivityType.Storm) then -- 未在活动时间之内 collection.state:SetState(0) UIUtils.SetActive(collection.group_Lock.gameObject, false) collection.txt_LimitTime:EndTimer() collection.txt_LimitTime:SetCDLabel(UIUtils.GetLocalizedTxt(Const_IDS["IDS_BossChallenge_NotOpen"])) elseif MDL.Storm.GetOpenTimeByLevelType(index) then collection.state:SetState(2) local dayStr = string.FormatByIdsId(Const_IDS.IDS_7DayActivityNew_Hint1, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime1)) local hourStr = string.FormatByIdsId(Const_IDS.IDS_7DayActivityNew_Hint1, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime2)) local minStr = string.FormatByIdsId(Const_IDS.IDS_7DayActivityNew_Hint1, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime3)) local secStr = string.FormatByIdsId(Const_IDS.IDS_7DayActivityNew_Hint1, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime4)) collection.txt_Time:SetDHMSStr(dayStr, hourStr, minStr, secStr) local offset = MDL.Storm.GetOpenTimeByLevelType(index) - UTL.Time.GetServerTimestamp() collection.txt_Time:ResetAndBeginCustomTimer(false, offset, 0, 1) else collection.state:SetState(1) collection.state_countries:SetState(self.openInfo.countryId - 1) local dayStr = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_52, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_1)) local hourStr = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_52, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_2)) local minStr = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_52, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_3)) local secStr = string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_52, UIUtils.GetLocalizedTxt(Const_IDS.IDS_DirectGift_TimeHint_4)) collection.txt_LimitTime:SetDHMSStr(dayStr, hourStr, minStr, secStr) collection.txt_LimitTime:ResetAndBeginCustomTimer(false, MDL.Storm.GetCurActivityLeftTime(), 0, nil) UIUtils.SetActive(collection.img_RedPoint.gameObject, CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Storm)) end end function UIStormEntrance:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.RewardScroll then UTL.Item.SetItemCell(cellTable.item, data.ItemID, data.ItemNum, false) end end function UIStormEntrance:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.RewardScroll then if target == cellTable.item.event_Click then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end end function UIStormEntrance:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIStormEntrance:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end function UIStormEntrance:OnButtonClicked(comp) if comp == self.event_Rank then 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.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.Storm }) 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.Content) do if comp == v.btn_Select then -- 1 和 3位是左右两个关卡,现写死未开放 if MDL.Storm.GetOpenTimeByLevelType(index) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Storm_NotYetOpen"]) return else if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Storm) then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_GMS_ActivityClosed"])) return elseif not CTL.Activities.IsOpeningTime(LuaConst.ActivityType.Storm) then CTL.Storm.PopNotInTimeTip() return end if CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Storm_Entry) then MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.Storm, 1, true, LuaConst.ActivityType.Storm) self:StartRepeatFunc( CTL.Storm.RefreshRed, 0.8, 1) end UIManager.OpenView(Const_UI_Lua.UIEnum.UIStormMain) end end end end end return UIStormEntrance