WingTaskInfo.lua 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ---@class WingTaskInfo 开服翅膀任务
  2. ---@field curChapter number
  3. ---@field wingChapterState table
  4. ---@field wingTaskMap table
  5. WingTaskInfo = class()
  6. local this = WingTaskInfo
  7. this.curChapter = 1
  8. this.wingChapterState = {}
  9. this.wingTaskMap = {}
  10. function this:Init()
  11. self:RegistMessages()
  12. self:Reset()
  13. end
  14. function this:Reset()
  15. self.curChapter = 1
  16. self.wingChapterState = {}
  17. self.wingTaskMap = {}
  18. end
  19. function this:RegistMessages()
  20. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_WINGS_TASK_INFO, self.InfoCallBack, self)
  21. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_WINGS_TASK_CHANGE, self.InfoChangeCallBack, self)
  22. end
  23. function this:InfoCallBack(_, message)
  24. self.curChapter = message.now_chapter
  25. self.wingChapterState = {}
  26. self.wingTaskMap = {}
  27. for key, value in pairs(message.chapter_task_info) do
  28. local id = tonumber(key)
  29. self.wingChapterState[id] = value.state
  30. self.wingTaskMap[id] = value.task_info
  31. end
  32. self:RefreshRedPoint()
  33. SL:onLUAEvent(LUA_EVENT_WING_CHAPTER_CHANGE)
  34. end
  35. function this:InfoChangeCallBack(_, message)
  36. self.wingChapterState[message.now_chapter] = message.chapter_state
  37. local curTaskMap = self.wingTaskMap[message.now_chapter]
  38. for key, value in pairs(message.change_task) do
  39. curTaskMap[key] = value
  40. end
  41. self:RefreshRedPoint()
  42. SL:onLUAEvent(LUA_EVENT_WING_TASK_CHANGE)
  43. end
  44. function this:EnterGame()
  45. end
  46. function this:RefreshRedPoint()
  47. local isShow = false
  48. for key, curTaskMap in pairs(self.wingTaskMap) do
  49. for key, value in pairs(curTaskMap) do
  50. if value.state == E_ChapterState.FINISH then
  51. isShow = true
  52. break
  53. end
  54. end
  55. end
  56. if not isShow then
  57. for key, state in pairs(self.wingChapterState) do
  58. if state == E_ChapterState.FINISH then
  59. isShow = true
  60. break
  61. end
  62. end
  63. end
  64. InfoManager.mainActivityInfo:RefreshMainActivityRedPoint("tog_WingTaskActivity",isShow)
  65. end