local SuperGoldMain_Controller = {} local private = {} local EventSystem = require("Event/EventSystem") SuperGoldMain_Controller.RedPointType = { Trail = 1, } SuperGoldMain_Controller.RpEventIdTemplate = { TownHome = "SuperGoldMain_TownHome", BossTrail = "SuperGoldMain_BossTrail", -- 彩金—Boss试炼 BossTrailHasReward = "SuperGoldBoss_HasReward", -- 彩金—Boss试炼—奖励可领 BossTrailItemEnough = "SuperGoldBoss_ItemEnough", -- 彩金—Boss试炼—可挑战 DrawCardAvailable = "SuperGoldMain_DrawCardAvailable", -- 彩金—限时抽卡可抽 HonorOrder = "SuperGoldMain_HonorOrder", -- 彩金—战令 SuperGoldLottery = "SuperGoldLottery", -- 彩金-扭蛋 Story = "SuperGoldMain_Story", -- 彩金—体验关 StoryNewEnding = "SuperGoldStory_NewEnding", -- 彩金—体验关 StoryEndingReward = "SuperGoldStory_EndingReward" -- 彩金—体验关 } --彩金活动期界面 local SuperGoldActiveView = { --体力购买,用到的体力都只有活动期才开放 Const_UI_Lua.UIEnum.UISuperGoldEnergyBuy, --秘闻 Const_UI_Lua.UIEnum.UISuperGoldStoryMain, Const_UI_Lua.UIEnum.UISuperGoldStoryPath, Const_UI_Lua.UIEnum.UISuperGoldStoryOption, Const_UI_Lua.UIEnum.UISuperGoldStoryTaskInfo, Const_UI_Lua.UIEnum.UISuperGoldStoryLevelInfo, Const_UI_Lua.UIEnum.UISuperGoldStoryEndingShow, Const_UI_Lua.UIEnum.UISuperGoldStoryEndingTarget, Const_UI_Lua.UIEnum.UISuperGoldStoryEndingLibrary, Const_UI_Lua.UIEnum.UIGoldenHeroStoryAchieve, Const_UI_Lua.UIEnum.UIGoldenHeroStoryEndingShow, --boss Const_UI_Lua.UIEnum.UISuperGoldBossMain, Const_UI_Lua.UIEnum.UISuperGoldBossSweepSuccess, Const_UI_Lua.UIEnum.UISuperGoldBossTimesReward, Const_UI_Lua.UIEnum.UISuperGoldBossRank, Const_UI_Lua.UIEnum.UISuperGoldBossRankReward, } --彩金活动除开活动期的其他界面(会在start的时候把SuperGoldActiveView插入进来),视为彩金所有界面的集合 local SuperGoldView = { --通用 Const_UI_Lua.UIEnum.UISuperGoldMain, Const_UI_Lua.UIEnum.OperationActivity.UIGetActivityItemPanel, --战令 Const_UI_Lua.UIEnum.UISuperGoldHonorOrderMain, Const_UI_Lua.UIEnum.UISuperGoldHonorOrderTask, Const_UI_Lua.UIEnum.UISuperGoldHonorOrderPurchase, --抽卡 Const_UI_Lua.UIEnum.UISuperGoldDrawCardMain, Const_UI_Lua.UIEnum.UISuperGoldDrawCardReward, Const_UI_Lua.UIEnum.UIGachaShop, Const_UI_Lua.UIEnum.UIGachaSummary, Const_UI_Lua.UIEnum.UIGachaExchangePopUp, Const_UI_Lua.UIEnum.UIGoldHeroOptional, Const_UI_Lua.UIEnum.UIGoldHeroOptionalPupup, --转盘 Const_UI_Lua.UIEnum.UISuperGoldLotteryMain, Const_UI_Lua.UIEnum.UISuperGoldLotteryProbability, Const_UI_Lua.UIEnum.UISuperGoldLotteryUnlock, Const_UI_Lua.UIEnum.UISuperGoldLotteryReward, --打脸图 Const_UI_Lua.UIEnum.UIPushInterfaceZhouYu, } function SuperGoldMain_Controller.OnStartup() for i, v in ipairs(SuperGoldActiveView) do table.insert(SuperGoldView, v) end EventSystem.Regist(EventID.UI_OperationActivity_InfoChanged, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.UI_SuperGold_ActivityEnd, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) EventSystem.Regist(EventID.UI_Delay_FocusOnTownHome, SuperGoldMain_Controller.SetIsOpenedActivity) EventSystem.Regist(EventID.DeepLink_Event, private.OnDeepLink) EventSystem.Regist(EventID.UI_GachaLimit_ChangeCardInfo, private.RefreshChangeCardInfo) private.ActivityType = MDL.OperationActivity.ActivityType.SuperGold SuperGoldMain_Controller.RpEventId = {} private.rewardRedPointInfo = {} private.endTimerHandle = {} private.isOpenedActivity = {} SuperGoldMain_Controller.OpenDrawCardActivityID = 0 end ---判断玩家是否打开了彩金的相关页面(在活动结束的时候使用) ---需要在返回主城、进入战斗关卡的时候清掉(否则可能会导致战斗相关界面出现异常) function SuperGoldMain_Controller.SetIsOpenedActivity(activityId, state) if activityId then private.isOpenedActivity[activityId] = state else private.isOpenedActivity = {} end end function SuperGoldMain_Controller.GetRedPointInfoByType(activityId, type) if private.rewardRedPointInfo[activityId] then return private.rewardRedPointInfo[activityId][type] or false end return false end function SuperGoldMain_Controller.SetRedPointInfo(activityId, trial) if not private.rewardRedPointInfo[activityId] then private.rewardRedPointInfo[activityId] = {} end private.rewardRedPointInfo[activityId][SuperGoldMain_Controller.RedPointType.Trail] = trial EventSystem.Dispatch(EventID.UI_SuperGold_ServerRedPointRefresh) end function private.GetCurrentTypeIds(heroType, viewClassPath) if viewClassPath == nil or string.isNilOrEmpty(viewClassPath) then logging.error(LTAG.ERROR, "[通用资源HUD] : 当前父级Panel的viewClassPath无效", viewClassPath) return nil end local cfg = DataSheetManager.SuperGoldHUDData[heroType]:GetDataByUIName(viewClassPath) if cfg then local currencyTypeIds = cfg.Money local currencyCount = #currencyTypeIds if currencyCount > 0 then return currencyTypeIds end end return nil end --region **************************** 打开界面 ****************************** local SuperGoldPlayCGKey = "SuperGoldPlayCGKey" local SuperGoldCGCantPassTime = DataSheetManager.ConstData:GetDataByID("SuperGoldCGCantPassTime").IntValue function SuperGoldMain_Controller.OpenMainView(activityId) local info = MDL.OperationActivity.GetOperationActivityInfo(private.ActivityType, activityId) if info then if CTL.OperationActivity.IsOperationActivityOpen(info) then local heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(activityId) local superGoldModeData = DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(heroType) if not private.isPlayedCG then private.isPlayedCG = PersistentData.PlayerData:Get(SuperGoldPlayCGKey, {}) end if string.isNilOrEmpty(superGoldModeData.OpeningCG) then private.isPlayedCG[activityId] = true end if private.isPlayedCG[activityId] then UIManager.CloseView(Const_UI_Lua.UIEnum.UIMoviePanel) SuperGoldMain_Controller.OperateBgSound(false) if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISuperGoldMain) then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISuperGoldMain, { heroType = heroType, activityId = activityId }, superGoldModeData.MainPrefab) end else private.isPlayedCG[activityId] = true PersistentData.PlayerData:Set(SuperGoldPlayCGKey, private.isPlayedCG, true) SuperGoldMain_Controller.OperateBgSound(true) --岳显礼0508需求,诸葛亮38号英雄的CG要特殊处理,所以这里要加上判断 后续优化走配置 if superGoldModeData.HeroID == 38 then --新的播放方式接缝处有漏出,还是先用原来的,但是音频还是要加上 --三段视频衔接出能看到场景 这里打开一个全屏遮罩界面 UIManager.OpenView(Const_UI_Lua.UIEnum.UIMovieMaskPanel) AuxUtil.StartTimeline(MDL.Login.GetLoginShowCGTimeLinePath(), true, -1, false, function() EventSystem.UnRegist(EventID.Event_OnTimelinePause, CTL.Login.OnCGTimelinePause) SuperGoldMain_Controller.OpenMainView(activityId) UIManager.CloseView(Const_UI_Lua.UIEnum.UIMovieMaskPanel) 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 UIManager.OpenView(Const_UI_Lua.UIEnum.UIMoviePanel, { movieID = superGoldModeData.OpeningCG, banSkipTime = SuperGoldCGCantPassTime, autoPassTime = -1, needPause = true, callback = function() --CTL.Sound.ResumeLevelSound() SuperGoldMain_Controller.OpenMainView(activityId) end }) --这里每个金将cg有自己的声音 cg比较少 就不配表了 需要添加的时候注意一下 if superGoldModeData.HeroID == 34 then CTL.Sound.PlayGameSound("MUSIC_Chibi") elseif superGoldModeData.HeroID == 46 then --左慈 CTL.Sound.PlayGameSound("MUSIC_Zuoci") end end end end end end function SuperGoldMain_Controller.OperateBgSound(isMute) if isMute then CTL.Sound.LowPass() CTL.Sound.PlayGameSound("MUSiC_empty") else CTL.Sound.ResumeLevelSound() CTL.Sound.HighPass() end end function SuperGoldMain_Controller.OpenCurrencyPanel(heroType, viewClassPath, currencyInfo, paramContext) local currencyTypeIds = private.GetCurrentTypeIds(heroType, viewClassPath) if currencyTypeIds then if not currencyInfo then logging.error(LTAG.ERROR, "当前View:", viewClassPath, "不存在资源条挂点currency_Info") return end if currencyInfo:GetType() ~= typeof(Tai.Lua.UIScriptableCanvas) then logging.error(LTAG.ERROR, "当前View:", viewClassPath, "UI挂点类型有误(不是UIScriptableCanvas):", currencyInfo:GetType()) return end currencyInfo:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UICurrencyPanel), { viewClassPath = viewClassPath, currencyTypeIds = currencyTypeIds, param = paramContext }) end end local UIGachaLimitPath = "DrawCard/TimeLimit/UIGachaMainLimit/" function SuperGoldMain_Controller.OpenDrawCardMainPanel(activityId) local drawCardPoolId local cfg = MDL.OperationActivity.ActivityBaseData[private.ActivityType]:GetDataByActivityID(activityId) local cardInfo = MDL.ActivityGacha.GetActivityDrawInfo(activityId) if cardInfo.isOpen then drawCardPoolId = cardInfo.cardPoolId else drawCardPoolId = cfg.DrawCardPoolID end local drawCardData = DataSheetManager.DrawCardData:GetDataByID(drawCardPoolId) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISuperGoldDrawCardMain, { drawCardPoolId = drawCardPoolId, drawCardStoreId = cfg.DrawCardStoreID, activityId = activityId, activityType = private.ActivityType, heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(activityId) }, UIGachaLimitPath .. drawCardData.BackgroundPrefab) SuperGoldMain_Controller.OpenDrawCardActivityID = activityId end function private.RefreshChangeCardInfo(activityId) if SuperGoldMain_Controller.OpenDrawCardActivityID == activityId then UIManager.CloseView(Const_UI_Lua.UIEnum.UIGoldHeroOptionalPupup) UIManager.CloseView(Const_UI_Lua.UIEnum.UIGoldHeroOptional) UIManager.RecoverView() UIManager.CloseView(Const_UI_Lua.UIEnum.UISuperGoldDrawCardMain) SuperGoldMain_Controller.OpenDrawCardMainPanel(activityId) end end --endregion **************************** 打开界面 ****************************** function SuperGoldMain_Controller.IsActivityInValidFuncTime(activityId) local heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(activityId) if heroType and heroType > 0 then local modeData = DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(heroType) local extraEndTime = modeData.TotalRankPreTime * UTL.Time.TotalSecondsOneHour local endTimeNum = MDL.SuperGoldMain.GetEndFuncTime(activityId) - extraEndTime return UTL.Time.GetServerTimestamp() <= endTimeNum else return false end end function private.CheckFuncOpenIssue() if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SuperGoldActivity) then private.ForceCloseActivityView() return end local activityTypeInfo = MDL.OperationActivity.GetOperationActivityInfo(private.ActivityType) if activityTypeInfo then for i, v in pairs(activityTypeInfo) do local activityId = v.activityId if private.endTimerHandle[activityId] then TimerUtil.Remove(private.endTimerHandle[activityId]) end if not CTL.OperationActivity.IsOperationActivityOpen(v) then private.EndAndCloseActivityView(activityId) else local deltaTime = v.endTime - UTL.Time.GetServerTimestamp() if deltaTime <= UTL.Time.TotalSecondsOneDay then private.endTimerHandle[activityId] = TimerUtil.Interval(function() private.EndAndCloseActivityView(activityId) end, deltaTime - 1, 1) --时间减1s是为了防止有误差导致玩家点击出现报错 end if not MDL.SuperGoldMain.IsActivityInFuncTime(activityId) then private.ShutDownPartActivityView(activityId) end end end end end --GMS开关变化时刷新 function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.SuperGoldActivity then if not isUnlock then private.ForceCloseActivityView() end end end function private.ShutDownPartActivityView(activityId) for i, v in ipairs(SuperGoldActiveView) do EventSystem.Dispatch(EventID.UI_OperationActivity_CloseView, v, activityId) end end function private.EndAndCloseActivityView(activityId) if private.isOpenedActivity[activityId] then UIManager.RecoverTopView() CTL.HomeMain.CloseOpenView() end if private.endTimerHandle[activityId] then TimerUtil.Remove(private.endTimerHandle[activityId]) end end -- 关闭活动界面 function private.ForceCloseActivityView() logging.log(LTAG.LOG, "SuperGold Function(include GMS) ActivityEnd ") local activityTypeInfo = MDL.OperationActivity.GetOperationActivityInfo(private.ActivityType) if activityTypeInfo then for i, v in pairs(activityTypeInfo) do local activityId = v.activityId private.EndAndCloseActivityView(activityId) end end end --IAE扩展,检测是否需要显示 彩金将界面 function private.OnDeepLink(key, heroType) if key ~= LuaConst.Deeplink.SuperGoldenHero or not heroType then return end --强制引导时,不打开界面,清掉deeplink存储 if CTL.PlayerGuide.IsForceGuiding() then return end if heroType > 0 then local activityId = MDL.SuperGoldMain.GetActivityIDByHeroType(heroType) --活动开启着 if activityId > 0 then --在城镇里 if BattleDataGetter.IsOnlineTownLevel() then --防止重复打开(第一次打开时会有CG) if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISuperGoldMain) and not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIMoviePanel) then SuperGoldMain_Controller.OpenMainView(activityId) end end end end end --region ************************** 红点 ************************************* ---@public 初始化金将体验关红点根节点 ---在运营活动doingActivity发过来的时候,先根据activityId初始化红点的根节点 function SuperGoldMain_Controller.InitRedPointTreeByActivityId(activityId) --根据activityId初始化红点的eventId SuperGoldMain_Controller.RpEventId[activityId] = {} for k, v in pairs(SuperGoldMain_Controller.RpEventIdTemplate) do SuperGoldMain_Controller.RpEventId[activityId][k] = v .. activityId end MDL.RedPoint.AddRootRpNode(SuperGoldMain_Controller.RpEventId[activityId].TownHome) SuperGoldMain_Controller.InitBossRedPointTreeByActivityId(activityId) SuperGoldMain_Controller.InitStoryRedPointTreeByActivityId(activityId) SuperGoldMain_Controller.InitDrawCardRedPointTreeByActivityId(activityId) SuperGoldMain_Controller.InitHonorOrderRedPointTreeByActivityId(activityId) SuperGoldMain_Controller.InitLotteryRedPointTreeByActivityId(activityId) end ---@public 协同讨伐初始化红点 ---先获取相应activityId对应的红点根节点,然后再添加相应的子节点 function SuperGoldMain_Controller.InitBossRedPointTreeByActivityId(activityId) if not SuperGoldMain_Controller.RpEventId[activityId] then SuperGoldMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = SuperGoldMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) local bossKey = SuperGoldMain_Controller.RpEventId[activityId].BossTrail local bossNode = townRoot:AddChildRpNode(bossKey, bossKey, activityId) local hasRewardKey = SuperGoldMain_Controller.RpEventId[activityId].BossTrailHasReward bossNode:AddChildRpNode(hasRewardKey, hasRewardKey, activityId, { hasRewardKey }, SuperGoldMain_Controller.GetRedPointInfoByType(activityId, SuperGoldMain_Controller.RedPointType.Trail)) local itemEnoughKey = SuperGoldMain_Controller.RpEventId[activityId].BossTrailItemEnough bossNode:AddChildRpNode(itemEnoughKey, itemEnoughKey, activityId, { itemEnoughKey }, CTL.SuperGoldBoss.IsItemEnough(activityId)) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end ---@public 体验关初始化红点 ---先获取相应activityId对应的红点根节点,然后再添加相应的子节点 function SuperGoldMain_Controller.InitStoryRedPointTreeByActivityId(activityId) local heroType = MDL.SuperGoldMain.GetHeroTypeByActivityId(activityId) if not SuperGoldMain_Controller.RpEventId[activityId] then SuperGoldMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = SuperGoldMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local storyKey = SuperGoldMain_Controller.RpEventId[activityId].Story local storyNode = townRoot:AddChildRpNode(storyKey, storyKey, activityId) local newEndingKey = SuperGoldMain_Controller.RpEventId[activityId].StoryNewEnding storyNode:AddChildRpNode(newEndingKey, newEndingKey, activityId, { newEndingKey }, MDL.SuperGoldStory.CheckHaveOpenEndingCount(activityId, heroType)) local HasEndingRewardKey = SuperGoldMain_Controller.RpEventId[activityId].StoryEndingReward storyNode:AddChildRpNode(HasEndingRewardKey, HasEndingRewardKey, activityId, { HasEndingRewardKey }, MDL.SuperGoldStory.GetEndingRewardRedPointByActivityID(activityId)) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end ---@public 限时抽卡初始化红点 ---先获取相应activityId对应的红点根节点,然后再添加相应的子节点 function SuperGoldMain_Controller.InitDrawCardRedPointTreeByActivityId(activityId) if not SuperGoldMain_Controller.RpEventId[activityId] then SuperGoldMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = SuperGoldMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local drawCardKey = SuperGoldMain_Controller.RpEventId[activityId].DrawCardAvailable townRoot:AddChildRpNode(drawCardKey, drawCardKey, activityId, { drawCardKey }, CTL.ActivityGacha.IfCanDrawByActivityId(activityId, private.ActivityType)) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end ---@public 战令初始化红点 ---先获取相应activityId对应的红点根节点,然后再添加相应的子节点 function SuperGoldMain_Controller.InitHonorOrderRedPointTreeByActivityId(activityId) if not SuperGoldMain_Controller.RpEventId[activityId] then SuperGoldMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = SuperGoldMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local honorOrderKey = SuperGoldMain_Controller.RpEventId[activityId].HonorOrder townRoot:AddChildRpNode(honorOrderKey, honorOrderKey, activityId, { honorOrderKey }, MDL.SuperGoldHonorOrder.CheckRedPoint(activityId)) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end ---@public 扭蛋初始化红点 ---先获取相应activityId对应的红点根节点,然后再添加相应的子节点 function SuperGoldMain_Controller.InitLotteryRedPointTreeByActivityId(activityId) if not SuperGoldMain_Controller.RpEventId[activityId] then SuperGoldMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = SuperGoldMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local lotteryKey = SuperGoldMain_Controller.RpEventId[activityId].SuperGoldLottery townRoot:AddChildRpNode(lotteryKey, lotteryKey, activityId, { lotteryKey }, CTL.SuperGoldLottery.IsCanLottery(activityId)) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end --endregion ************************** 红点 ************************************* return SuperGoldMain_Controller