miduo_client/Assets/ManagedResources/~Lua/Modules/DailyRecharge/DailyRechargeManager.lua

73 lines
2.0 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
--[[
* @Classname DailyRechargeManager
* @Description
* @Date 2019/8/2 13:51
* @Created by MagicianJoker
--]]
DailyRechargeManager = {}
local this = DailyRechargeManager
local rechargeState = false
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
rechargeState = dailyActInfo.mission[1].state
rechargeValue = dailyActInfo.value
Log("rechargeValue "..rechargeValue)
if rechargeState == 0 then
CheckRedPointStatus(RedPointType.DailyRecharge)
end
end
end
function this.GetRechargeValue()
return rechargeValue
end
--1已领取0未完成
function this.GetRechargeState()
return rechargeState == 1
end
function this.SetRechargeState(value)
rechargeState = value
end
function this.ReceivedEnabled()
local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge)
if dailyActInfo then
local actRewardConfig = ConfigManager.GetConfigData(ConfigName.ActivityRewardConfig, dailyActInfo.mission[1].missionId)
return dailyActInfo.value >= actRewardConfig.Values[1][1]
else
return false
end
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()
if this.GetRechargeState() or ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.DailyRecharge) == nil then
return false
end
return true
end
return this