KLUIChallengeBossSelectBtnItem.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ---@class KLUIChallengeBossSelectBtnItem:UIKmlLuaPanelBase
  2. ---@field view KLUIChallengeBossSelectBtnItemView
  3. local KLUIChallengeBossSelectBtnItem = class(UIKmlLuaPanelBase)
  4. local this = KLUIChallengeBossSelectBtnItem
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---创建或者刷新界面数据时调用
  9. function this:Refresh()
  10. end
  11. function this:RefreshItem(data,select_gold_level,panel,type)
  12. ---@type KLChallengeBossPanel
  13. self.panel = panel
  14. self.data = data
  15. self.level = data.level
  16. self.monsterid = data.monsterid
  17. self.type = type
  18. local tab = SL:GetConfigMultiKeys('cfg_monster', self.monsterid, 'id')
  19. local name = tab.name
  20. local icon = tab.icon
  21. local playerLevel = SL:GetMetaValue(EMetaVarGetKey.LEVEL)
  22. local level_str = "Lv." .. self.level
  23. if playerLevel < self.level then
  24. level_str = "开启等级: <color=#ff2323>".. self.level.."</color>"
  25. end
  26. GUI:Text_setString(self.view.level,level_str)
  27. GUI:Text_setString(self.view.name,name)
  28. GUI:Image_loadTexture(self.view.touxiang,icon,"Atlas/Monster_icon.spriteatlas")
  29. if self.type == EBossChallengeType.Field then
  30. if self.data.index == select_gold_level then
  31. GUI:setVisible(self.view.level_select,true)
  32. else
  33. GUI:setVisible(self.view.level_select,false)
  34. end
  35. elseif self.type == EBossChallengeType.Secret or self.type == EBossChallengeType.Sanctuary then
  36. if self.level == select_gold_level then
  37. GUI:setVisible(self.view.level_select,true)
  38. else
  39. GUI:setVisible(self.view.level_select,false)
  40. end
  41. elseif self.type == EBossChallengeType.Privilege then
  42. if self.data.index == select_gold_level then
  43. GUI:setVisible(self.view.level_select,true)
  44. else
  45. GUI:setVisible(self.view.level_select,false)
  46. end
  47. end
  48. end
  49. function this:HideItem()
  50. GUI:setVisible(self.view.level_select,false)
  51. end
  52. ---注册UI事件和服务器消息
  53. function this:RegistEvents()
  54. GUI:AddOnClickEvent(self.view.btn,self,self.OnclickIcon)
  55. end
  56. function this:OnclickIcon()
  57. if self.type == 2 then
  58. self.panel:HideSelectLevelOutdoor()
  59. GUI:setVisible(self.view.level_select,true)
  60. self.panel:SelectLevelOutdoor(self.data.index,self)
  61. elseif self.type == 3 then
  62. self.panel:HideSelectLevelSecret()
  63. GUI:setVisible(self.view.level_select,true)
  64. self.panel:SelectLevelSecret(self.level,self)
  65. elseif self.type == 4 then
  66. self.panel:HideSelectLevelPrivilege()
  67. GUI:setVisible(self.view.level_select,true)
  68. self.panel:SelectLevelPrivilege(self.data.index,self)
  69. elseif self.type == EBossChallengeType.Sanctuary then
  70. self.panel:HideSanctuaryLevelSecret()
  71. GUI:setVisible(self.view.level_select,true)
  72. self.panel:SelectSanctuarySecret(self.level,self)
  73. end
  74. end
  75. function this:Close()
  76. end
  77. return this