local GoldenHeroMain_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') GoldenHeroMain_Controller.ViewType = { Story = Const_UI_Lua.UIEnum.UIGoldenHeroStory, Boss = Const_UI_Lua.UIEnum.UIGoldenHeroBossMain, Store = Const_UI_Lua.UIEnum.UIGoldenHeroStore, } GoldenHeroMain_Controller.RpEventIdTemplate = { TownHome = "GoldenHeroMain_TownHome", Boss = "GoldenHeroMain_Boss", -- 金将体验关—协同讨伐 BossFindReward = "GoldenHeroBoss_FindReward", -- 金将体验关—协同讨伐—有可领取发现奖励 BossPointReward = "GoldenHeroBoss_PointReward", -- 金将体验关—协同讨伐—有可领取积分奖励 BossItemEnough = "GoldenHeroBoss_ItemEnough", -- 金将体验关—协同讨伐—体力已满 BossNewOne = "GoldenHeroBoss_NewOne", -- 金将体验关—协同讨伐—有新发现的boss BossLogin = "GoldenHeroBoss_BossLogin", -- 金将体验关—协同讨伐—首次登录 Story = "GoldenHeroMain_Story", -- 金将体验关—秘闻 StoryNewLevel = "GoldenHeroStory_NewLevel", -- 金将体验关—秘闻—新开放关卡 StorySweep = "GoldenHeroStory_Sweep", -- 金将体验关—秘闻—有可扫荡关卡 StoryEndingReward = "GoldenHeroStory_EndingReward", -- 金将体验关—秘闻—有可领取结局奖励 StoryAchievementReward = "GoldenHeroStory_AchievementReward", -- 金将体验关—秘闻—有可领取成就奖励 Fame = "GoldenHeroMain_Fame", -- 金将体验关—声明鹊起 FameLevelReward = "GoldenHeroStory_LevelReward", -- 金将体验关—声明鹊起—声明等级奖励可领 FameTaskReward = "GoldenHeroStory_TaskReward", -- 金将体验关—声明鹊起—声明任务奖励可领 DrawCardAvailable = "GoldenHeroMain_DrawCardAvailable", -- 金将体验关—限时抽卡—可抽 Anecdote = "GoldenHeroMain_Anecdote", -- 金将体验关—轶事 AnecdoteSweep = "GoldenHeroAnecdote_Sweep", -- 金将体验关—轶事-可扫荡 AnecdoteHasEnergy = "GoldenHeroAnecdote_HasEnergy", -- 金将体验关—轶事—体力足够 AnecdoteNew = "GoldenHeroAnecdote_New", -- 金将体验关—轶事—有新的轶事可查看 AnecdoteReward = "GoldenHeroAnecdote_Reward", -- 金将体验关—轶事—可领取 HeroTryFirstPass = "GoldenHeroMain_TryFirstPass", -- 金将体验关—试用—首通奖励 DirectGiftFree = "GoldenHeroMain_DirectGiftFree", -- 金将体验关—直购—免费礼包 --待补充 } --金将活动期界面 local GoldenHeroActiveView = { --体力购买,用到的体力都只有活动期才开放 Const_UI_Lua.UIEnum.UIGoldenHeroEnergyBuy, --秘闻 Const_UI_Lua.UIEnum.UIGoldenHeroStory, Const_UI_Lua.UIEnum.UIGoldenHeroStoryTaskInfo, Const_UI_Lua.UIEnum.UIGoldenHeroStoryLevelInfo, Const_UI_Lua.UIEnum.UIGoldenHeroStoryEnding, Const_UI_Lua.UIEnum.UIGoldenHeroStoryOption, Const_UI_Lua.UIEnum.UIGoldenHeroStoryStar, Const_UI_Lua.UIEnum.UIGoldenHeroStoryEndingShow, Const_UI_Lua.UIEnum.UIGoldenHeroStorySweep, --轶事 Const_UI_Lua.UIEnum.UIGoldenHeroAnecdote, Const_UI_Lua.UIEnum.UIGoldenHeroAnecdoteDetail, Const_UI_Lua.UIEnum.UIGoldenHeroAnecdoteSweep, --boss Const_UI_Lua.UIEnum.UIGoldenHeroBossMain, Const_UI_Lua.UIEnum.UIGoldenHeroBossRecord, Const_UI_Lua.UIEnum.UIGoldenHeroBossFilter, Const_UI_Lua.UIEnum.UIGoldenHeroBossRank, Const_UI_Lua.UIEnum.UIGoldenHeroBossYesterdayRank, Const_UI_Lua.UIEnum.UIGoldenHeroBossRankReward, Const_UI_Lua.UIEnum.UIGoldenHeroBossPointsReward, Const_UI_Lua.UIEnum.UIGoldenHeroBossSweepSuccess, Const_UI_Lua.UIEnum.UIGoldenHeroBossRewardClaim, Const_UI_Lua.UIEnum.UIGoldenHeroBossPurchase, } --金将活动除开活动期的其他界面(会在start的时候把GoldenHeroActiveView插入进来),视为金将所有界面的集合 local GoldenHeroView = { --通用 Const_UI_Lua.UIEnum.UIGoldenHeroMain, Const_UI_Lua.UIEnum.OperationActivity.UIGetActivityItemPanel, --试用 Const_UI_Lua.UIEnum.UIGoldenHeroTry, Const_UI_Lua.UIEnum.UIGoldenHeroTryShow, --声明 Const_UI_Lua.UIEnum.UIGoldenHeroFame, Const_UI_Lua.UIEnum.UIGoldenHeroFameReward, --宝库 Const_UI_Lua.UIEnum.UIGoldenHeroStore, Const_UI_Lua.UIEnum.UIGoldenHeroStoreExchange, --抽卡 Const_UI_Lua.UIEnum.UIGachaMainLimit, Const_UI_Lua.UIEnum.UIGachaShop, Const_UI_Lua.UIEnum.UIGachaSummary, Const_UI_Lua.UIEnum.UIGachaExchangePopUp, Const_UI_Lua.UIEnum.UIGachaRewardLimit, Const_UI_Lua.UIEnum.UIGoldHeroOptional, Const_UI_Lua.UIEnum.UIGoldHeroOptionalPupup, --打脸 Const_UI_Lua.UIEnum.UIPushInterfaceGuanYu, Const_UI_Lua.UIEnum.UIPushInterfaceSunShangXiang, Const_UI_Lua.UIEnum.UIPushInterfaceDiaoChan, Const_UI_Lua.UIEnum.UIPushInterfaceCaoCao, Const_UI_Lua.UIEnum.UIPushInterfaceSunJian, Const_UI_Lua.UIEnum.UIPushInterfaceZhangLiao, } function GoldenHeroMain_Controller.OnStartup() for i, v in ipairs(GoldenHeroActiveView) do table.insert(GoldenHeroView, v) end EventSystem.Regist(EventID.UI_GoldenHero_FocusOnGoldenHeroView , private.PopGoldenHeroDelayView) EventSystem.Regist(EventID.UI_OperationActivity_InfoChanged, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.UI_GoldenHero_ActivityEnd, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) EventSystem.Regist(EventID.UI_Delay_FocusOnTownHome, GoldenHeroMain_Controller.SetIsOpenedActivity) EventSystem.Regist(EventID.UI_DirectGift_GiftInfoUpdate, private.UpdateDirectGiftFreeRp) EventSystem.Regist(EventID.DeepLink_Event,private.OnDeepLink) EventSystem.Regist(EventID.UI_GachaLimit_ChangeCardInfo, private.RefreshChangeCardInfo) private.ActivityType = MDL.OperationActivity.ActivityType.GoldenHero private.delayBossViewList = {} private.delayStoryViewList = {} private.delayStoreViewList = {} private.focusTarget = nil private.focusActivityId = nil private.endTimerHandle = {} private.isOpenedActivity = {} GoldenHeroMain_Controller.RpEventId = {} GoldenHeroMain_Controller.OpenDrawCardActivityID = 0 end ---判断玩家是否打开了金将的相关页面(在活动结束的时候使用) ---需要在返回主城、进入战斗关卡的时候清掉(否则可能会导致战斗相关界面出现异常) function GoldenHeroMain_Controller.SetIsOpenedActivity(activityId, state) if activityId then private.isOpenedActivity[activityId] = state else private.isOpenedActivity = {} end end local UIGachaLimitPath = "DrawCard/TimeLimit/UIGachaMainLimit/" function GoldenHeroMain_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.UIGachaMainLimit, { drawCardPoolId = drawCardPoolId, drawCardStoreId = cfg.DrawCardStoreID, activityId = activityId, activityType = private.ActivityType, heroType = MDL.GoldenHeroMain.GetHeroTypeByActivityId(activityId) }, UIGachaLimitPath .. drawCardData.BackgroundPrefab) GoldenHeroMain_Controller.OpenDrawCardActivityID = activityId end function private.RefreshChangeCardInfo(activityId) if GoldenHeroMain_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.UIGachaMainLimit) GoldenHeroMain_Controller.OpenDrawCardMainPanel(activityId) end end function private.CheckFuncOpenIssue() if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GoldHeroActivity) 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.GoldenHeroMain.IsActivityInFuncTime(activityId) then private.ShutDownPartActivityView(activityId) end end end end end --GMS开关变化时刷新 function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.GoldHeroActivity then if not isUnlock then private.ForceCloseActivityView() end end end function private.ShutDownPartActivityView(activityId) for i, v in ipairs(GoldenHeroActiveView) 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, "GoldenHero 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 --region ************************** 商店 ************************************* function GoldenHeroMain_Controller.OpenStoreUnlockShow(icon, name, node) UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroStoreUnlockShow, { Config = { Icon = icon, Name = name }, Node = node }, Const_UI_Lua.UIEnum.UIFunctionUnlockShow) end function GoldenHeroMain_Controller.IsStoreTabUnlock(activityId, storeId) local storeType = MDL.OperationActivity.ActivityBaseData[private.ActivityType]:GetDataByActivityID(activityId).HeroStoreType local storeData = DataSheetManager.GoldHeroActivityStore[storeType]:GetDataByStoreID(storeId) local itemId = storeData.MoneyType local consumeNum = MDL.GoldenHeroMain.GetItemConsumeNumByActivityId(activityId, itemId) local delta = storeData.MoneyNum - consumeNum return delta <= 0, delta end function GoldenHeroMain_Controller.IsStoreTabSoldOut(tabId) local goods = MDL.Shop.GetShopGoodsCfgByTypeID(tabId) for i, v in ipairs(goods) do local goodData = v.OriData if not CTL.PayMall.IsSoldOut(goodData) then return false end end return true end --endregion --region ************************** 红点 ************************************* ---@public 初始化金将体验关红点根节点 ---在运营活动doingActivity发过来的时候,先根据activityId初始化红点的根节点 function GoldenHeroMain_Controller.InitRedPointTreeByActivityId(activityId) --根据activityId初始化红点的eventId GoldenHeroMain_Controller.RpEventId[activityId] = {} for k, v in pairs(GoldenHeroMain_Controller.RpEventIdTemplate) do GoldenHeroMain_Controller.RpEventId[activityId][k] = v .. activityId end MDL.RedPoint.AddRootRpNode(GoldenHeroMain_Controller.RpEventId[activityId].TownHome) GoldenHeroMain_Controller.InitBossRedPointTreeByActivityId(activityId) GoldenHeroMain_Controller.InitStoryRedPointTreeByActivityId(activityId) GoldenHeroMain_Controller.InitFameRedPointTreeByActivityId(activityId) GoldenHeroMain_Controller.InitDrawCardRedPointTreeByActivityId(activityId) GoldenHeroMain_Controller.InitAnecdoteRedPointTreeByActivityId(activityId) GoldenHeroMain_Controller.InitHeroTryFirstPassRedPointTreeByActivityId(activityId) GoldenHeroMain_Controller.InitDirectGiftFreeRedPointTreeByActivityId(activityId) end ---@public 协同讨伐初始化红点 ---先获取相应activityId对应的红点根节点,然后再添加相应的子节点 function GoldenHeroMain_Controller.InitBossRedPointTreeByActivityId(activityId) if not GoldenHeroMain_Controller.RpEventId[activityId] then GoldenHeroMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = GoldenHeroMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local bossKey = GoldenHeroMain_Controller.RpEventId[activityId].Boss local bossNode = townRoot:AddChildRpNode(bossKey, bossKey, activityId) local findRewardKey = GoldenHeroMain_Controller.RpEventId[activityId].BossFindReward bossNode:AddChildRpNode(findRewardKey, findRewardKey, activityId, { findRewardKey }, CTL.GoldenHeroBoss.IsHasFindRewardToCollect(activityId)) local pointRewardKey = GoldenHeroMain_Controller.RpEventId[activityId].BossPointReward bossNode:AddChildRpNode(pointRewardKey, pointRewardKey, activityId, { pointRewardKey }, CTL.GoldenHeroBoss.IsHasDailyRewardToCollect(activityId)) local itemEnoughKey = GoldenHeroMain_Controller.RpEventId[activityId].BossItemEnough bossNode:AddChildRpNode(itemEnoughKey, itemEnoughKey, activityId, { itemEnoughKey }, false) local newOneKey = GoldenHeroMain_Controller.RpEventId[activityId].BossNewOne bossNode:AddChildRpNode(newOneKey, newOneKey, activityId, { newOneKey }, CTL.GoldenHeroBoss.CheckIfHasNewBoss(activityId)) local loginKey = GoldenHeroMain_Controller.RpEventId[activityId].BossLogin bossNode:AddChildRpNode(loginKey, loginKey, activityId, { loginKey }, true and MDL.GoldenHeroMain.IsActivityInFuncTime(activityId)) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end ---@public 武将秘闻初始化红点 ---先获取相应activityId对应的红点根节点,然后再添加相应的子节点 function GoldenHeroMain_Controller.InitStoryRedPointTreeByActivityId(activityId) local isOpenActive = MDL.GoldenHeroMain.IsActivityInFuncTime(activityId) if not GoldenHeroMain_Controller.RpEventId[activityId] then GoldenHeroMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = GoldenHeroMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local storyKey = GoldenHeroMain_Controller.RpEventId[activityId].Story local storyNode = townRoot:AddChildRpNode(storyKey, storyKey, activityId) local newLevelKey = GoldenHeroMain_Controller.RpEventId[activityId].StoryNewLevel storyNode:AddChildRpNode(newLevelKey, newLevelKey, activityId, { newLevelKey }, MDL.GoldenHeroStory.GetLevelRedPointByActivityID(activityId) and isOpenActive) local heroType = MDL.GoldenHeroMain.GetHeroTypeByActivityId(activityId) local isShowEnding = heroType and DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(heroType).IsDisplayRecord if isShowEnding then local endingRewardKey = GoldenHeroMain_Controller.RpEventId[activityId].StoryEndingReward storyNode:AddChildRpNode(endingRewardKey, endingRewardKey, activityId, { endingRewardKey }, MDL.GoldenHeroStory.GetEndingRewardRedPointByActivityID(activityId) and isOpenActive) end local achievementRewardKey = GoldenHeroMain_Controller.RpEventId[activityId].StoryAchievementReward storyNode:AddChildRpNode(achievementRewardKey, achievementRewardKey, activityId, { achievementRewardKey }, MDL.GoldenHeroStory.GetAchievementRewardRedPointByActivityID(activityId) and isOpenActive) local sweepKey = GoldenHeroMain_Controller.RpEventId[activityId].StorySweep storyNode:AddChildRpNode(sweepKey, sweepKey, activityId, { sweepKey }, MDL.GoldenHeroStory.GetSweepRedPointByActivityID(activityId) and isOpenActive) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end ---@public 声名鹊起初始化红点 ---先获取相应activityId对应的红点根节点,然后再添加相应的子节点 function GoldenHeroMain_Controller.InitFameRedPointTreeByActivityId(activityId) if not GoldenHeroMain_Controller.RpEventId[activityId] then GoldenHeroMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = GoldenHeroMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local fameKey = GoldenHeroMain_Controller.RpEventId[activityId].Fame local fameNode = townRoot:AddChildRpNode(fameKey, fameKey, activityId) local levelRewardKey = GoldenHeroMain_Controller.RpEventId[activityId].FameLevelReward fameNode:AddChildRpNode(levelRewardKey, levelRewardKey, activityId, { levelRewardKey }, MDL.GoldenHeroFame.GetLevelRewardRedPointByActivityID(activityId)) local taskRewardKey = GoldenHeroMain_Controller.RpEventId[activityId].FameTaskReward fameNode:AddChildRpNode(taskRewardKey, taskRewardKey, activityId, { taskRewardKey }, MDL.GoldenHeroFame.GetTaskRewardRedPointByActivityID(activityId)) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end ---@public 限时抽卡初始化红点 ---先获取相应activityId对应的红点根节点,然后再添加相应的子节点 function GoldenHeroMain_Controller.InitDrawCardRedPointTreeByActivityId(activityId) if not GoldenHeroMain_Controller.RpEventId[activityId] then GoldenHeroMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = GoldenHeroMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local drawCardKey = GoldenHeroMain_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 GoldenHeroMain_Controller.InitAnecdoteRedPointTreeByActivityId(activityId) local isOpenActive = MDL.GoldenHeroMain.IsActivityInFuncTime(activityId) if not GoldenHeroMain_Controller.RpEventId[activityId] then GoldenHeroMain_Controller.InitRedPointTreeByActivityId(activityId) end if not MDL.GoldenHeroAnecdote.GetAnecdoteInfo(activityId) then return end local townKey = GoldenHeroMain_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local anecdoteKey = GoldenHeroMain_Controller.RpEventId[activityId].Anecdote local anecdoteNode = townRoot:AddChildRpNode(anecdoteKey, anecdoteKey, activityId) local sweepKey = GoldenHeroMain_Controller.RpEventId[activityId].AnecdoteSweep anecdoteNode:AddChildRpNode(sweepKey, sweepKey, activityId, { sweepKey }, CTL.GoldenHeroAnecdote.IsActivityHasLevelCanSweep(activityId) and isOpenActive) local maxEnergyKey = GoldenHeroMain_Controller.RpEventId[activityId].AnecdoteHasEnergy anecdoteNode:AddChildRpNode(maxEnergyKey, maxEnergyKey, activityId, { maxEnergyKey }, CTL.GoldenHeroAnecdote.IsHasEnergy(activityId) and isOpenActive) local newKey = GoldenHeroMain_Controller.RpEventId[activityId].AnecdoteNew anecdoteNode:AddChildRpNode(newKey, newKey, activityId, { newKey }, CTL.GoldenHeroAnecdote.IsHasNewAnecdote(activityId) and isOpenActive) local rewardKey = GoldenHeroMain_Controller.RpEventId[activityId].AnecdoteReward anecdoteNode:AddChildRpNode(rewardKey, rewardKey, activityId, { rewardKey }, CTL.GoldenHeroAnecdote.IsActivityHasReward(activityId) and isOpenActive) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end --直接将服务器数据传进来更新红点节点状态,直接取得相应红点状态作为判断是否首次通关 function GoldenHeroMain_Controller.InitHeroTryFirstPassRedPointTreeByActivityId(activityId) if not GoldenHeroMain_Controller.RpEventId[activityId] then GoldenHeroMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = GoldenHeroMain_Controller.RpEventId[activityId].TownHome local heroTryFirstPass = GoldenHeroMain_Controller.RpEventId[activityId].HeroTryFirstPass local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 townRoot:AddChildRpNode(heroTryFirstPass, heroTryFirstPass, activityId, { heroTryFirstPass }, MDL.GoldenHeroMain.GetHeroTryFirstPassRp()) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end --直接将服务器数据传进来更新红点节点状态,直接取得相应红点状态作为判断是否首次通关 function GoldenHeroMain_Controller.InitDirectGiftFreeRedPointTreeByActivityId(activityId) if not GoldenHeroMain_Controller.RpEventId[activityId] then GoldenHeroMain_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = GoldenHeroMain_Controller.RpEventId[activityId].TownHome local DirectGiftFree = GoldenHeroMain_Controller.RpEventId[activityId].DirectGiftFree local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 --if MDL.RedPoint.GetNodeByLogicParams(townKey, DirectGiftFree) then townRoot:AddChildRpNode(DirectGiftFree, DirectGiftFree, activityId, {DirectGiftFree}, CTL.DirectGift.IsHasFreeGift(MDL.DirectGift.DirectGiftType.Base, activityId)) --else -- MDL.RedPoint.UpdateNodeStateByLogicParams(CTL.DirectGift.IsHasFreeGift(MDL.DirectGift.DirectGiftType.Base, activityId), townKey, DirectGiftFree) --end MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end function private.UpdateDirectGiftFreeRp() local goldHeroTypeData = MDL.OperationActivity.GetOperationActivityInfo(private.ActivityType) if goldHeroTypeData then for i, v in pairs(goldHeroTypeData) do GoldenHeroMain_Controller.InitDirectGiftFreeRedPointTreeByActivityId(v.activityId) end end end --endregion ************************** 红点 ************************************* --region **************************** 打开界面 ****************************** function GoldenHeroMain_Controller.OpenMainView(activityId) --通过activityId找到对应的heroType --ActivityType是需要写在程序中的枚举 local info = MDL.OperationActivity.GetOperationActivityInfo(private.ActivityType, activityId) if info then if CTL.OperationActivity.IsOperationActivityOpen(info) then local heroType = MDL.GoldenHeroMain.GetHeroTypeByActivityId(activityId) local goldHeroActivityModeData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(heroType) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGoldenHeroMain, { heroType = heroType, activityId = activityId }, goldHeroActivityModeData.MainPrefab) end end end function GoldenHeroMain_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 function private.GetCurrentTypeIds(heroType, viewClassPath) if viewClassPath == nil or viewClassPath == "" then logging.error(LTAG.ERROR, "[通用资源HUD] : 当前父级Panel的viewClassPath无效", viewClassPath) return nil end local isSuccess, cfg = DataSheetManager.GoldHeroActivityHUDData[heroType]:TryGetDataByUIName(viewClassPath) if isSuccess then local currencyTypeIds = cfg.Money local currencyCount = #currencyTypeIds if currencyCount > 0 then return currencyTypeIds end end return nil end function GoldenHeroMain_Controller.OpenEnergyBuyViewByAttack(activityId, energyType, itemId) if not energyType then energyType = MDL.GoldenHeroMain.GetEnergyBuyType(itemId, activityId) end local maxCount = DataSheetManager.GoldHeroEnergyGetBuy:GetDataLengthByType_ID(energyType) local energyBuyCount = MDL.GoldenHeroMain.GetGoldHeroEnergyBuyCount(activityId, energyType) if maxCount - energyBuyCount <= 0 then return false end local heroType = MDL.GoldenHeroMain.GetHeroTypeByActivityId(activityId) local heroTypeData = DataSheetManager.GoldHeroActivityModeData:GetDataByHeroType(heroType) if not itemId then if energyType == MDL.GoldenHeroMain.EnergyType.Story then itemId = heroTypeData.LevelEnergyType elseif energyType == MDL.GoldenHeroMain.EnergyType.Boss then itemId = heroTypeData.BossEnergyType end end local energyBuyData = DataSheetManager.GoldHeroEnergyGetBuy:GetDataByType_ID(energyType, energyBuyCount + 1) if CTL.Currency.IsDragonJadeUsedInJapan(energyBuyData.CurrencyID) then --日本消耗龙玉特殊弹窗 UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroEnergyBuy, { param = { activityId = activityId, energyType = energyType }, itemId = itemId }, "GoldenHero/GoldenHeroStore/UIGoldenHeroStoreExchange_JP") else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGoldenHeroEnergyBuy, { param = { activityId = activityId, energyType = energyType }, itemId = itemId }, Const_UI_Lua.UIEnum.UIGoldenHeroStoreExchange) end return true end --endregion **************************** 打开界面 ****************************** --region **************************** 延迟到界面执行 ****************************** function GoldenHeroMain_Controller.GetGoldenHeroFocusTarget() return private.focusTarget, private.focusActivityId end function GoldenHeroMain_Controller.SetGoldenHeroFocusTarget(target, activityId) private.focusTarget = target private.focusActivityId = activityId end function GoldenHeroMain_Controller.AddGoldenHeroDelayView(type, activityId, viewName, viewContext) private.AddToDelayList(type, activityId, { name = viewName, context = viewContext }) end function GoldenHeroMain_Controller.AddGoldenHeroDelayFunc(type, activityId, viewFunc, ...) private.AddToDelayList(type, activityId, { func = viewFunc, params = { ... } }) end --添加非UI的事件 --由于非UI的事件没有焦点切换,会导致下一个Delay无法执行,这里对非UI事件做个标记 --从队列出来的是非UI的事件,需要继续执行ExecuteDelayViewData function GoldenHeroMain_Controller.AddGoldenHeroDelayFuncNoUI(type, activityId, viewFunc, ...) private.AddToDelayList(type, activityId, { func = viewFunc, isUI = false, params = { ... } }) end function private.AddToDelayList(type, activityId, data) if type == GoldenHeroMain_Controller.ViewType.Story then if not private.delayStoryViewList[activityId] then private.delayStoryViewList[activityId] = {} end table.insert(private.delayStoryViewList[activityId], data) elseif type == GoldenHeroMain_Controller.ViewType.Boss then if not private.delayBossViewList[activityId] then private.delayBossViewList[activityId] = {} end table.insert(private.delayBossViewList[activityId], data) elseif type == GoldenHeroMain_Controller.ViewType.Store then if not private.delayStoreViewList[activityId] then private.delayStoreViewList[activityId] = {} end table.insert(private.delayStoreViewList[activityId], data) end if private.focusTarget == type and private.focusActivityId == activityId then private.ExecuteDelayViewData(type, activityId) end end function GoldenHeroMain_Controller.ClearGoldenHeroDelayView() private.delayBossViewList = {} private.delayStoryViewList = {} private.delayStoreViewList = {} end function private.PopGoldenHeroDelayView(type, activityId) if private.focusActivityId == activityId then --private.ExecuteDelayViewData(type, activityId) TimerUtil.TimeOut(function() private.ExecuteDelayViewData(type, activityId) end) end end function private.ExecuteDelayViewData(type, activityId) local data if type == GoldenHeroMain_Controller.ViewType.Story then if private.delayStoryViewList[activityId] then data = table.remove(private.delayStoryViewList[activityId], 1) end elseif type == GoldenHeroMain_Controller.ViewType.Boss then if private.delayBossViewList[activityId] then data = table.remove(private.delayBossViewList[activityId], 1) end elseif type == GoldenHeroMain_Controller.ViewType.Store then if private.delayStoreViewList[activityId] then data = table.remove(private.delayStoreViewList[activityId], 1) end end if data then if data.name then UIManager.OpenView(data.name, data.context) elseif data.func then data.func(table.unpack(data.params)) end if data.isUI == false then private.ExecuteDelayViewData(type, activityId) end end end --endregion local EmptyLightObjPath = ConstAssetPathConfig.EmptyLightObjPath GoldenHeroMain_Controller.MainViewPrefabMode = { AnyPortrait = 1, OrthoGraphic = 2, -- 类型为2时表示场景摄像机需要设置为正交模式 RealBgScene = 3, RenderAndBg = 4, } function GoldenHeroMain_Controller.ShowReal3DModel(modelComponentDataHandle, modeData) UTL.UIRender.Create2DTextureBgScene(modelComponentDataHandle, modeData.HeroBackground, nil, nil) UTL.UIRender.CreateNonPlayerModel(modelComponentDataHandle, modeData.MainPrefabHero, modeData.HeroSize, 0, EmptyLightObjPath) UTL.UIRender.SetHeroParentPos(modelComponentDataHandle, modeData.HeroOffsetX, modeData.HeroOffsetY, 0) UTL.UIRender.SetHeroParentRot(modelComponentDataHandle, 0, 0, 0) end function GoldenHeroMain_Controller.Show3DModel(comp, modeData) comp:Show2DBGModel(modeData.MainPrefabHero, nil, modeData.HeroSize, EmptyLightObjPath) comp:SetSceneTexture(modeData.HeroBackground) comp:SetNodePos(modeData.HeroOffsetX, modeData.HeroOffsetY, 0) comp:SetSceneShadowPlane(false) end function GoldenHeroMain_Controller.ShowRenderModelTexture(comp, modeData) UIUtils.SetActive(comp.gameObject, true) comp:ShowHeroModel(modeData.CameraRenderId, modeData.MainPrefabHero, nil, 1, EmptyLightObjPath) end function GoldenHeroMain_Controller.ShowModelWithOrthoGraphic(modelComponentDataHandle, modeData) UTL.UIRender.Create2DTextureBgScene(modelComponentDataHandle, modeData.HeroBackground, nil, nil) UTL.UIRender.CreateNonPlayerModel(modelComponentDataHandle, modeData.MainPrefabHero, modeData.HeroSize, 0, EmptyLightObjPath) UTL.UIRender.SetCamerOrthographic(2.55) UTL.UIRender.SetHeroParentPos(modelComponentDataHandle, modeData.HeroOffsetX, modeData.HeroOffsetY, 0) UTL.UIRender.SetHeroParentRot(modelComponentDataHandle, 0, 0, 0) local heroType = modeData.HeroType if heroType == MDL.GoldenHeroMain.HeroType.GN then local resolutionRatio = UIUtils.GetScreenResolutionRatio() if resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPad4_3 or resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPadOther then UTL.UIRender.SetHeroParentPos(modelComponentDataHandle, modeData.HeroOffsetX - 2, modeData.HeroOffsetY, 0) end elseif heroType == MDL.GoldenHeroMain.HeroType.JX then local resolutionRatio = UIUtils.GetScreenResolutionRatio() if resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPad4_3 or resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPadOther then UTL.UIRender.SetHeroParentPos(modelComponentDataHandle, modeData.HeroOffsetX, modeData.HeroOffsetY - 0.5, 0) end end end function GoldenHeroMain_Controller.ShowAnyPortrait(modeData, parentTf, view, isFameView) local heroType = modeData.HeroType local anyPortraitObj = TK2API.GetInstance(modeData.MainPrefabHero, nil) anyPortraitObj.transform:SetParent(parentTf) anyPortraitObj.transform:SetLocalScale(1, 1, 1) if isFameView then if heroType == MDL.GoldenHeroMain.HeroType.GY then parentTf:SetLocalPosition(0, 0, 0) elseif heroType == MDL.GoldenHeroMain.HeroType.SSX then parentTf:SetLocalPosition(-733, -135, 0) elseif heroType == MDL.GoldenHeroMain.HeroType.DC then parentTf:SetLocalPosition(-500, -100, 0) elseif heroType == MDL.GoldenHeroMain.HeroType.CC then parentTf:SetLocalPosition(-733, -84, 0) end end anyPortraitObj.transform:SetLocalPosition(0, 0, 0) UIUtils.SetApPortraitSortingOrder(anyPortraitObj.transform, view.gameObject.transform, (isFameView and 210 or 10) - 5000) return anyPortraitObj end --IAE扩展,检测是否需要显示 金将界面 function private.OnDeepLink(key, heroType) if key ~= LuaConst.Deeplink.GoldenHero or not heroType then return end --强制引导时,不打开界面,清掉deeplink存储 if CTL.PlayerGuide.IsForceGuiding() then return end if heroType > 0 then local activityId = MDL.GoldenHeroMain.GetActivityIDByHeroType(heroType) --活动开启着 if activityId > 0 then --在城镇里 if BattleDataGetter.IsOnlineTownLevel() then --防止重复打开 if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGoldenHeroMain) then GoldenHeroMain_Controller.OpenMainView(activityId) end end end end end return GoldenHeroMain_Controller