KLBossKillItem.lua 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. ---@class KLBossKillItem:UIKmlLuaPanelBase
  2. ---@field view KLBossKillItemView
  3. local KLBossKillItem = class(UIKmlLuaPanelBase)
  4. local this =KLBossKillItem
  5. ---创建时调用一次
  6. function this:Init()
  7. self.DecomposeGetItem = {}
  8. end
  9. ---创建或者刷新界面数据时调用
  10. function this:Refresh()
  11. end
  12. function this:UpdateUI(data)
  13. self.data= data
  14. ---奖励领取状态:0 正常 1 可领取 2 已领取
  15. self.state = InfoManager.openServerInfo:GetNomStateByBossInfo(data.boss_group,data.boss_id)
  16. local hurt_state,kill_state = InfoManager.openServerInfo:GetSerStateOrNameByBossInfo(data.boss_group,data.boss_id)
  17. local hurt_name,kill_name = InfoManager.openServerInfo:GetSerStateOrNameByBossInfo(data.boss_group,data.boss_id,2)
  18. local personal_count = InfoManager.openServerInfo:GetSerStateOrNameByBossInfo(data.boss_group,data.boss_id,3)
  19. local left_count = data.cond_count - personal_count
  20. if self.state == 1 then
  21. left_count = left_count + 1
  22. end
  23. local noget = left_count <= 0 and self.state == 0 --不可领取
  24. self.hurt_state = hurt_state
  25. self.kill_state = kill_state
  26. GUI:Text_setString(self.view.text666, "剩余:"..left_count) ---剩余次数
  27. GUI:Text_setString(self.view.text21, data.boss_name) ---boss 名称
  28. GUI:Text_setString(self.view.text22, hurt_name) ---伤害第一玩家name
  29. GUI:Text_setString(self.view.text23, kill_name) ---致命第一玩家name
  30. ---伤害第一奖励
  31. self:SetEquipItemIcon(self.view.RewardHurtItem,true,data.hurt_item)
  32. GUI:setVisible(self.view.RewardImg1,hurt_state==2)
  33. GUI:setVisible(self.view.img4,hurt_state==1)
  34. ---致命第一奖励
  35. self:SetEquipItemIcon(self.view.RewardKillItem,true,data.kill_item)
  36. GUI:setVisible(self.view.RewardImg2,kill_state == 2)
  37. GUI:setVisible(self.view.img11,kill_state == 1)
  38. self.perewardInfos = data.personal_item
  39. if table.count(self.perewardInfos) > 0 then
  40. self:SetpersonalItemIcon(true,self.perewardInfos)
  41. end
  42. ---按钮状态text_attach
  43. if self.state == 0 then
  44. GUI:Text_setString(self.view.button29, "前 往")
  45. else
  46. GUI:Text_setString(self.view.button29, "领取奖励")
  47. end
  48. GUI:setVisible(self.view.img33, noget)
  49. GUI:setVisible(self.view.text666,left_count > 0)
  50. GUI:setVisible(self.view.button29, not noget and self.state ~= 2 )
  51. GUI:setVisible(self.view.light_btn29, not noget and self.state == 1 )
  52. GUI:setVisible(self.view.RewardImg3,self.state == 2 )
  53. end
  54. ---单个奖励道具
  55. function this:SetEquipItemIcon(viewItem,show,item)
  56. GUI:setVisible(viewItem,show)
  57. if show then
  58. local count = "<color=#fbd994>"..SL:GetSimpleNumber(tonumber(item[2]),0).."</color>"
  59. GUI:Item_setItemId(viewItem,item[1])
  60. GUI:Item_UpdataData(viewItem,{itemcustomcount = count})
  61. end
  62. end
  63. ---多个奖励道具
  64. function this:SetpersonalItemIcon(show)
  65. GUI:DataListInitData(self.view.Personalrewards, function()
  66. return table.count(self.perewardInfos)
  67. end, function(realIndex)
  68. return self:DataListItemGetFunc(realIndex)
  69. end, function(realIndex, kmlcontrol)
  70. return self:DataListItemInitFunc(realIndex, kmlcontrol)
  71. end, function(realIndex, kmlcontrol)
  72. return self:DataListItemUpdateFunc(realIndex, kmlcontrol)
  73. end)
  74. GUI:DataListUpdateData(self.view.Personalrewards)
  75. end
  76. function this:DataListItemGetFunc(realIndex)
  77. end
  78. function this:DataListItemInitFunc(realIndex, kmlcontrol)
  79. end
  80. function this:DataListItemUpdateFunc(realIndex, kmlcontrol)
  81. local data = self.perewardInfos[realIndex+1]
  82. local item = self.view.Personalrewards:GetChildControl(realIndex, "Personalitem")
  83. local count = "<color=#fbd994>"..SL:GetSimpleNumber(tonumber(data[2]),0).."</color>"
  84. GUI:Item_UpdataData(item, {
  85. itemid = data[1],
  86. itemcustomcount = count
  87. })
  88. end
  89. ---注册UI事件和服务器消息
  90. function this:RegistEvents()
  91. GUI:AddOnClickEvent(self.view.button29, self, self.OnClickButton)
  92. GUI:AddOnClickEvent(self.view.RewardHurtItem,self,self.Hurt_itemClick)
  93. GUI:AddOnClickEvent(self.view.RewardKillItem,self,self.Kill_itemClick)
  94. end
  95. function this:Hurt_itemClick()
  96. if self.hurt_state < 2 then
  97. local iscanget = self.hurt_state == 1
  98. if iscanget then
  99. ---可领取奖励,不用弹提示
  100. SL:SendLuaNetMsg(LuaMessageIdToSever.RECEIVE_GLOBAL_FIRST_KILL_AWARD,{ group = self.data.boss_group ,configId = self.data.boss_id,type = 2})
  101. else
  102. SL:OpenTips(nil,self.data.hurt_item[1])
  103. end
  104. end
  105. end
  106. function this:Kill_itemClick()
  107. if self.kill_state < 2 then
  108. local iscanget = self.kill_state ==1
  109. if iscanget then
  110. ---可领取奖励,不用弹提示
  111. SL:SendLuaNetMsg(LuaMessageIdToSever.RECEIVE_GLOBAL_FIRST_KILL_AWARD,{ group = self.data.boss_group ,configId = self.data.boss_id ,type = 1})
  112. else
  113. SL:OpenTips(nil,self.data.kill_item[1])
  114. end
  115. end
  116. end
  117. function this:OnClickButton()
  118. if self.state == 0 then
  119. --跳转
  120. if self.data.boss_type and self.data.boss_type.monsterType and self.data.boss_type.monsterType> 0 then
  121. SL.HideMainPanel()
  122. GUI:UIPanel_Close("dev/outui/ServerActivity/Panel/KLOpenServer/KLOpenServerPanel")
  123. GUI:UIPanel_Open("dev/outui/ChallengeBoss/Panel/KLChallengeBoss/KLChallengeBossPanel",nil,
  124. nil,{monsterId = self.data.boss_id,monsterType = self.data.boss_type.monsterType })
  125. end
  126. else
  127. --领取个人奖励
  128. SL:SendLuaNetMsg(LuaMessageIdToSever.RECEIVE_PERSONAL_FIRST_KILL_AWARD,{ group = self.data.boss_group ,configId = self.data.boss_id })
  129. end
  130. end
  131. function this:Close()
  132. end
  133. return this