local DrawCard_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local LuaFuncEntry = require("Main/LuaFuncEntry") local PlayItemRarityTimeline = CSExt.PlayItemRarityTimeline local EternalDrawCardID = 1 local RewardCoinItemID = DataSheetManager.ConstData:GetDataByID("DrawCardGiveItemId").IntValue -- 抽卡过程表现路径配置 -- [卡池类型] = { [抽卡数量] = 资源路径 } -- TODO:等策划做好了替换路径资源 local DrawCardProgressDisplay = { [1] = { --普通卡池 [1] = ConstAssetPathConfig.Path6, --单抽 [10] = ConstAssetPathConfig.AssetPath0, --十连抽 } } DrawCard_Controller.DrawCardType = { Eternal = 1, Limit = 2 } private.heroCardDir = {} function DrawCard_Controller.OnStartup() private.SetupEntryFunc(true) EventSystem.Regist(EventID.BagItem_Update, DrawCard_Controller.RefreshRedPoint) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, DrawCard_Controller.RefreshRedPoint) EventSystem.Regist(EventID.UI_DrawCard_Refresh_MainUI, DrawCard_Controller.RefreshRedPoint) EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) EventSystem.Regist(EventID.OnBackButtonPressed_Event, private.OnClickBackBtnEvent) private.rewardResult = { rewardList = nil, rewardItem = nil, rewardNewDict = LuaExt.CreateTable(10), isInit = false, curIndex = 1 } end function private.SetupEntryFunc(isRegist) LuaFuncEntry.SetupMainEntryFunc(isRegist, LuaFuncEntry.FuncType.OnItemRarityTimelineFinish, private.ProgressShowCallBack) end function DrawCard_Controller.OnShutdown() private.rewardResult = nil private.SetupEntryFunc(false) end function private.OnClickBackBtnEvent() if DrawCard_Controller.IsDuringDrawCardTimeLine() then AuxUtil.StopTimeline() end end function DrawCard_Controller.OpenMainView() if GameAppInfo.IsJapanesePackage() then --日服入口整合所有抽卡活动 local goldenHeroActivityType = MDL.OperationActivity.ActivityType.GoldenHero if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GoldHeroActivity) and CTL.OperationActivity.IsOperationActivityTypeUnlock(goldenHeroActivityType) then local goldenHeroInfo = MDL.OperationActivity.GetOperationActivityInfo(goldenHeroActivityType) if goldenHeroInfo then for i, v in pairs(goldenHeroInfo) do if CTL.OperationActivity.IsOperationActivityOpen(v) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGachaPoolSelect) return end end end end local superGoldActivityType = MDL.OperationActivity.ActivityType.SuperGold if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SuperGoldActivity) and CTL.OperationActivity.IsOperationActivityTypeUnlock(superGoldActivityType) then local superGoldInfo = MDL.OperationActivity.GetOperationActivityInfo(superGoldActivityType) if superGoldInfo then for i, v in pairs(superGoldInfo) do if CTL.OperationActivity.IsOperationActivityOpen(v) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGachaPoolSelect) return end end end end local goldHeroReprintActivityType = MDL.OperationActivity.ActivityType.GoldHeroReprint if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SuperGoldActivity) and CTL.OperationActivity.IsOperationActivityTypeUnlock(goldHeroReprintActivityType) then local goldHeroReprint = MDL.OperationActivity.GetOperationActivityInfo(goldHeroReprintActivityType) if goldHeroReprint then for i, v in pairs(goldHeroReprint) do if CTL.OperationActivity.IsOperationActivityOpen(v) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGachaPoolSelect) return end end end end end --招募抽卡 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGachaMain) end function DrawCard_Controller.GetDrawCardRedPoint() if GameAppInfo.IsJapanesePackage() then --日服入口整合所有抽卡活动 if CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.DrawCard) then return true end local goldenHeroActivityType = MDL.OperationActivity.ActivityType.GoldenHero if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GoldHeroActivity) and CTL.OperationActivity.IsOperationActivityTypeUnlock(goldenHeroActivityType) then local goldenHeroInfo = MDL.OperationActivity.GetOperationActivityInfo(goldenHeroActivityType) if goldenHeroInfo then for i, v in pairs(goldenHeroInfo) do if MDL.RedPoint.GetNodeStateByLogicParams(CTL.GoldenHeroMain.RpEventId[v.activityId].TownHome, CTL.GoldenHeroMain.RpEventId[v.activityId].DrawCardAvailable) then return true end end end end local superGoldActivityType = MDL.OperationActivity.ActivityType.SuperGold if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SuperGoldActivity) and CTL.OperationActivity.IsOperationActivityTypeUnlock(superGoldActivityType) then local superGoldInfo = MDL.OperationActivity.GetOperationActivityInfo(superGoldActivityType) if superGoldInfo then for i, v in pairs(superGoldInfo) do if MDL.RedPoint.GetNodeStateByLogicParams(CTL.SuperGoldMain.RpEventId[v.activityId].TownHome, CTL.SuperGoldMain.RpEventId[v.activityId].DrawCardAvailable) then return true end end end end if GameAppInfo.IsJapanesePackage() then local goldHeroReprintActivityType = MDL.OperationActivity.ActivityType.GoldHeroReprint if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GoldHeroReprint) and CTL.OperationActivity.IsOperationActivityTypeUnlock(goldHeroReprintActivityType) then local goldHeroReprint = MDL.OperationActivity.GetOperationActivityInfo(goldHeroReprintActivityType) if goldHeroReprint then for i, v in pairs(goldHeroReprint) do if MDL.GoldHeroReprint.CheckCanDrawCardRedPoint() then return true end end end end end else return CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.DrawCard) end return false end function DrawCard_Controller.IsShowDrawOneCardRP() local drawCardData = DataSheetManager.DrawCardData:GetDataByID(EternalDrawCardID) if drawCardData then return MDL.DrawCard.GetFreeCount(EternalDrawCardID) > 0 and MDL.DrawCard.GetDrawCardSumCountPerDay() > 0 end return false end function DrawCard_Controller.IsShowDrawTenCardRP() local drawCardData = DataSheetManager.DrawCardData:GetDataByID(EternalDrawCardID) if drawCardData then return UTL.Item.GetItemStockCount(drawCardData.Item) >= 10 and MDL.DrawCard.GetDrawCardSumCountPerDay() >= 10 end return false end --百抽奖励可领取 function DrawCard_Controller.IsHundredRewardRP() if GameAppInfo.IsJapanesePackage() == false then if MDL.DrawCard.HasGetHundredDrawReward() == false then return MDL.DrawCard.GetDrawCardTestSumCount() >= DataSheetManager.ConstData:GetDataByID("SelectionHeroFrequency").IntValue end end return false end function DrawCard_Controller.RefreshRedPoint() if DrawCard_Controller.IsShowDrawOneCardRP() or DrawCard_Controller.IsShowDrawTenCardRP() or DrawCard_Controller.IsHundredRewardRP() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.DrawCard) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.DrawCard) end end function DrawCard_Controller.IsDisplayIDSTips(itemId) if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGachaMain) then local list = DataSheetManager.ConstData:GetDataByID("DrawCardShowGetItemIDS").IntListValue local isDisplay = false for i=1,#list do if itemId == list[i] then isDisplay = true end end return isDisplay end return true end function DrawCard_Controller.IsDisplayGetItemUI(rewards) if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGachaMain) then local list = DataSheetManager.ConstData:GetDataByID("DrawCardNotShowGetItemUI").IntListValue if #rewards == 1 then for i=1,#list do if rewards[1].ItemId == list[i] then return false end end end end return true end --为了在做抽卡奖励展示的时候,将整卡转换为碎片,维护一个字典来判断武将是否激活 --不用hero模块里的是否激活接口是因为其数据在playerchange的时机更新,不能用来判断是否转换成整卡 --该数据在抽卡前刷新即可 function DrawCard_Controller.UpdateHeroCardState() for _, v in DataSheetManager.HeroNum:GetEnumerator() do if MDL.HeroSelect.IsHasHero(v.ID) then private.heroCardDir[v.ID] = true else private.heroCardDir[v.ID] = false end end end --武将整卡是否转换成碎片 function DrawCard_Controller.IsHeroTransToPiece(heroId) return private.heroCardDir[heroId] end function DrawCard_Controller.IsDuringDrawCardTimeLine() return private.isDurationDrawCard or false end function DrawCard_Controller.HandleDrawCardResult(cardPoolType, cardReward, rewardItems) private.rewardResult.rewardList = cardReward private.rewardResult.isInit = true private.rewardResult.curIndex = 0 for i, data in ipairs (private.rewardResult.rewardList) do private.rewardResult.rewardNewDict[i] = false local heroId = UTL.Item.IsItemWholeHero(data.rewardItems[1].ItemId) if heroId then if not CTL.DrawCard.IsHeroTransToPiece(heroId) then -- 判断是否有相同武将卡片重复 local hasSameHero = false if i > 1 then for j = 1, i - 1 do if private.rewardResult.rewardNewDict[j] then local rewardData = private.rewardResult.rewardList[j] local rewardHeroId = UTL.Item.IsItemWholeHero(rewardData.rewardItems[1].ItemId) if rewardHeroId == heroId then hasSameHero = true break end end end end if not hasSameHero then private.rewardResult.rewardNewDict[i] = true end end end end for _, v in ipairs (rewardItems) do if v.ItemId == RewardCoinItemID then private.rewardResult.rewardItem = v break end end UIManager.CloseView(Const_UI_Lua.UIEnum.UIGachaMain) -- UIManager.CloseView(Const_UI_Lua.UIEnum.UIGachaGet) -- 延迟共鸣提示 MDL.FormationResonance.OpenDelayResonanceShow() local isSkipAnim = MDL.DrawCard.GetIsSkipAnim() if not isSkipAnim then if not CTL.DrawCard.ShowDrawCardProgress(cardPoolType, cardReward) then private.ProgressShowCallBack() end else private.ProgressShowCallBack() end end ---抽卡过程表现的接口 ---@param cardPoolType 卡池类型 ---@param rewardList 奖励列表 ---@param callBack 抽卡回调函数 function DrawCard_Controller.ShowDrawCardProgress(cardPoolType, rewardList) local count = #rewardList local path = DrawCardProgressDisplay[cardPoolType][count] if path then local rarityList = {} for i, v in ipairs(rewardList) do local itemId = v.rewardItems[1].ItemId table.insert(rarityList, UTL.Item.GetItemDrawCardColor(itemId)) end CTL.Sound.LowPass() CTL.Sound.PlayGameSound(#rarityList == 10 and "UI_double_recruit" or "UI_single_recruit") private.isDurationDrawCard = true PlayItemRarityTimeline(UTL.String.GetIdByString(path), #rarityList, rarityList) return true end return false end function private.ProgressShowCallBack() private.isDurationDrawCard = false --展示抽卡数据 CTL.Sound.HighPass() private.rewardResult.isDrawCardByOne = MDL.DrawCard.GetIsOriginDrawCardByOne() if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGachaGet) then EventSystem.Dispatch(EventID.UI_Gacha_RefreshGet, private.rewardResult) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGachaGet, private.rewardResult) end end --开关玩法时执行 function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.DrawCard then if not isUnlock then private.EndAndCloseGamePlay() end end end function private.EndAndCloseGamePlay() logging.log(LTAG.LOG, "EndAndCloseGamePlay DrawCard") UIManager.CloseView(Const_UI_Lua.UIEnum.UIGachaSummary) UIManager.CloseView(Const_UI_Lua.UIEnum.UICurrencyExchange) EventSystem.Dispatch(EventID.UI_DrawCard_OnCloseGamePlay) end local DrawCardSkipAnim = "DrawCardSkipAnim" function DrawCard_Controller.IsSkipAnim() if private.isSkipAnim == nil then private.isSkipAnim = PersistentData.PlayerData:Get(DrawCardSkipAnim, false) end return private.isSkipAnim end function DrawCard_Controller.SetSkipAnim(isSkip) private.isSkipAnim = isSkip PersistentData.PlayerData:Set(DrawCardSkipAnim, private.isSkipAnim, true) end return DrawCard_Controller