local HorseRear_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') HorseRear_Controller.RpEventIdTemplate = { TownHome = "HorseRear_TownHome", Main = "HorseRear_Main", Task = "HorseRear_Task", Gift = "HorseRear_Gift", LevelReward = "HorseRear_LevelReward", FeedItemEnough = "HorseRear_FeedItemEnough", } -- 养马活动期界面 local HorseRearActivityView = { Const_UI_Lua.UIEnum.UIHorseRearPay, Const_UI_Lua.UIEnum.UIHorseRearMain, Const_UI_Lua.UIEnum.UIHorseRearTasks, Const_UI_Lua.UIEnum.UIHorseRearStore, Const_UI_Lua.UIEnum.UIHorseRearReward, Const_UI_Lua.UIEnum.UIHorseRearLevelUp, Const_UI_Lua.UIEnum.UIHorseRearGetReward, Const_UI_Lua.UIEnum.UIHorseRearPackageWindow, Const_UI_Lua.UIEnum.UIHorseRearPackageDetail, Const_UI_Lua.UIEnum.UIBagItemTips, Const_UI_Lua.UIEnum.UIPayMallPopUp, Const_UI_Lua.UIEnum.UICommonNoteView, Const_UI_Lua.UIEnum.UICurrencyExchange, Const_UI_Lua.UIEnum.OperationActivity.UIGetActivityItemPanel, } function HorseRear_Controller.OnStartup() EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) EventSystem.Regist(EventID.UI_HorseRear_ActivityEnd, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.AcquireSystemRedAfterUnlock, private.CheckFuncOpenIssue) EventSystem.Regist(EventID.UI_OperationActivity_InfoChanged, private.CheckFuncOpenIssue) private.ActivityType = MDL.OperationActivity.ActivityType.HorseRear private.FunctionType = MDL.Unlock.FunctionType.HorseRear private.endTimerHandle = {} private.isOpenedActivity = {} HorseRear_Controller.RpEventId = {} end function HorseRear_Controller.OpenMainPanel(activityId) if HorseRear_Controller.IsSuperGold(activityId) then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHorseRearMain, {activityId = activityId}, "HorseRear/UIHorseRearMainDarkGold") else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIHorseRearMain, {activityId = activityId}) end end function HorseRear_Controller.IsSuperGold(activityId) if activityId and activityId > 0 then local basicData = MDL.OperationActivity.ActivityBaseData[private.ActivityType]:GetDataByActivityID(activityId) if basicData then local horseId = basicData.HorseID local horseData = DataSheetManager.HorseData:GetDataByHorseID(horseId) local isSuperGold = horseData.HorseQuality == LuaConst.QualityColor.DarkGold --彩金品质需要换皮 return isSuperGold else logging.error(LTAG.ERROR, "hot10BackGround表中找不到activityId:", activityId, "的数据,请检查!!!") end end return false end function HorseRear_Controller.GetActivitySameQualityHorse(activityId, HorseId) local sameQualityHorse = {} local selectHorseInfo = {} local curHorseData = DataSheetManager.HorseData:GetDataByHorseID(HorseId) for i, goodData in MDL.OACommon.GetStoreGoodsEnumerator(private.ActivityType, activityId) do local itemData = DataSheetManager.ItemData:GetDataByID(goodData.ItemID) if itemData.FirstType == LuaConst.ItemType.Horse and itemData.Color == curHorseData.HorseQuality then local horseData = DataSheetManager.HorseData:GetDataByHorseID(itemData.BelongerID) if horseData.HorseID == HorseId then selectHorseInfo = horseData else table.insert(sameQualityHorse, horseData) end end end return sameQualityHorse, selectHorseInfo end --region ************************** 红点 ************************************* ---在运营活动doingActivity发过来的时候,先根据activityId初始化红点的根节点 function HorseRear_Controller.InitRedPointTreeByActivityId(activityId) --根据activityId初始化红点的eventId HorseRear_Controller.RpEventId[activityId] = {} for k, v in pairs(HorseRear_Controller.RpEventIdTemplate) do HorseRear_Controller.RpEventId[activityId][k] = v .. activityId end MDL.RedPoint.AddRootRpNode(HorseRear_Controller.RpEventId[activityId].TownHome) HorseRear_Controller.InitHorseRearRedPointTreeByActivityId(activityId) end function HorseRear_Controller.InitHorseRearRedPointTreeByActivityId(activityId) local isOpenActive = MDL.HorseRear.IsActivityInFuncTime(activityId) if not HorseRear_Controller.RpEventId[activityId] then HorseRear_Controller.InitRedPointTreeByActivityId(activityId) end local townKey = HorseRear_Controller.RpEventId[activityId].TownHome local townRoot = MDL.RedPoint.GetRootNode(townKey) --获取根节点 local mainKey = HorseRear_Controller.RpEventId[activityId].Main local mainNode = townRoot:AddChildRpNode(mainKey, mainKey, activityId) local taskKey = HorseRear_Controller.RpEventId[activityId].Task mainNode:AddChildRpNode(taskKey, taskKey, activityId, {taskKey}, CTL.OACommon.IsHasTaskRedPoint(activityId) and isOpenActive) local giftKey = HorseRear_Controller.RpEventId[activityId].Gift mainNode:AddChildRpNode(giftKey, giftKey, activityId, {giftKey}, CTL.OACommon.IsHasGiftRedPoint(activityId) and isOpenActive) local levelRewardKey = HorseRear_Controller.RpEventId[activityId].LevelReward mainNode:AddChildRpNode(levelRewardKey, levelRewardKey, activityId, {levelRewardKey}, MDL.HorseRear.IsHasLevelReward(activityId) and isOpenActive) local feedItemEnoughKey = HorseRear_Controller.RpEventId[activityId].FeedItemEnough mainNode:AddChildRpNode(feedItemEnoughKey, feedItemEnoughKey, activityId, {feedItemEnoughKey}, MDL.HorseRear.IsFeedItemEnough(activityId) and isOpenActive) MDL.RedPoint.InitAllNodes(townKey) --初始化红点树各个节点的state end --endregion ************************** 红点 ************************************* function HorseRear_Controller.OpenFeedItemPayPopView(activityId) local basicData = MDL.OperationActivity.ActivityBaseData[private.ActivityType]:GetDataByActivityID(activityId) local limitFeedGoodData = MDL.OperationActivity.StoreGoodsData:GetDataByID(basicData.LimitBuyItem) local feedGoodData = MDL.OperationActivity.StoreGoodsData:GetDataByID(basicData.UnlimitBuyItem) local goodData if CTL.PayMall.IsSoldOut(limitFeedGoodData) then goodData = feedGoodData else goodData = limitFeedGoodData end CTL.PayMall.OpenPayMallPopUp(goodData, activityId, private.ActivityType, "IDS_HorseActivity_ChildTitle_5") end function HorseRear_Controller.IsFeedItem(activityId, itemId) local basicData = MDL.OperationActivity.ActivityBaseData[private.ActivityType]:GetDataByActivityID(activityId) if basicData then return itemId == basicData.ItemID end return false end function HorseRear_Controller.IsCanGetLevelReward(activityId, level) if MDL.HorseRear.GetRearLevel(activityId) >= level then if not MDL.HorseRear.GetRearLevelReward(activityId, level) then return true end end return false end function HorseRear_Controller.IsGotLevelReward(activityId, level) return MDL.HorseRear.GetRearLevelReward(activityId, level) or false end --region ************************** 红点 ************************************* function private.CheckFuncOpenIssue() if not MDL.Unlock.IsUnlock(private.FunctionType) 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 end end end end --GMS开关变化时刷新 function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == private.FunctionType then if not isUnlock then private.ForceCloseActivityView() end end end function private.ShutDownPartActivityView(activityId) for i, v in ipairs(HorseRearActivityView) 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]) private.endTimerHandle[activityId] = nil end end -- 关闭活动界面 function private.ForceCloseActivityView() logging.log(LTAG.LOG, "HorseRear 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 --endregion ************************** 红点 ************************************* return HorseRear_Controller