KLSkillSelectItem.lua 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ---@class KLSkillSelectItem:UIKmlLuaPanelBase
  2. ---@field view KLSkillSelectItemView
  3. local KLSkillSelectItem = class(UIKmlLuaPanelBase)
  4. local this =KLSkillSelectItem
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---注册UI事件和服务器消息
  9. function this:RegistEvents()
  10. GUI:AddOnTouchEvent(self.view.button1, self, function(ui, control, eventType, systemData)
  11. if eventType == EUIEventName.OnPointerDown then
  12. if systemData.button ~= InputButton.Left then
  13. return
  14. end
  15. self:OnClick()
  16. end
  17. if eventType == EUIEventName.OnPointerEnter then
  18. PCSkillInfoMgr.nowKeyId=self.skillId
  19. GUI:setVisible(self.view.img1, true)
  20. GUI:UIPanel_Open("dev/outui/Skill/Panel/KLSkillFloatInfo/KLSkillFloatInfoPanel",nil,nil,{skillId=self.skillId})
  21. end
  22. if eventType == EUIEventName.OnPointerExit then
  23. GUI:setVisible(self.view.img1, false)
  24. PCSkillInfoMgr.nowKeyId=0
  25. GUI:UI_Close("dev/outui/Skill/Panel/KLSkillFloatInfo/KLSkillFloatInfoPanel")
  26. end
  27. end)
  28. --GUI:AddOnTouchEvent(self.view.button1, self, self.OnTouchEvent)
  29. --GUI:AddOnClickEvent(self.view.button1,self,)
  30. end
  31. ---界面显示时调用一次
  32. function this:Show()
  33. end
  34. ---创建或者刷新界面数据时调用
  35. function this:Refresh()
  36. end
  37. function this:Hide()
  38. end
  39. function this:Close()
  40. end
  41. function this:UpdateUI(skillId,luaIndex)
  42. self.skillId = skillId
  43. self:ChangeSelectSkill()
  44. self.luaIndex = luaIndex
  45. local spriteName=""
  46. ---@type Skill
  47. local skill = SL:GetMetaValue(EMetaVarGetKey.SKILL_DATA, self.skillId)
  48. --log(skill.skillId)
  49. local skillLv = skill and skill.level or 1
  50. if skill.skillId > 0 then
  51. ---@type Skill
  52. --local skill = SL:GetMetaValue(EMetaVarGetKey.SKILL_DATA, self.skillId)
  53. --local skillLv = skill and skill.level or 1
  54. ---@type cfg_skill_info_column
  55. local tbl = SL:GetConfigMultiKeys('cfg_skill_info', skill.skillId, skillLv, 'skillID', 'skillLevel')
  56. spriteName = string.isNullOrEmpty(tbl.icon) and "" or tbl.icon
  57. self.view.img2:SetAtlasSprite("Atlas/UIOutSkillIcon.spriteatlas", spriteName)
  58. self.view.img2:SetActive(true)
  59. end
  60. end
  61. function this:OnTouchEvent(kmlCtrl, eventType, args)
  62. return self.baseUI:OnTouchEvent(kmlCtrl, eventType, args,self.skillId)
  63. end
  64. function this:OnClick()
  65. if LoginManager.selectSkillId.value==self.skillId then
  66. return
  67. end
  68. ---点击之后将右键技能设置为该技能
  69. LoginManager.selectSkillId:Set(self.skillId)
  70. --self.baseUI:ChangeSelectSkill()
  71. --self.view.img3:SetActive(true)
  72. --self.baseUI.lastSelect=self
  73. ---抛出技能改变事件,用于刷新
  74. SL:onLUAEvent(LUA_EVENT_SelectSkill_Change)
  75. end
  76. function this:ChangeSelectSkill()
  77. self.view.img3:SetActive(false)
  78. if LoginManager.selectSkillId and LoginManager.selectSkillId.value~=0 then
  79. if LoginManager.selectSkillId.value==self.skillId then
  80. log("当前右键技能id"..LoginManager.selectSkillId.value)
  81. --self.baseUI.lastSelect=self
  82. self.view.img3:SetActive(true)
  83. end
  84. end
  85. end
  86. return this