OpenServiceGiftInfo.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ---@class OpenServiceGiftInfo 开服七日累积登录
  2. OpenServiceGiftInfo = class()
  3. local this = OpenServiceGiftInfo
  4. this.countDay = 0
  5. this.hadReceiveReward = {}
  6. function this:Init()
  7. self:RegistMessages()
  8. self:Reset()
  9. end
  10. function this:Reset()
  11. end
  12. function this:RegistMessages()
  13. -- SL:RegisterLUAEvent(LUA_EVENT_ROLE_LOGIN, self.EnterGame, self)
  14. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_LOGIN_REWARD_INFO_CHANGE, self.InfoChangeCallBack, self)
  15. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECEIVE_LOGIN_REWARD, self.InfoChangeCallBack, self)
  16. end
  17. function this:InfoChangeCallBack(_, message)
  18. self.countDay = message.countDay
  19. self.hadReceiveReward = message.hadReceiveReward
  20. self:RefreshRedPoint()
  21. SL:onLUAEvent(LUA_EVENT_SEVEN_DAY_GIFT)
  22. end
  23. function this:EnterGame()
  24. end
  25. function this:RefreshRedPoint()
  26. local allReward = SL:GetConfigTable("cfg_accumulateLogOn")
  27. local isShow = false
  28. for index, value in ipairs(allReward) do
  29. if value.accumulateDay<= InfoManager.openServiceGiftInfo.countDay and not table.contains(InfoManager.openServiceGiftInfo.hadReceiveReward,value.id) then
  30. isShow = true
  31. break
  32. end
  33. end
  34. InfoManager.mainActivityInfo:RefreshMainActivityRedPoint("tog_SevenDayGiftActivity",isShow)
  35. end