local UISuperGoldMain = UIViewClass() local StringFormat = string.format local EmptyLightObjPath = ConstAssetPathConfig.EmptyLightObjPath local EventSystem = require('Event/EventSystem') function UISuperGoldMain:OnOpened(context) self.heroType = context.heroType self.activityId = context.activityId self.activityType = MDL.OperationActivity.ActivityType.SuperGold self.modeData = DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(self.heroType) self:SetButtonTextAndIcon() UIUtils.SetLocalizationImage(self.img_New, "zr_msz_new.png") self.img_New:SetNativeSize() self:RegistSystemEvent(EventID.UI_DirectGift_GiftInfoUpdate, self.RefreshGiftNewImg) self:RegistSystemEvent(EventID.UI_DirectGift_NewGiftInfoChange, self.RefreshGiftNewImg) self:RegistSystemEvent(EventID.UI_OperationActivity_InfoChanged, self.RefreshTimeAndButton) self:RegistSystemEvent(EventID.UI_SuperGold_ActivityEnd, self.RefreshTimeAndButton) self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) --self:RegistSystemEvent(EventID.Event_OnTimelinePause, self.OnCGTimelinePause) local timeText = UIUtils.GetLocalizedTxt(Const_IDS.IDS_GoldHeroActivity_TimeHint2) self.txt_CountDown:SetDHMSStr(StringFormat(timeText, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime1)), StringFormat(timeText, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime2)), StringFormat(timeText, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime3)), StringFormat(timeText, UIUtils.GetLocalizedTxt(Const_IDS.IDS_PreviewTime4))) UIUtils.SetLabelText(self.lab_Time, Const_IDS.IDS_GoldHeroActivity_TimeHint1) CTL.SuperGoldMain.OpenCurrencyPanel(self.heroType, self.__viewClassPath, self.currency_Info, {activityType = self.activityType, activityId = self.activityId, title = "IDS_DrawCard_Title_QuickBuy"}) self.isActive = MDL.SuperGoldMain.IsActivityInFuncTime(self.activityId) --红点 self:RegistSystemEvent(CTL.SuperGoldMain.RpEventId[self.activityId].BossTrail, self.RefreshBossTrailRp) -- Boss试炼 self:RegistSystemEvent(CTL.SuperGoldMain.RpEventId[self.activityId].DrawCardAvailable, self.RefreshDrawCardRp) -- 限时抽卡入口红点 self:RegistSystemEvent(CTL.SuperGoldMain.RpEventId[self.activityId].SuperGoldLottery, self.RefreshLotteryRp) -- 扭蛋入口红点 self:RegistSystemEvent(CTL.SuperGoldMain.RpEventId[self.activityId].HonorOrder, self.RefreshHonorOrderRp) -- 彩金战令入口红点 self:RegistSystemEvent(CTL.SuperGoldMain.RpEventId[self.activityId].StoryEndingReward, self.RefreshStoryRp) -- 秘闻录可领奖红点 self:RefreshBossTrailRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].BossTrail)) -- Boss试炼入口红点 self:RefreshDrawCardRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].DrawCardAvailable)) -- 限时抽卡入口红点 self:RefreshLotteryRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].SuperGoldLottery)) -- 扭蛋入口红点 self:RefreshHonorOrderRp(MDL.RedPoint.GetNodeStateByMultiKey(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].HonorOrder)) -- 彩金战令入口红点 self:RefreshStoryRp(MDL.RedPoint.GetNodeStateByLogicParams(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].StoryEndingReward)) -- 秘闻录可领奖红点 self:RefreshTimeAndButton() self:RefreshGiftNewImg() self:SetPortrait() UIManager.ActiveUIModle(false, "UISuperGoldMain") CTL.SuperGoldMain.SetIsOpenedActivity(self.activityId, true) -- 目前只有周瑜1,不需要进行特效层级处理,其他彩金将活动按需设置 if self.heroType ~= 1 then UIUtils.SetCanvasSortingOrderByMainCanvas(self.canvas_Model, self.group_UI, 10) self:StartRepeatFunc(self.PlayUIEffectFunc, 0.1, 1) end end function UISuperGoldMain:PlayUIEffectFunc() -- 以下特效节点只能拿到初始化时父级canvas的层级,他们的父级canvas在上面手动设置了层级,所以这里先手动设置特效层级 self.effect_Story:RefreshParentCanvas(100) self.effect_Story_Loc:RefreshParentCanvas(100) self.effect_Boss:RefreshParentCanvas(100) self.effect_Boss_Loc:RefreshParentCanvas(100) self.effect_DrawCard:RefreshParentCanvas(100) self.effect_DrawCard_Loc:RefreshParentCanvas(100) self.effect_HonorOrderBg:RefreshParentCanvas(100) self.effect_LotteryBg:RefreshParentCanvas(100) self.effect_GiftBg:RefreshParentCanvas(100) -- 手动设置完层级后这里播放特效就以新的层级显示 self.effect_Story:PlayUIEffect() self.effect_Story_Loc:PlayUIEffect() self.effect_Boss:PlayUIEffect() self.effect_Boss_Loc:PlayUIEffect() self.effect_DrawCard:PlayUIEffect() self.effect_DrawCard_Loc:PlayUIEffect() self.effect_HonorOrderBg:PlayUIEffect() self.effect_LotteryBg:PlayUIEffect() self.effect_GiftBg:PlayUIEffect() -- button特效上面又有一层UI,这里在button特效层级的基础上再向上设置50 UIUtils.SetCanvasSortingOrderByMainCanvas(self.group_UI, self.canvas_Story, 150) UIUtils.SetCanvasSortingOrderByMainCanvas(self.group_UI, self.canvas_Story_Loc, 150) UIUtils.SetCanvasSortingOrderByMainCanvas(self.group_UI, self.canvas_Boss, 150) UIUtils.SetCanvasSortingOrderByMainCanvas(self.group_UI, self.canvas_Boss_Loc, 150) UIUtils.SetCanvasSortingOrderByMainCanvas(self.group_UI, self.canvas_DrawCard, 150) UIUtils.SetCanvasSortingOrderByMainCanvas(self.group_UI, self.canvas_DrawCard_Loc, 150) end function UISuperGoldMain:OnClosed() UIManager.ActiveUIModle(true, "UISuperGoldMain") end function UISuperGoldMain:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView(true) end end end function UISuperGoldMain:SetButtonTextAndIcon() --标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[self.modeData.TownName]) UIUtils.SetLabelText(self.lab_Story, Const_IDS[self.modeData.LevelName]) --秘闻 UIUtils.SetLabelText(self.lab_Boss, Const_IDS[self.modeData.BossName]) --试炼 UIUtils.SetLabelText(self.lab_DrawCard, Const_IDS[self.modeData.DrawName]) --抽卡 UIUtils.SetLabelText(self.lab_HonorOrder, Const_IDS[self.modeData.HonorOrderName]) --战令 UIUtils.SetImageByAssetBundle(self.img_HonorOrderIcon, self.modeData.HonorOrderIcon) UIUtils.SetLabelText(self.lab_Lottery, Const_IDS[self.modeData.TurntableName]) --转盘 UIUtils.SetImageByAssetBundle(self.img_LotteryIcon, self.modeData.TurntableIcon) UIUtils.SetLabelText(self.lab_Gift, Const_IDS[self.modeData.GiftName]) --直购 UIUtils.SetImageByAssetBundle(self.img_GiftIcon, self.modeData.GiftIcon) local isHasCG = not string.isNilOrEmpty(self.modeData.OpeningCG) UIUtils.SetActive(self.btn_Play1, isHasCG) UIUtils.SetActive(self.btn_Play2, isHasCG) end function UISuperGoldMain:RefreshGiftNewImg() UIUtils.SetActive(self.img_New, CTL.DirectGift.IsActivityShowNew(self.activityId)) end function UISuperGoldMain:RefreshTimeAndButton() self:RefreshButtonState(self.isActive) UIUtils.SetActive(self.lab_Time, self.isActive) UIUtils.SetActive(self.txt_Time, self.isActive) local activityInfo = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) self.infoParams = {} if activityInfo then if self.isActive then local startTime = os.date(UTL.Time.FormatDateEnum.YMDHM, activityInfo.startTime) local endFuncTime = os.date(UTL.Time.FormatDateEnum.YMDHM, MDL.SuperGoldMain.GetEndFuncTime(self.activityId)) self.txt_Time.text = " "..startTime .. "-" .. endFuncTime self.txt_CountDown:EndTimer() else local leftTimes = activityInfo.endTime - UTL.Time.GetServerTimestamp() self.txt_CountDown:ResetAndBeginCustomTimer(false, leftTimes, 0, nil) end --获取说明按钮中的参数 local startTime = os.date(UTL.Time.FormatDateEnum.YMDHM, activityInfo.startTime) local endFuncTime = os.date(UTL.Time.FormatDateEnum.YMDHM, MDL.SuperGoldMain.GetEndFuncTime(self.activityId)) local endTime = os.date(UTL.Time.FormatDateEnum.YMDHM, activityInfo.endTime) self.infoParams[1] = startTime .. "-" .. endFuncTime self.infoParams[2] = endFuncTime .. "-" .. endTime self.infoParams[3] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.LevelName]) self.infoParams[4] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.BossName]) self.infoParams[5] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.DrawName]) self.infoParams[6] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.HonorOrderName]) self.infoParams[7] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.TurntableName]) self.infoParams[8] = UIUtils.GetLocalizedTxt(Const_IDS[self.modeData.GiftName]) end end function UISuperGoldMain:RefreshButtonState(state) self.state_Story:SetState(state and 0 or 1) if not self.heroType == 3 then UIUtils.SetGray(self.lab_Story, not state) UIUtils.SetGray(self.lab_Boss, not state) UIUtils.SetComponentGray(self.btn_Story, not state) UIUtils.SetComponentGray(self.btn_Story_Loc, not state) UIUtils.SetComponentGray(self.btn_Boss, not state) UIUtils.SetComponentGray(self.btn_Boss_Loc, not state) end UIUtils.SetActive(self.effect_Story, state or false) UIUtils.SetActive(self.effect_Story_Loc, state or false) UIUtils.SetActive(self.group_NewEnding, state and MDL.RedPoint.GetNodeStateByLogicParams(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].StoryNewEnding)) self.state_Boss:SetState(state and 0 or 1) UIUtils.SetActive(self.effect_Boss, state or false) UIUtils.SetActive(self.effect_Boss_Loc, state or false) end function UISuperGoldMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) return elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() return end local info = MDL.OperationActivity.GetOperationActivityInfo(self.activityType, self.activityId) if not info or not CTL.OperationActivity.IsOperationActivityOpen(info) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_TimeHint3) return end if comp == self.btn_DrawCard or comp == self.btn_DrawCard_Loc then CTL.SuperGoldMain.OpenDrawCardMainPanel(self.activityId) elseif comp == self.btn_HonorOrder then CTL.SuperGoldHonorOrder.OpenSuperGoldHonorOrderMainView(self.activityId, self.heroType) elseif comp == self.btn_Lottery then --扭蛋界面 CTL.SuperGoldLottery.OpenMainPanel(self.activityId) elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.SuperGoldMain, params = self.infoParams}) elseif comp == self.btn_Gift then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.OperationActivity.UIOACommonDirectGiftPanel, { activityType = self.activityType, activityId = self.activityId, Title = self.modeData.GiftName }) elseif comp == self.btn_Play1 or comp == self.btn_Play2 or comp == self.btn_Play3 then --当活动是诸葛亮是播放Timeline if self.modeData.HeroID == 38 then self:CloseView(true) UIManager.OpenView(Const_UI_Lua.UIEnum.UIMovieMaskPanel) AuxUtil.StartTimeline(MDL.Login.GetLoginShowCGTimeLinePath(), true, -1, false, function() EventSystem.UnRegist(EventID.Event_OnTimelinePause, CTL.Login.OnCGTimelinePause) CTL.SuperGoldMain.OperateBgSound(false) UIManager.CloseView(Const_UI_Lua.UIEnum.UIMovieMaskPanel) CTL.SuperGoldMain.OpenMainView(self.activityId) end) UIManager.SetLayerActive(Const_UI_Lua.UILayers.UIDefault, true) EventSystem.Regist(EventID.Event_OnTimelinePause, CTL.Login.OnCGTimelinePause) CTL.Sound.PlayGameSound(MDL.Login.GetGameCGMusic(false)) else CTL.SuperGoldMain.OperateBgSound(true) UIManager.OpenView(Const_UI_Lua.UIEnum.UIMoviePanel, { movieID = self.modeData.OpeningCG, banSkipTime = 0, autoPassTime = -1, needPause = true, callback = function() CTL.SuperGoldMain.OperateBgSound(false) end }) --当活动是周瑜是播放MUSIC_Chibi if self.modeData.HeroID == 34 then CTL.Sound.PlayGameSound("MUSIC_Chibi") elseif self.modeData.HeroID == 46 then --左慈 CTL.Sound.PlayGameSound("MUSIC_Zuoci") end end else if not self.isActive then CTL.Tips.AddTipsMsg(Const_IDS.IDS_GoldHeroActivity_TimeHint3) return end if comp == self.btn_Story or comp == self.btn_Story_Loc then CTL.SuperGoldStory.OpenStoryMain(self.activityId, self.heroType) elseif comp == self.btn_Boss or comp == self.btn_Boss_Loc then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISuperGoldBossMain, {heroType = self.heroType, activityId = self.activityId}) end end end --要改成新的播放方式的话,这里可能要用 --function UISuperGoldMain:OnCGTimelinePause(pause) -- CTL.Login.OnCGTimelinePause(pause) --end function UISuperGoldMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UISuperGoldMain:SetPortrait() local mainPrefabMode = self.modeData.MainPrefabMode local MainViewPrefabModeEnum = CTL.GoldenHeroMain.MainViewPrefabMode if mainPrefabMode == MainViewPrefabModeEnum.AnyPortrait then self.AnyPortraitPath = self.modeData.MainPrefabHero self.AnyPortraitObj = CTL.GoldenHeroMain.ShowAnyPortrait(self.modeData, self.group_2DDynamicBG.transform, self) elseif mainPrefabMode == MainViewPrefabModeEnum.OrthoGraphic then -- 虽然叫正交,但实际上还是使用RT,后续会改成场景渲染,现在暂时先这样 CTL.GoldenHeroMain.ShowRenderModelTexture(self.renderModel, self.modeData) elseif mainPrefabMode == MainViewPrefabModeEnum.RealBgScene then CTL.GoldenHeroMain.Show3DModel(self.heroModel, self.modeData) elseif mainPrefabMode == MainViewPrefabModeEnum.RenderAndBg then CTL.GoldenHeroMain.ShowRenderModelTexture(self.renderModel, self.modeData) self.heroModel:Show2DBGModel(self.modeData.HeroBackground, nil, self.modeData.HeroSize, EmptyLightObjPath) local offsetZ = 0 if UIUtils.GetScreenResolutionRatio() <= LuaConst.ScreenResolutionRatio.RatioPadOther then offsetZ = -1 end self.heroModel:SetNodePos(self.modeData.DrawCardHeroOffsetX, self.modeData.DrawCardHeroOffsetY, offsetZ) self.heroModel:SetNodeRot(0, 0, 0) self.heroModel:SetSceneShadowPlane(false) end UIUtils.SetActive(self.bg_Bottom, mainPrefabMode ~= MainViewPrefabModeEnum.RealBgScene and mainPrefabMode ~= MainViewPrefabModeEnum.RenderAndBg) if self.renderModel then UIUtils.SetActive(self.renderModel, mainPrefabMode == MainViewPrefabModeEnum.OrthoGraphic or mainPrefabMode == MainViewPrefabModeEnum.RenderAndBg) end end --region 红点 ---@public 协同讨伐入口红点 function UISuperGoldMain:RefreshBossTrailRp(active) self.btn_Boss:SetRedPoint(active and self.isActive) self.btn_Boss_Loc:SetRedPoint(active and self.isActive) end ---@public 体验关入口红点 function UISuperGoldMain:RefreshStoryRp(active) self.btn_Story:SetRedPoint(active) self.btn_Story_Loc:SetRedPoint(active) UIUtils.SetActive(self.group_NewEnding, MDL.RedPoint.GetNodeStateByLogicParams(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].StoryNewEnding)) end ---@public 限时抽卡入口红点 function UISuperGoldMain:RefreshDrawCardRp(active) self.btn_DrawCard:SetRedPoint(active) self.btn_DrawCard_Loc:SetRedPoint(active) end ---@public 扭蛋入口红点 function UISuperGoldMain:RefreshLotteryRp(active) self.btn_Lottery:SetRedPoint(active) end ---@public 战令入口红点 function UISuperGoldMain:RefreshHonorOrderRp(active) self.btn_HonorOrder:SetRedPoint(active) end --endregion return UISuperGoldMain