--[[ 势力共建Controller ]] local GuildTarget_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local GuildTaskKey = "GuildTaskKey" --势力任务入口一次性查看红点 function GuildTarget_Controller.OnStartup() EventSystem.Regist(EventID.FunctionUnlockUpdate, private.OnFunctionUnlockUpdate) private.maxScoreValue = 0 end function GuildTarget_Controller.SetOpenGuildTargetView() if not PersistentData.PlayerData:Get(GuildTaskKey) then PersistentData.PlayerData:Set(GuildTaskKey, true, true) GuildTarget_Controller.RefreshGuildTargetRedpoint() end end function private.OnFunctionUnlockUpdate(funcID, isComplete) --功能解锁通知服务器推送数据 if isComplete and funcID == MDL.Unlock.FunctionType.GuildTarget then GuildTarget_Controller.RefreshGuildTargetRedpoint() end end function GuildTarget_Controller.RefreshGuildTargetRedpoint() if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.GuildTarget) then return end if not PersistentData.PlayerData:Get(GuildTaskKey) then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Task) EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.GuildTarget, true) return end if MDL.GuildTarget.GetScoreRewardRedPoint() or MDL.GuildTarget.GetDayRewardRedPoint() or MDL.GuildTarget.GetWeekRewardRedPoint() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Task) EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.GuildTarget, true) return end CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Task) EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.GuildTarget, false) end function GuildTarget_Controller.IsCanGetRewardById(id) local taskScore = MDL.GuildTarget.GetGuildTaskScore() local rewardCfg = DataSheetManager.GuildTargetSchedule:GetDataByID(id) return rewardCfg.Score <= taskScore and not MDL.GuildTarget.IsHasGetRewardById(id) end function GuildTarget_Controller.GetMaxScoreValue() if private.maxScoreValue > 0 then return private.maxScoreValue end local maxId = DataSheetManager.GuildTargetSchedule:GetDataCount() local maxData = DataSheetManager.GuildTargetSchedule:GetDataByID(maxId) private.maxScoreValue = maxData.Score return private.maxScoreValue end return GuildTarget_Controller