KLUnionBossMainPanel.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ---@class KLUnionBossMainPanel:UIKmlLuaPanelBase
  2. ---@field view KLUnionBossMainPanelView
  3. local KLUnionBossMainPanel = class(UIKmlLuaPanelBase)
  4. local this =KLUnionBossMainPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. GUI:OSAScrollView_Initialized(self.view.osa_boss,nil,self.BossItemUpdateGetFun,self)
  8. GUI:OSAScrollView_Initialized(self.view.osa_reward,nil,self.RewardItemUpdateGetFun,self)
  9. local activityPanel = GUI:GetUI("dev/outui/Union/Panel/KLUnionActivity/KLUnionActivityPanel")
  10. if activityPanel then
  11. GUI:setPositionX(self.view.root,-67)
  12. else
  13. GUI:setPositionX(self.view.root,0)
  14. end
  15. end
  16. ---@param item UIKmlLuaControl
  17. function this:BossItemUpdateGetFun(item,index)
  18. local data = self.bossInfoListData[index + 1]
  19. local textName = GUI:GetChildById(item,"text_name")
  20. local imgKillIcon = GUI:GetChildById(item,"img_icon_kill")
  21. local imgBossIcon = GUI:GetChildById(item,"img_icon_monster")
  22. local textLv = GUI:GetChildById(item,"text_lv")
  23. GUI:setVisible(imgKillIcon,index < self.killProgress)
  24. local monsterId = data.monster[1][1]
  25. ---@type cfg_monster_column
  26. local monster = SL:GetConfig("cfg_monster",monsterId)
  27. GUI:Text_setString(textName,monster.name)
  28. GUI:Image_loadTexture(imgBossIcon,monster.icon,"Atlas/Monster_icon.spriteatlas")
  29. GUI:Text_setString(textLv,tostring(monster.level) .. "级")
  30. end
  31. ---@param item UIKmlLuaControl
  32. function this:RewardItemUpdateGetFun(item,index)
  33. local data = self.rewardListData[index + 1]
  34. local ctrlItem = GUI:GetChildById(item,"item")
  35. local btnItem = GUI:GetChildById(item,"btn_item")
  36. GUI:Item_setItemId(ctrlItem,data[1])
  37. GUI:AddOnClickEvent(btnItem,self,self.BtnItemOnClick,data[1])
  38. end
  39. function this:BtnItemOnClick(_,itemId)
  40. SL:OpenTips(nil,itemId)
  41. end
  42. ---注册UI事件和服务器消息
  43. function this:RegistEvents()
  44. GUI:AddOnClickEvent(self.view.btn_close,self,self.BtnCloseOnClick)
  45. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_WAR_ALLIANCE_BOSS_PANEL,self.RES_WAR_ALLIANCE_BOSS_PANEL,self)
  46. GUI:AddOnClickEvent(self.view.btn_enter,self,self.BtnEnterOnClick)
  47. end
  48. function this:RES_WAR_ALLIANCE_BOSS_PANEL(_,message)
  49. local curId = message["1"]
  50. self.killProgress = message["5"]
  51. ---@type cfg_rep_column
  52. local repTbl = SL:GetConfig("cfg_rep",curId)
  53. ---@type cfg_repMonster_column
  54. local repMonster = SL:GetConfig("cfg_repMonster",repTbl.monster)
  55. ---@type cfg_repMonster_column[]
  56. self.bossInfoListData = {repMonster}
  57. while repMonster.nextID ~= 0 do
  58. local next = SL:GetConfig("cfg_repMonster",repMonster.nextID)
  59. table.insert(self.bossInfoListData,next)
  60. repMonster = next
  61. end
  62. GUI:OSAScrollView_RefreshList(self.view.osa_boss,#self.bossInfoListData)
  63. self.rewardListData = repTbl.UIreward
  64. GUI:OSAScrollView_RefreshList(self.view.osa_reward,#self.rewardListData)
  65. local isOpen = message["3"]
  66. GUI:setVisible(self.view.btn_enter,isOpen)
  67. end
  68. function this:BtnCloseOnClick()
  69. GUI:UIPanel_Close("dev/outui/Union/Panel/KLUnionBossMain/KLUnionBossMainPanel")
  70. end
  71. function this:BtnEnterOnClick()
  72. GUI:UIPanel_Close("dev/outui/Union/Panel/KLUnionBossMain/KLUnionBossMainPanel")
  73. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_ENTER_WAR_ALLIANCE)
  74. GUI:UIPanel_Close("dev/outui/Union/Panel/KLUnionActivity/KLUnionActivityPanel")
  75. GUI:UIPanel_Close("dev/ui/Union/Panel/KLUnionToggleList/KLUnionToggleListPanel")
  76. end
  77. ---创建或者刷新界面数据时调用
  78. function this:Refresh()
  79. SL.HideMainPanel()
  80. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_WAR_ALLIANCE_PANEL_INFO)
  81. ---@type cfg_repGlobal_column
  82. local config = SL:GetConfig("cfg_repGlobal",14001001)
  83. local tipStr = string.format("前<color=#4CC5FE>%s</color>个通关的战盟将获得拍卖奖励",config.value)
  84. GUI:Text_setString(self.view.txt_pass_tip,tipStr)
  85. end
  86. function this:Close()
  87. local activityPanel = GUI:GetUI("dev/outui/Union/Panel/KLUnionActivity/KLUnionActivityPanel")
  88. if not activityPanel then
  89. SL.ShowMainPanel()
  90. end
  91. end
  92. return this