UIEfficiencyNewInfo.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ---@class UIEfficiencyNewInfo
  2. UIEfficiencyNewInfo = class()
  3. local this = UIEfficiencyNewInfo
  4. function this:ctor()
  5. end
  6. function this:Reset()
  7. self:ResetData()
  8. end
  9. function this:Init()
  10. self:ResetData()
  11. self:InitData()
  12. self:RegistMessages()
  13. end
  14. ---刷新初始数据
  15. function this:ResetData()
  16. ---效率红点信息
  17. self.EfficiencyRedDotInfoList = {}
  18. ---效率条件激活信息
  19. self.EfficiencyTabActiveList = {}
  20. end
  21. function this:InitData()
  22. end
  23. function this:RegistMessages()
  24. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_EFFECIENCY_TAB_ACTIVE,self.RES_EFFECIENCY_TAB_ACTIVE,self)
  25. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_EFFECIENCY_RED_DOT,self.RES_EFFECIENCY_RED_DOT,self)
  26. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_EFFECIENCY_REWARD_RESULT,self.RES_EFFECIENCY_REWARD_RESULT,self)
  27. end
  28. ---响应效率奖励领取结果
  29. function this:RES_EFFECIENCY_REWARD_RESULT(id,message)
  30. if not message then
  31. return
  32. end
  33. local list = {}
  34. table.insert(list,{cfgId = message.itemId,count = message.count})
  35. SL:OpenRewardTipsByItemList(list,0)
  36. end
  37. ---响应效率条件激活
  38. function this:RES_EFFECIENCY_TAB_ACTIVE(id,message)
  39. if not message then
  40. return
  41. end
  42. local list = {}
  43. for i, v in pairs(message) do
  44. if SL:HasConfig("cfg_efficiency",v) then
  45. table.insert(list,v)
  46. end
  47. end
  48. self.EfficiencyTabActiveList = list
  49. SL:onLUAEvent(LUA_EFFICIENCY_TAB_ACTIVE_CHANGE)
  50. end
  51. ---响应效率页面红点信息
  52. function this:RES_EFFECIENCY_RED_DOT(id,message)
  53. if not message then
  54. return
  55. end
  56. self.EfficiencyRedDotInfoList = message
  57. SL:onLUAEvent(LUA_EFFICIENCY_RED_DOT_CHANGE)
  58. SL:RefreshPanelALLRedPoint("KLUISystemTopPanel")
  59. end
  60. ---获取激活信息
  61. function this:GetEfficiencyTabActiveInfo()
  62. if self.EfficiencyTabActiveList then
  63. return self.EfficiencyTabActiveList
  64. end
  65. return {}
  66. end
  67. ---是否有单个红点(页签上)
  68. ---1 表示上面几个页签, type=2 表示下面奖励页签
  69. function this:GetToggleIsEfficiencyRedDot(group)
  70. if self.EfficiencyRedDotInfoList and self.EfficiencyRedDotInfoList["1"] then
  71. return table.contains(self.EfficiencyRedDotInfoList["1"],group)
  72. end
  73. return false
  74. end
  75. ---获取当前奖励的最低未领取的cfgid
  76. function this:GetNowRewardCfgId()
  77. if self.EfficiencyRedDotInfoList and self.EfficiencyRedDotInfoList["2"] and self.EfficiencyRedDotInfoList["2"]["targetId"] then
  78. return tonumber(self.EfficiencyRedDotInfoList["2"]["targetId"])
  79. end
  80. return 1
  81. end
  82. ---获取效率按钮是否有红点
  83. function this:GetAllIsEfficiencyRedDot()
  84. local redCount = 0
  85. if self.EfficiencyRedDotInfoList and self.EfficiencyRedDotInfoList["1"] then
  86. redCount = table.count(self.EfficiencyRedDotInfoList["1"])
  87. end
  88. return redCount > 0 or self:GetIsCanReward()
  89. end
  90. ---是否可领取奖励
  91. function this:GetIsCanReward()
  92. local myLv = SL:GetMetaValue("LEVEL")
  93. local cfgId = self:GetNowRewardCfgId()
  94. ---@type cfg_efficiency_level_column
  95. local cfg = nil
  96. if cfgId and SL:HasConfig("cfg_efficiency_level",cfgId) then
  97. cfg = SL:GetConfig("cfg_efficiency_level",cfgId)
  98. end
  99. if cfg then
  100. return myLv >= cfg.level
  101. end
  102. return false
  103. end