OpenServiceAthleticsInfo.lua 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ---@class OpenServiceAthleticsInfo
  2. OpenServiceAthleticsInfo = class()
  3. local this = OpenServiceAthleticsInfo
  4. function this:ctor()
  5. end
  6. function this:Init()
  7. self.BossBossRedPoint = false
  8. self.RewardRedPoint = false
  9. self.bossFistKillInfo = {}
  10. self:InitData()
  11. self:RegistMessages()
  12. end
  13. function this:InitData()
  14. end
  15. function this:RegistMessages()
  16. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_ALL_SERVER_FIRST_KILL_INFO, self.RES_ALL_SERVER_FIRST_KILL_INFO, self)
  17. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECEIVE_FIRST_KILL_ENVELOPE, self.RES_RECEIVE_FIRST_KILL_ENVELOPE, self)
  18. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECEIVE_PERSONAL_FIRST_KILL_AWARD, self.RES_RECEIVE_PERSONAL_FIRST_KILL_AWARD, self)
  19. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_GOAL_FIRST_KILL_CHANGE, self.RES_GOAL_FIRST_KILL_CHANGE, self)
  20. SL:RegisterLUAEvent(LUA_EVENT_ENTRY_MAP_LOADING_PANEL_CLOSE,self.LUA_EVENT_ENTRY_MAP_LOADING_PANEL_CLOSE,self)
  21. end
  22. function this:LUA_EVENT_ENTRY_MAP_LOADING_PANEL_CLOSE(_, message)
  23. self:TryReqMessageOnce()
  24. end
  25. ----响应全服首杀和红包数据
  26. ----@param message GoldFirstKillProtos.ResponseAllServerFirstKillData
  27. function this:RES_ALL_SERVER_FIRST_KILL_INFO(_, message)
  28. self.bossFistKillInfo = message
  29. self:RedDotCheck()
  30. SL:onLUAEvent(LUA_EVENT_OPENSERVICE_GOLDBOSSKILL_REDPONT_CHANGE)
  31. end
  32. ----响应领取全服首杀红包
  33. ----@param message GoldFirstKillProtos.ResponseFirstKillRedEnvelope[]
  34. function this:RES_RECEIVE_FIRST_KILL_ENVELOPE(_, message)
  35. if self.bossFistKillInfo then
  36. self.bossFistKillInfo.envelope = message
  37. self:RedDotCheck()
  38. SL:onLUAEvent(LUA_EVENT_OPENSERVICE_GOLDBOSSKILL_REDPONT_CHANGE,true)
  39. end
  40. end
  41. ----响应领取个人奖励
  42. ----@param message GoldFirstKillProtos.ResponsePersonalGoldFirstKillRewardTable[]
  43. function this:RES_RECEIVE_PERSONAL_FIRST_KILL_AWARD(_, message)
  44. if self.bossFistKillInfo then
  45. self.bossFistKillInfo.taskInfo = message
  46. self:RedDotCheck()
  47. --有奖励变化发ture
  48. SL:onLUAEvent(LUA_EVENT_OPENSERVICE_GOLDBOSSKILL_REDPONT_CHANGE,true)
  49. end
  50. end
  51. ----黄金首杀任务变化包
  52. ----@param message GoldFirstKillProtos.PersonalFirstKillTaskStatusChange[]
  53. function this:RES_GOAL_FIRST_KILL_CHANGE(_, message)
  54. if self.bossFistKillInfo then
  55. self.bossFistKillInfo.taskInfo = message
  56. self:RedDotCheck()
  57. SL:onLUAEvent(LUA_EVENT_OPENSERVICE_GOLDBOSSKILL_REDPONT_CHANGE)
  58. end
  59. end
  60. ----@param data GoldFirstKillProtos.ResponseAllServerFirstKillData
  61. function this:RedDotCheck()
  62. self.BossBossRedPoint = false
  63. ---@type sub_mainActivity_column
  64. local tabRankingConfig = SL:GetConfig("sub_mainActivity", 1)
  65. local isShow = tabRankingConfig.showCondition == "" or ConditionManager.Check4D(tabRankingConfig.showCondition)
  66. if isShow then
  67. if not table.isNullOrEmpty(self.bossFistKillInfo) and self.bossFistKillInfo.allServerData ~= nil and self.bossFistKillInfo.taskInfo ~= nil then
  68. for monsterId, v in pairs(self.bossFistKillInfo.allServerData) do
  69. if ((not self.bossFistKillInfo.envelope[monsterId]
  70. or self.bossFistKillInfo.envelope[monsterId] == false))
  71. or self.bossFistKillInfo.taskInfo[monsterId] == "2" then
  72. self.BossBossRedPoint = true
  73. break
  74. end
  75. end
  76. for monsterId, v in pairs(self.bossFistKillInfo.taskInfo) do
  77. if v == "2" then
  78. self.BossBossRedPoint = true
  79. break
  80. end
  81. end
  82. end
  83. end
  84. InfoManager.mainActivityInfo:RefreshMainActivityRedPoint("tog_FirstKill",self.BossBossRedPoint)
  85. end
  86. function this:TryReqMessageOnce()
  87. if not self.isReqMsg then
  88. self.isReqMsg = true
  89. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_ALL_SERVER_FIRST_KILL_INFO)
  90. end
  91. end
  92. function this:GetDiffTime()
  93. local isbeforerefresh, differenceTime = self:GetServerOpendifferenceTime()
  94. local serverTime = Time.GetServerTime()
  95. local outTimeTbl = ConditionManager.GetConditionParams(tabRankingConfig.showCondition)
  96. local endTime = (tonumber(outTimeTbl[2]) - 1) * 86400000 + SL:GetEnterRoleRes().openServerTime
  97. local diff = endTime - serverTime - differenceTime * 1000
  98. if isbeforerefresh then
  99. diff = endTime - serverTime + differenceTime * 1000
  100. end
  101. return diff
  102. end
  103. function this:GetServerOpendifferenceTime()
  104. if SL:GetEnterRoleRes() == nil then
  105. return -1
  106. end
  107. local openTime = Time.FormatTimeYMDHMS(SL:GetEnterRoleRes().openServerTime / 1000)
  108. local hour = tonumber(string.sub(openTime, 12, 13))
  109. local minute = tonumber(string.sub(openTime, 15, 16))
  110. local second = tonumber(string.sub(openTime, 18, 19))
  111. local differenceTime = 0 --刷新差值
  112. local refreshTime = 5 --刷新时间5点改为0点
  113. local isbeforerefresh = hour < refreshTime
  114. differenceTime = hour * 3600 + minute * 60 + second
  115. return isbeforerefresh, differenceTime
  116. end
  117. function this:Reset()
  118. self.isReqMsg = nil
  119. end