--[[ * @Classname DailyRechargeManager * @Description 每日首充 * @Date 2019/8/2 13:51 * @Created by MagicianJoker --]] DailyRechargeManager = {} local this = DailyRechargeManager local rechargeValue = 0 function this.Initialize() Game.GlobalEvent:AddEvent(GameEvent.Activity.OnActivityProgressStateChange, this.DailyRechargeChanged) Game.GlobalEvent:AddEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, this.DailyRechargeReset) end function this.InitRechargeStatus() local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge) if dailyActInfo then rechargeValue = dailyActInfo.value CheckRedPointStatus(RedPointType.DailyRecharge) end end function this.GetRechargeValue() return rechargeValue end --1已领取0未完成 function this.GetRechargeState() local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge) if dailyActInfo then for i = 1,#dailyActInfo.mission do if dailyActInfo.mission[i].state == 0 then return false end end end return true end function this.ReceivedEnabled(missionId) local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge) if not dailyActInfo then return false end local actRewardConfig = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig, missionId) for i = 1,#dailyActInfo.mission do if missionId == dailyActInfo.mission[i].missionId then return dailyActInfo.value >= actRewardConfig.Values[1][1] end end return false end function this.CheckRedPoint() local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge) if dailyActInfo then for i = 1, #dailyActInfo.mission do if this.ReceivedEnabled(dailyActInfo.mission[i].missionId) and dailyActInfo.mission[i].state == 0 then return true end end end return false end function this.CheckRedPointYunmeng() local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.yunmenghaoli) if dailyActInfo and #dailyActInfo.mission > 0 then -- 每天检测 local isCheck = PlayerPrefs.GetInt(PlayerManager.uid.."_YunMeng_Check"..dailyActInfo.activityId, 0) if isCheck == 0 then return true end -- for i = 1, #dailyActInfo.mission do if dailyActInfo.mission[i].state == 2 then return true end end end return false end function this.DailyRechargeReset() this.InitRechargeStatus() Game.GlobalEvent:DispatchEvent(GameEvent.Activity.OnActivityOpenOrClose, { type = ActivityTypeDef.DailyRecharge, status = 1 }) end function this.DailyRechargeChanged() this.InitRechargeStatus() end function this.GetDailyRechargeExist() local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge) if this.GetRechargeState() or not dailyActInfo or #dailyActInfo.mission < 1 then return false end return true end function this.GetyunmengyouliExist() local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.yunmenghaoli) if not dailyActInfo or #dailyActInfo.mission < 1 then return false end for i = 1,#dailyActInfo.mission do if dailyActInfo.mission[i].state ~= 1 then return true end end return false end return this