73 lines
2.1 KiB
Lua
73 lines
2.1 KiB
Lua
--[[
|
|
* @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 and dailyActInfo.mission[1] 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 and dailyActInfo.mission[1] 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()
|
|
local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge)
|
|
if this.GetRechargeState() or not dailyActInfo or not dailyActInfo.mission[1] then
|
|
return false
|
|
end
|
|
return true
|
|
end
|
|
|
|
return this |