UIFruitInfo.lua 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ---@class UIFruitInfo @注释
  2. UIFruitInfo = class()
  3. local this = UIFruitInfo
  4. function this:ctor()
  5. end
  6. function this:Init()
  7. self:Reset()
  8. self:InitData()
  9. self:RegistMessages()
  10. end
  11. function this:InitData()
  12. end
  13. function this:RegistMessages()
  14. SL:RegisterLuaNetMsg(LuaMessageIdToClient.C_USE_FRUIT_RESULT,self.C_USE_FRUIT_RESULT,self)
  15. SL:RegisterLUAEvent(LUA_EVENT_BAG_CHANGE_AFTER,self.LUA_EVENT_BAG_CHANGE_AFTER,self)
  16. end
  17. function this:C_USE_FRUIT_RESULT(_,message)
  18. if message then
  19. ---分配点数
  20. self.distributionPoint = message["totalFirstLevelAttrs"] and message["totalFirstLevelAttrs"] or 0
  21. if self.isFirstOpenGame then
  22. self.isFirstOpenGame = false
  23. SL:RefreshPanelALLRedPoint("KLAttrPanel")
  24. end
  25. end
  26. end
  27. function this:LUA_EVENT_BAG_CHANGE_AFTER(id,message)
  28. if not message then
  29. return
  30. end
  31. SL:RefreshPanelALLRedPoint("KLAttrPanel")
  32. end
  33. ---是否有果实可使用
  34. function this:IsFruitCanUse()
  35. if SL:MeData_Check() then
  36. ---@type cfg_global_column
  37. local cfg = SL:GetConfig("cfg_global",3003)
  38. if SL:MeData_GetLevel() < tonumber(cfg.value) then--是否满足开放等级
  39. return false
  40. end
  41. local items = SL:GetMetaValue(EMetaVarGetKey.STD_ITEMS)
  42. if items and #items > 0 then
  43. for i, v in pairs(items[1]) do
  44. if SL:HasConfig("cfg_item",v.cfgId) then
  45. ---@type cfg_item_column
  46. local item = SL:GetConfig("cfg_item",v.cfgId)
  47. if item.type == 3 and item.subType == 99 and SL:HasConfig("cfg_fruit",v.cfgId) then--是否满足果实类型并且果实表中是否配了
  48. ---@type cfg_fruit_column
  49. local fruitCfg = SL:GetConfig("cfg_fruit",v.cfgId)
  50. if SL:HasConfig("cfg_att_info",fruitCfg.attribute) then
  51. ---@type cfg_att_info_column
  52. local attCfg = SL:GetConfig("cfg_att_info",fruitCfg.attribute)
  53. if attCfg.base == 1 then --1级属性需要满足点数未达上限方可显示红点
  54. if self.fruitMaxNum > self.distributionPoint then
  55. return true
  56. end
  57. else
  58. return true
  59. end
  60. end
  61. end
  62. end
  63. end
  64. end
  65. return false
  66. end
  67. return false
  68. end
  69. function this:Reset()
  70. ---果实点数上限
  71. self.fruitMaxNum = tonumber(SL:GetConfig("cfg_global",3001).value)
  72. self.distributionPoint = 0
  73. ---第一次进入游戏
  74. self.isFirstOpenGame = true
  75. end