SelfSelectBoxInfo.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---@class SelfSelectBoxInfo @注释
  2. SelfSelectBoxInfo = class()
  3. local this = SelfSelectBoxInfo
  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.RES_USE_SELF_CHOICE_BOX,self.RES_USE_SELF_CHOICE_BOX,self)
  15. end
  16. ---打开自选宝箱响应
  17. function this:RES_USE_SELF_CHOICE_BOX(id,message)
  18. if message and self.useItems and next(self.useItems) then
  19. local list = {}
  20. for i, v in pairs(self.useItems) do
  21. local isAdd = false
  22. for z, a in ipairs(list) do
  23. if v.itemId == a.cfgId then
  24. a.count = a.count + v.count
  25. isAdd = true
  26. break
  27. end
  28. end
  29. if not isAdd then
  30. table.insert(list,{cfgId = v.itemId,count = v.count})
  31. end
  32. end
  33. SL:OpenRewardTipsByItemList(list,0)
  34. self.useItems = {}
  35. end
  36. end
  37. function this:Reset()
  38. self.useItems = {}
  39. end