优化红点检测机制为分帧刷新,优化人物升级红点检测
parent
054c04c465
commit
0a19c1dd82
|
@ -20,13 +20,27 @@ function Game.InitManagers()
|
||||||
Log("===============>初始化管理器")
|
Log("===============>初始化管理器")
|
||||||
Framework.Initialize()
|
Framework.Initialize()
|
||||||
local managers = require("Common/Managers")
|
local managers = require("Common/Managers")
|
||||||
local manager
|
this.managerList = {}
|
||||||
for i, v in ipairs(managers) do
|
for i, v in ipairs(managers) do
|
||||||
manager = require("Modules/"..v)
|
this.managerList[i] = require("Modules/"..v)
|
||||||
manager.Initialize()
|
if this.managerList[i].Initialize then
|
||||||
|
this.managerList[i].Initialize()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
UpdateBeat:Add(this.LateUpdate, this)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Game.LateUpdate()
|
||||||
|
for i, v in ipairs(this.managerList) do
|
||||||
|
if v.LateUpdate then
|
||||||
|
v.LateUpdate()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--应用程序暂停/恢复
|
--应用程序暂停/恢复
|
||||||
function Game.OnApplicationPause(pauseStatus)
|
function Game.OnApplicationPause(pauseStatus)
|
||||||
Log("Game.OnApplicationPause:"..tostring(pauseStatus))
|
Log("Game.OnApplicationPause:"..tostring(pauseStatus))
|
||||||
|
|
|
@ -63,6 +63,28 @@ function this.Initialize()
|
||||||
-- 监听功能开启,结束事件
|
-- 监听功能开启,结束事件
|
||||||
Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionOpen, this.RefreshRedpotByFunctionOpenType)
|
Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionOpen, this.RefreshRedpotByFunctionOpenType)
|
||||||
Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionClose, this.RefreshRedpotByFunctionOpenType)
|
Game.GlobalEvent:AddEvent(GameEvent.FunctionCtrl.OnFunctionClose, this.RefreshRedpotByFunctionOpenType)
|
||||||
|
|
||||||
|
this.isDirty = false
|
||||||
|
this.refreshList = {}
|
||||||
|
this.LateUpdateTime = Time.realtimeSinceStartup
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 红点事件分帧刷新
|
||||||
|
function this.LateUpdate()
|
||||||
|
|
||||||
|
if this.isDirty and Time.realtimeSinceStartup - this.LateUpdateTime > 0.1 then
|
||||||
|
if this.refreshList[1] then
|
||||||
|
local rpType = table.remove(this.refreshList, 1)
|
||||||
|
-- 判断是否需要刷新红点显示
|
||||||
|
if RPData:CheckRedPoint(rpType) then
|
||||||
|
this.RefreshRedObjectStatus(rpType)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- 没有红点要刷新
|
||||||
|
if not this.refreshList[1] then
|
||||||
|
this.isDirty = false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 根据功能
|
-- 根据功能
|
||||||
|
@ -451,10 +473,28 @@ end
|
||||||
|
|
||||||
--- 检测红点状态
|
--- 检测红点状态
|
||||||
function this.CheckRedPointStatus(rpType)
|
function this.CheckRedPointStatus(rpType)
|
||||||
-- 判断是否需要刷新红点显示
|
function _CheckRepeat(rpType)
|
||||||
if RPData:CheckRedPoint(rpType) then
|
|
||||||
this.RefreshRedObjectStatus(rpType)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if this.isDirty then
|
||||||
|
if not table.indexof(this.refreshList, rpType) then
|
||||||
|
table.insert(this.refreshList, rpType)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
--
|
||||||
|
this.isDirty = true
|
||||||
|
this.LateUpdateTime = Time.realtimeSinceStartup
|
||||||
|
--
|
||||||
|
if not table.indexof(this.refreshList, rpType) then
|
||||||
|
table.insert(this.refreshList, rpType)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- -- 判断是否需要刷新红点显示
|
||||||
|
-- if RPData:CheckRedPoint(rpType) then
|
||||||
|
-- this.RefreshRedObjectStatus(rpType)
|
||||||
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- 检测所有红点状态
|
--- 检测所有红点状态
|
||||||
|
|
|
@ -17,6 +17,8 @@ end
|
||||||
|
|
||||||
function this.Initialize()
|
function this.Initialize()
|
||||||
end
|
end
|
||||||
|
function this.LateUpdate()
|
||||||
|
end
|
||||||
|
|
||||||
function this.SetRoleName(name)
|
function this.SetRoleName(name)
|
||||||
this.roleName = name
|
this.roleName = name
|
||||||
|
|
|
@ -16,6 +16,7 @@ function this.Initialize()
|
||||||
for _, v in pairs(TaskTypeDef) do
|
for _, v in pairs(TaskTypeDef) do
|
||||||
TypeTaskData[v] = {}
|
TypeTaskData[v] = {}
|
||||||
end
|
end
|
||||||
|
this.LateUpdateTime = Time.realtimeSinceStartup
|
||||||
end
|
end
|
||||||
|
|
||||||
--missionId =1;
|
--missionId =1;
|
||||||
|
@ -65,7 +66,7 @@ function this.SetTypeTaskList(type, data)
|
||||||
table.insert(TypeTaskData[type], t)
|
table.insert(TypeTaskData[type], t)
|
||||||
LogRed(Language[11982]..data[i].type..Language[11983]..data[i].missionId..Language[11984]..data[i].state)
|
LogRed(Language[11982]..data[i].type..Language[11983]..data[i].missionId..Language[11984]..data[i].state)
|
||||||
end
|
end
|
||||||
this.ChangeVipRedPointState()
|
this.SetDirty()
|
||||||
end
|
end
|
||||||
|
|
||||||
local achievementConfig = ConfigManager.GetConfig(ConfigName.AchievementConfig)
|
local achievementConfig = ConfigManager.GetConfig(ConfigName.AchievementConfig)
|
||||||
|
@ -132,7 +133,7 @@ function this.SetTypeTaskState(type, Id, state, progress, takeTimes,heroId)
|
||||||
taskInfo.heroId = heroId
|
taskInfo.heroId = heroId
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
this.ChangeVipRedPointState()
|
this.SetDirty()
|
||||||
Game.GlobalEvent:DispatchEvent(GameEvent.MissionDaily.OnMissionDailyChanged)
|
Game.GlobalEvent:DispatchEvent(GameEvent.MissionDaily.OnMissionDailyChanged)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -184,7 +185,7 @@ function this.SetTypeTaskInfo(type, Id, state, progress, takeTimes,heroId)
|
||||||
elseif type == TaskTypeDef.DayTask or type == TaskTypeDef.Achievement then--推送时检测 是否达成 飘弹窗提示
|
elseif type == TaskTypeDef.DayTask or type == TaskTypeDef.Achievement then--推送时检测 是否达成 飘弹窗提示
|
||||||
this.SetAllShowTipMission(type, Id, state)
|
this.SetAllShowTipMission(type, Id, state)
|
||||||
end
|
end
|
||||||
this.ChangeVipRedPointState()
|
this.SetDirty()
|
||||||
end
|
end
|
||||||
|
|
||||||
--刷新本地的任务数据
|
--刷新本地的任务数据
|
||||||
|
@ -195,7 +196,7 @@ function this.RefreshTypeTaskInfo(taskInfoList)
|
||||||
this.SetTypeTaskInfo(taskInfo.type, taskInfo.missionId, taskInfo.state, taskInfo.progress, taskInfo.takeTimes,taskInfo.heroId)
|
this.SetTypeTaskInfo(taskInfo.type, taskInfo.missionId, taskInfo.state, taskInfo.progress, taskInfo.takeTimes,taskInfo.heroId)
|
||||||
end
|
end
|
||||||
Game.GlobalEvent:DispatchEvent(GameEvent.MissionDaily.OnMissionDailyChanged)
|
Game.GlobalEvent:DispatchEvent(GameEvent.MissionDaily.OnMissionDailyChanged)
|
||||||
this.ChangeVipRedPointState()
|
this.SetDirty()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 返回已经完成的成就数量和总数量
|
-- 返回已经完成的成就数量和总数量
|
||||||
|
@ -215,6 +216,20 @@ function this.GetAchiveNum(mapId)
|
||||||
return doneNum, totalNum
|
return doneNum, totalNum
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function this.SetDirty()
|
||||||
|
this.isRedDirty = true
|
||||||
|
this.LateUpdateTime = Time.realtimeSinceStartup
|
||||||
|
end
|
||||||
|
-- 生命周期函数
|
||||||
|
-- override
|
||||||
|
function this.LateUpdate()
|
||||||
|
if this.isRedDirty and Time.realtimeSinceStartup - this.LateUpdateTime > 1 then
|
||||||
|
this.ChangeVipRedPointState()
|
||||||
|
this.isRedDirty = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- 检测红点状态
|
-- 检测红点状态
|
||||||
function this.ChangeVipRedPointState()
|
function this.ChangeVipRedPointState()
|
||||||
CheckRedPointStatus(RedPointType.VipPrivilege)
|
CheckRedPointStatus(RedPointType.VipPrivilege)
|
||||||
|
|
Loading…
Reference in New Issue