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

110 lines
3.2 KiB
Lua
Raw Normal View History

2021-04-20 13:58:00 +08:00
--[[
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 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
2020-05-09 13:31:21 +08:00
rechargeValue = dailyActInfo.value
CheckRedPointStatus(RedPointType.DailyRecharge)
2020-05-09 13:31:21 +08:00
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
2020-05-09 13:31:21 +08:00
end
function this.ReceivedEnabled(missionId)
2020-05-09 13:31:21 +08:00
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
2020-05-09 13:31:21 +08:00
end
return false
2020-05-09 13:31:21 +08:00
end
function this.CheckRedPoint()
local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge)
2021-06-02 20:25:20 +08:00
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
for i = 1, #dailyActInfo.mission do
if dailyActInfo.mission[i].state == 2 then
return true
end
end
end
return false
end
2020-05-09 13:31:21 +08:00
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()
2020-05-25 19:16:23 +08:00
local dailyActInfo = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.DailyRecharge)
if this.GetRechargeState() or not dailyActInfo or #dailyActInfo.mission < 1 then
2020-05-09 13:31:21 +08:00
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
2020-06-23 18:36:24 +08:00
return this