local UINewYearMain = UIViewClass() function UINewYearMain:OnOpened(context) self.activityId = context.activityId self.activityType = MDL.OperationActivity.ActivityType.NewYear self.modeData = MDL.OperationActivity.ActivityBaseData[self.activityType]:GetDataByActivityID(self.activityId) self.textGroup = self.modeData.TextGroup UIUtils.SetActive(self.group_TextInfo, self.textGroup > 0) self:RegistSystemEvent(EventID.UI_NewYear_RefreshRp, self.SetButtonRedPoint) self:RegistSystemEvent(EventID.UI_SceneQuiz_QuizModuleInfoRefresh, self.RefreshSceneQuizState) self:RegistSystemEvent(EventID.UI_SceneQuiz_StageChange, self.RefreshSceneQuizState) self:RegistSystemEvent(EventID.Timeline_OnFinish, self.RefreshCameraOrthographicFunc) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.RefreshDifferEntry) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.NewYear_ExpelMonster, self.SetExpelMonsterBtnRedPoint) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.NewYear_AnniversaryLuckyDraw, self.SetLuckyDrawBtnRedPoint) local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) local startTimeMonth, startTimeDay, startTimeHourMinute = UTL.Time.FormatTimeSimple(activityInfo.startTime) local endTimeMonth, endTimeDay, endTimeHourMinute = UTL.Time.FormatTimeSimple(activityInfo.endTime) if GameAppInfo.IsVietnamPackage() then self.txt_Time.text = os.date(UTL.Time.FormatDateEnum.MDHM, activityInfo.startTime) .. "~" .. os.date(UTL.Time.FormatDateEnum.MDHM, activityInfo.endTime) else self.txt_Time.text = string.FormatByIdsId(Const_IDS.IDS_BattlefieldMuster_Time, startTimeMonth, startTimeDay, startTimeHourMinute, endTimeMonth, endTimeDay, endTimeHourMinute) end self:SetButtonTextAndIcon() self:RefreshTextInfo() self:SetButtonRedPoint() self:SetExpelMonsterBtnRedPoint() self:SetLuckyDrawBtnRedPoint() self:SetPortrait() self:RefreshSceneQuizState() self:RefreshDifferEntry() self:ControlSound(true) CTL.NewYear.OpenCurrencyPanel(CTL.NewYear.ViewName.UINewYearMain, self.activityType, self.activityId, self.currency_Info) UTL.UIRender.AdaptiveImageSizeFit(self.bg_Bottom) end function UINewYearMain:ControlSound(isPlay) --龙年春节活动播放音效 if self.modeData.PrefabMode == 7 then if isPlay then CTL.Sound.PlayGameSound("SFX_luoyang_zhucheng_festival", true) else CTL.Sound.StopGameSound("SFX_luoyang_zhucheng_festival") end end end function UINewYearMain:OnClosed() self:ControlSound(false) end function UINewYearMain:RefreshSceneQuizState() if self.state_SceneQuiz then local curStage = MDL.SceneQuiz.GetCurStage() if curStage == MDL.SceneQuiz.ScheduleStage.PreCompetition then self.state_SceneQuiz:SetState(1) elseif curStage == MDL.SceneQuiz.ScheduleStage.Preliminary then self.state_SceneQuiz:SetState(2) elseif curStage == MDL.SceneQuiz.ScheduleStage.Bet then self.state_SceneQuiz:SetState(3) elseif curStage == MDL.SceneQuiz.ScheduleStage.Finals then self.state_SceneQuiz:SetState(4) else self.state_SceneQuiz:SetState(0) end end end function UINewYearMain:RefreshTextInfo() if self.textGroup > 0 then UIUtils.SetLabelText(self.txt_Info, Const_IDS[CTL.NewYear.GetRandomDialogue(self.textGroup)]) end end function UINewYearMain:SetButtonRedPoint() self.btn_SignIn:SetRedPoint(CTL.NewYear.IsHasLoginReward(self.activityId)) self.btn_Task:SetRedPoint(CTL.OACommon.IsHasTaskRedPoint(self.activityId)) self.btn_Pray:SetRedPoint(CTL.NewYear.IsCanPrayReward(self.activityId) or CTL.NewYear.IsShowActivityRedPoint(self.activityId)) if self.btn_Gift then self.btn_Gift:SetRedPoint(CTL.OACommon.IsHasGiftRedPoint(self.activityId)) end if self.event_SceneQuiz then self.event_SceneQuiz:SetRedPoint(CTL.SceneQuiz.IsShowRedPoint()) end end function UINewYearMain:SetExpelMonsterBtnRedPoint() if self.btn_ExpelMonster then self.btn_ExpelMonster:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.NewYear_ExpelMonster)) end end function UINewYearMain:SetLuckyDrawBtnRedPoint() if self.event_LuckyDraw then self.event_LuckyDraw:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.NewYear_AnniversaryLuckyDraw)) end end function UINewYearMain:OnButtonClicked(comp) if comp == self.btn_SignIn then CTL.NewYear.OpenView(self.activityId, CTL.NewYear.ViewName.UINewYearLoginReward, {activityId = self.activityId, activityType = self.activityType}) elseif comp == self.btn_Task then CTL.NewYear.OpenView(self.activityId, CTL.NewYear.ViewName.UINewYearTaskPanel, {activityId = self.activityId, activityType = self.activityType}) elseif comp == self.btn_Pray then CTL.NewYear.OpenView(self.activityId, CTL.NewYear.ViewName.UINewYearPray, {activityId = self.activityId, activityType = self.activityType}) elseif comp == self.btn_Shop then CTL.NewYear.OpenView(self.activityId, CTL.NewYear.ViewName.UINewYearStorePanel, {activityId = self.activityId, activityType = self.activityType}) elseif comp == self.btn_Gift then CTL.NewYear.OpenView(self.activityId, CTL.NewYear.ViewName.UINewYearGiftMain, {activityType = self.activityType, activityId = self.activityId, Title = "IDS_NewYearActivity_ChildTitle_5"}) elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.NewYear}) elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Dialogue then self:RefreshTextInfo() elseif comp == self.event_SceneQuiz then MDL.SceneQuiz.CurActivityID = self.activityId CTL.SceneQuiz.OpenMainPanel(self.activityId) elseif comp == self.event_LuckyDraw then UIManager.OpenView(Const_UI_Lua.UIEnum.UIAnniversaryLuckyDrawMain, {activityId = self.activityId}) elseif comp == self.btn_ExpelMonster then if CTL.ExpelMonster.IsActivityOpen() then UIManager.OpenView(Const_UI_Lua.UIEnum.UIExpelMonsterMain,{activityId = self.activityId}) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_GMS_ActivityClosed"]) end end end function UINewYearMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UINewYearMain:SetButtonTextAndIcon() UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[self.modeData.TownName]) UIUtils.SetImageByAssetBundle(self.img_SignIn, self.modeData.LoginIcon) self.btn_SignIn:SetText(Const_IDS[self.modeData.LoginName]) UIUtils.SetImageByAssetBundle(self.img_Task, self.modeData.TaskIcon) self.btn_Task:SetText(Const_IDS[self.modeData.TaskName]) UIUtils.SetImageByAssetBundle(self.img_Pray, self.modeData.LuckyBagIcon) self.btn_Pray:SetText(Const_IDS[self.modeData.LuckyBagName]) UIUtils.SetImageByAssetBundle(self.img_Shop, self.modeData.StoreIcon) self.btn_Shop:SetText(Const_IDS[self.modeData.StoreName]) if self.img_Gift then UIUtils.SetImageByAssetBundle(self.img_Gift, self.modeData.GiftIcon) end if self.btn_Gift then self.btn_Gift:SetText(Const_IDS[self.modeData.GiftName]) end end local EmptyLightObjPath = ConstAssetPathConfig.EmptyLightObjPath function UINewYearMain:SetPortrait() local prefabData = DataSheetManager.NewYearPrefabData:GetDataByModeID(self.modeData.PrefabMode) self.bgPath = prefabData.UINewYearMainLive2D UIUtils.SetActive(self.bg_Bottom, string.isNilOrEmpty(self.bgPath)) if not string.isNilOrEmpty(self.bgPath) then self.bgModel:Show2DBGModel(self.bgPath, nil, 2, EmptyLightObjPath) self.bgModel:SetNodePos(0, 0, 0) self.bgModel:SetNodeRot(0, 0, 0) self.bgModel:SetSceneShadowPlane(false) self:RefreshCameraOrthographicFunc() end end function UINewYearMain:RefreshDifferEntry(funcId, isUnlock) if self.event_LuckyDraw then if funcId and funcId == MDL.Unlock.FunctionType.AnniversaryLuckyDraw then if not isUnlock then UIUtils.SetActive(self.event_LuckyDraw, isUnlock) end else local prefabData = DataSheetManager.NewYearPrefabData:GetDataByModeID(self.modeData.PrefabMode) UIUtils.SetActive(self.event_LuckyDraw, MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.AnniversaryLuckyDraw) and prefabData.IsOpenLuckyDraw) end end end function UINewYearMain:RefreshCameraOrthographicFunc() local resolutionRatio = UIUtils.GetScreenResolutionRatio() if self.bgPath == ConstAssetPathConfig.AssetPath151 then local screenWidth, screenHeight = UIUtils.GetScreenSize(1, 1) local ratio = screenWidth/screenHeight if resolutionRatio >= LuaConst.ScreenResolutionRatio.Ratio1920_1080 then CameraController.Instance:ChangeCameraOrthographic(0.96, 0.3) else CameraController.Instance:ChangeCameraOrthographic(0.96 * (1.78/ratio), 0.3) end elseif self.bgPath == "Assets/Actor/Legend/Legend_ZuoCiZhou/Legend_ZuoCiZhou.prefab" then if resolutionRatio >= LuaConst.ScreenResolutionRatio.Ratio1920_1080 then CameraController.Instance:ChangeCameraOrthographic(0.96, 0.3) elseif resolutionRatio >= LuaConst.ScreenResolutionRatio.RatioPadOther then CameraController.Instance:ChangeCameraOrthographic(1.05, 0.3) else CameraController.Instance:ChangeCameraOrthographic(1.28, 0.3) end else if resolutionRatio >= LuaConst.ScreenResolutionRatio.RatioBeyond2400 then CameraController.Instance:ChangeCameraOrthographic(0.83, 0.3) elseif resolutionRatio >= LuaConst.ScreenResolutionRatio.Ratio1920_1080 then CameraController.Instance:ChangeCameraOrthographic(0.96, 0.3) elseif resolutionRatio >= LuaConst.ScreenResolutionRatio.RatioPadOther then CameraController.Instance:ChangeCameraOrthographic(1.05, 0.3) else CameraController.Instance:ChangeCameraOrthographic(1.25, 0.3) end end end return UINewYearMain