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 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)
|
|
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.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
|
|
|
|
return this |