KLUIChallengeBossItem.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ---@class KLUIChallengeBossItem:UIKmlLuaPanelBase
  2. ---@field view KLUIChallengeBossItemView
  3. local KLUIChallengeBossItem = class(UIKmlLuaPanelBase)
  4. local this = KLUIChallengeBossItem
  5. ---创建时调用一次
  6. function this:Init()
  7. GUI:DataListInitData(self.view.line_data_list,function()
  8. return self:BossBtnDataListItemCountFunc()
  9. end,function(realIndex)
  10. return self:BossBtnDataListItemGetFunc(realIndex)
  11. end,function(realIndex, kmlcontrol)
  12. return self:BossBtnDataListItemInitFunc(realIndex, kmlcontrol)
  13. end, function(realIndex, kmlcontrol)
  14. return self:BossBtnDataListItemUpdateFunc(realIndex, kmlcontrol)
  15. end)
  16. self.glod_boss_level_btn_all_item = {}
  17. end
  18. ---创建或者刷新界面数据时调用
  19. function this:Refresh()
  20. end
  21. function this:RefreshItem(data)
  22. self.data = data
  23. self.monsterid = data.monsterid
  24. InfoManager.uiHuntingDemonsInfo:SetIntegralInControl(self.view.Integral_BG,self.view.Integral_Text,self.monsterid)
  25. --local name = SL:GetConfig("cfg_monster", "id", self.monsterid)
  26. local tab = SL:GetConfigMultiKeys('cfg_monster', self.monsterid, 'id')
  27. local name = tab.name
  28. local level = data.level
  29. local appr = tab.appr
  30. local path = SL:GetConfigMultiKeys('cfg_model_monster', appr, 'id').path
  31. self.mapId = data.mapId
  32. self.mapMoveId = data.mapMoveId
  33. local monster_level = SL:GetConfig('cfg_monster', self.monsterid, 'id').level
  34. local nameStr = "<color=#e6e600>Lv." .. monster_level .. "</color> " .. name
  35. GUI:Text_setString(self.view.name,nameStr)
  36. local mscale = ""
  37. if self.data.size then
  38. local scale = math.ceil(self.data.size/100)
  39. mscale = scale .. "," .. scale .. "," .. scale
  40. end
  41. GUI:Model_setSrc(self.view.monster,path,mscale)
  42. if self.data.offset and #self.data.offset >= 2 then
  43. GUI:setPosition(self.view.monster,self.data.offset[1],self.data.offset[2])
  44. end
  45. self.all_line = {}
  46. self.all_MoveId = {}
  47. for i, v in ipairs(self.mapId) do
  48. table.insert(self.all_line,v)
  49. end
  50. for i, v in ipairs(self.mapMoveId) do
  51. table.insert(self.all_MoveId,v)
  52. end
  53. GUI:setVisible(self.view.img_select,false)
  54. GUI:DataListUpdateData(self.view.line_data_list)
  55. --self:GetMonsterCount()
  56. end
  57. function this:GetMonsterCount()
  58. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MONSTER_COUNT_BY_ID, {id=self.data.id,state=1})
  59. end
  60. ---注册UI事件和服务器消息
  61. function this:RegistEvents()
  62. --GUI:AddOnClickEvent(self.view.btn,self,self.OnclickIcon)
  63. -- SL:RegisterLuaNetMsg(LuaMessageIdToClient.MONSTER_COUNT_RESULT_BY_ID,self.MonserCount,self)
  64. end
  65. function this:OnclickIcon()
  66. end
  67. function this:BossBtnDataListItemCountFunc()
  68. return #self.all_line
  69. end
  70. function this:BossBtnDataListItemGetFunc(realIndex)
  71. local data = self.all_line[realIndex + 1]
  72. local item = GUI:UIPanel_Open("dev/outui/ChallengeBoss/Item/KLUIChallengeBossLineItem/KLUIChallengeBossLineItem",self.view.line_data_list,self,{is_copy =2},true)
  73. self.glod_boss_level_btn_all_item[realIndex+1] = item
  74. return item.view.root
  75. end
  76. function this:BossBtnDataListItemInitFunc(realIndex, kmlcontrol)
  77. end
  78. function this:BossBtnDataListItemUpdateFunc(realIndex, kmlcontrol)
  79. local data = self.all_line[realIndex + 1]
  80. local move = self.all_MoveId[realIndex + 1]
  81. self.glod_boss_level_btn_all_item[realIndex+1]:RefreshItem(self.monsterid,data,move,self)
  82. end
  83. function this:ShowSelectImg()
  84. GUI:setVisible(self.view.img_select,true)
  85. end
  86. function this:Close()
  87. end
  88. function this:MonserCount(id, message)
  89. --SL:LogError("MonserCount")
  90. --SL:LogTable(message,true)
  91. if not message then
  92. return
  93. end
  94. if not message["1"] then
  95. return
  96. end
  97. if not self.data then
  98. return
  99. end
  100. if message["1"].id ~= self.data.id then
  101. return
  102. end
  103. for i=1,100,1 do
  104. if message[tostring(i)] and self.glod_boss_level_btn_all_item[i] then
  105. self.glod_boss_level_btn_all_item[i]:MonserCount(nil,message[tostring(i)])
  106. else
  107. break
  108. end
  109. end
  110. end
  111. return this