KLUIMasterTalentColumnItem.lua 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. ---@class KLUIMasterTalentColumnItem:UIKmlLuaPanelBase
  2. ---@field view KLUIMasterTalentColumnItemView
  3. local KLUIMasterTalentColumnItem = class(UIKmlLuaPanelBase)
  4. local this =KLUIMasterTalentColumnItem
  5. ---创建时调用一次
  6. function this:Init()
  7. self.SkillDataList = {}
  8. self.type = EMasterTalentType.CAREER
  9. GUI:DataListInitData(self.view.SkillDataList,function()
  10. return self:SkillDataListItemCountFunc()
  11. end,function(realIndex)
  12. return self:SkillDataListItemGetFunc(realIndex)
  13. end,function(realIndex, kmlcontrol)
  14. return self:SkillDataListItemInitFunc(realIndex, kmlcontrol)
  15. end, function(realIndex, kmlcontrol)
  16. return self:SkillDataListItemUpdateFunc(realIndex, kmlcontrol)
  17. end)
  18. end
  19. ---注册UI事件和服务器消息
  20. function this:RegistEvents()
  21. end
  22. --------------------------------技能-------------------------------------------------------
  23. function this:SkillDataListItemCountFunc()
  24. return #self.SkillDataList
  25. end
  26. function this:SkillDataListItemGetFunc(realIndex)
  27. end
  28. function this:SkillDataListItemInitFunc(realIndex, kmlcontrol)
  29. end
  30. function this:SkillDataListItemUpdateFunc(realIndex, kmlcontrol)
  31. local _skillBG = GUI:GetChildControl(self.view.SkillDataList,realIndex,'SkillBG')
  32. local _skillIcon = GUI:GetChildControl(self.view.SkillDataList,realIndex,'SkillIcon')
  33. local _skillMask = GUI:GetChildControl(self.view.SkillDataList,realIndex,'SkillMask')
  34. local _skillLv = GUI:GetChildControl(self.view.SkillDataList,realIndex,'SkillLv')
  35. local _skillButton = GUI:GetChildControl(self.view.SkillDataList,realIndex,'SkillButton')
  36. local _skillSign = GUI:GetChildControl(self.view.SkillDataList,realIndex,'SkillSign')
  37. local _skillLight = GUI:GetChildControl(self.view.SkillDataList,realIndex,'SkillBG_Light')
  38. local skillLv = 0
  39. GUI:Text_setString(_skillLv,"")
  40. GUI:SetActive(_skillSign,false)
  41. GUI:SetActive(_skillLight,false)
  42. --职业天赋
  43. if self.type == EMasterTalentType.CAREER then
  44. ---@type cfg_master_protalent_column
  45. local data = self.SkillDataList[realIndex + 1]
  46. if data.type == 1 then--1天赋;2技能
  47. self:SetSkillBG(_skillBG,1)
  48. elseif data.type == 2 then
  49. self:SetSkillBG(_skillBG,3)
  50. end
  51. GUI:Image_loadTexture(_skillIcon,data.icon,"Atlas/UIOutSkillIcon.spriteatlas")
  52. skillLv = InfoManager.masterTalentInfo:GetMasterLevel(self.type,data.series,data.id)
  53. GUI:Text_setString(_skillLv,skillLv.."/"..data.minMaxLevel[2])
  54. ---点数够就不遮罩
  55. GUI:SetActive(_skillMask,not InfoManager.masterTalentInfo:IsCanUpLevel(data.id,data.series,nil,self.type))
  56. GUI:AddOnClickEvent(_skillButton,self,self.OnClickCareerTalent,{data})
  57. self:ShowUpLevelIconEff(data.id,_skillLight)
  58. elseif self.type == EMasterTalentType.SKILL then--技能天赋
  59. ---@type cfg_master_skilltalent_column
  60. local data = self.SkillDataList[realIndex + 1]
  61. if data.steps == 0 then
  62. GUI:Image_loadTexture(_skillMask,"Knob_1","Atlas/Common.spriteatlas")
  63. GUI:SetActive(_skillMask,false)
  64. self:SetSkillBG(_skillBG,4)
  65. else
  66. skillLv = InfoManager.masterTalentInfo:GetMasterLevel(self.type,data.series,data.id)
  67. GUI:Text_setString(_skillLv,skillLv.."/"..data.minMaxLevel[2])
  68. GUI:SetActive(_skillMask,false)
  69. GUI:SetActive(_skillMask,not InfoManager.masterTalentInfo:IsCanUpLevel(data.id,data.series,data.steps,self.type))
  70. self:SetSkillBG(_skillBG,data.steps)
  71. GUI:Image_loadTexture(_skillMask,"bg_tips","Atlas/Common.spriteatlas")
  72. GUI:SetActive(_skillSign,true)
  73. GUI:Image_loadTexture(_skillSign,"icon-"..data.steps,"Atlas/UIMasterTalent.spriteatlas")
  74. end
  75. GUI:Image_loadTexture(_skillIcon,data.icon,"Atlas/UIOutSkillIcon.spriteatlas")
  76. GUI:AddOnClickEvent(_skillButton,self,self.OnClickSkillTalent,{data})
  77. self:ShowUpLevelIconEff(data.id,_skillLight)
  78. elseif self.type == EMasterTalentType.COMMON then--通用天赋
  79. ---@type cfg_master_commontalent_column
  80. local data = self.SkillDataList[realIndex + 1]
  81. if not data.id then--无数据
  82. GUI:SetActive(_skillBG,false)
  83. GUI:SetActive(_skillIcon,false)
  84. GUI:SetActive(_skillMask,false)
  85. GUI:SetActive(_skillLv,false)
  86. GUI:SetActive(_skillButton,false)
  87. else
  88. self:SetSkillBG(_skillBG,2)
  89. skillLv = InfoManager.masterTalentInfo:GetMasterLevel(self.type,nil,data.id)
  90. GUI:Text_setString(_skillLv,skillLv.."/"..data.minMaxLevel[2])
  91. ---点数够就不遮罩
  92. GUI:SetActive(_skillMask,not InfoManager.masterTalentInfo:IsCanUpLevel(data.id,data.series,data.steps,self.type))
  93. GUI:AddOnClickEvent(_skillButton,self,self.OnClickCommonTalent,{data})
  94. GUI:Image_loadTexture(_skillIcon,data.icon,"Atlas/UIOutSkillIcon.spriteatlas")
  95. self:ShowUpLevelIconEff(data.id,_skillLight)
  96. end
  97. end
  98. end
  99. ---显示升级技能效果
  100. function this:ShowUpLevelIconEff(id,Control)
  101. if self.upLevelCfgId == id then
  102. self.upLevelCfgId = 0
  103. GUI:SetImageAlpha(Control, 1, 1, 1, 1)
  104. GUI:SetActive(Control,true)
  105. local index = 1
  106. self.timer = SL:Schedule( self.timer,0, 0.1, -1, function()
  107. ---渐隐
  108. if index <= 0.2 then
  109. if self.timer then
  110. SL:UnSchedule(self.timer)
  111. self.timer = nil
  112. end
  113. GUI:SetActive(Control,false)
  114. return
  115. end
  116. index = index - 0.15
  117. GUI:SetImageAlpha(Control, 1, 1, 1, index)
  118. end)
  119. end
  120. end
  121. ---设置技能背景和坐标偏移
  122. function this:SetSkillBG(Control,index)
  123. if index > 3 then
  124. GUI:Image_loadTexture(Control,"img_skill_Strengthened","Atlas/UIMasterTalent.spriteatlas")
  125. GUI:setPositionY(Control,-5)
  126. GUI:setContentSize(Control,102,105)
  127. return
  128. end
  129. GUI:Image_loadTexture(Control,"img_skill_bg"..index,"Atlas/UIMasterTalent.spriteatlas")
  130. if index == 1 then
  131. GUI:setPositionY(Control,0)
  132. GUI:setContentSize(Control,75,75)
  133. elseif index == 2 then
  134. GUI:setPositionY(Control,0)
  135. GUI:setContentSize(Control,85,85)
  136. elseif index == 3 then
  137. GUI:setPositionY(Control,0)
  138. GUI:setContentSize(Control,100,100)
  139. end
  140. end
  141. ---点击职业天赋
  142. ---@param data cfg_master_protalent_column
  143. function this:OnClickCareerTalent(control,data)
  144. GUI:UIPanel_Open("dev/outui/SkillTips/Panel/KLUISkillUpTips/KLUISkillUpTipsPanel",_,_,
  145. {masterID = data[1].id,
  146. type = EMasterTalentType.CAREER,
  147. callBack= function()--升级
  148. self:UpLevel(data[1].id,data[1].series)
  149. end})
  150. end
  151. ---点击技能天赋
  152. ---@param data cfg_master_skilltalent_column
  153. function this:OnClickSkillTalent(control,data)
  154. if data[1].steps == 0 then
  155. local skillId = data[1].proTalentId
  156. local lv = InfoManager.masterTalentInfo:GetMasterLevel(EMasterTalentType.CAREER,data[1].series,skillId)
  157. if data[1].type == 3 and SL:MeData_GetSkill(skillId) then
  158. lv = SL:MeData_GetSkill(skillId).level
  159. end
  160. GUI:UIPanel_Open("dev/outui/SkillTips/Panel/KLUISkillTips/KLUISkillTipsPanel",_,_,
  161. {skillID = skillId,skillLevel = lv,tipsType = data[1].type,icon = data[1].icon})
  162. return
  163. end
  164. GUI:UIPanel_Open("dev/outui/SkillTips/Panel/KLUISkillUpTips2/KLUISkillUpTips2Panel",_,_,
  165. {masterID = data[1].id,type = self.type,
  166. callBack= function()--升级
  167. self:UpLevel(data[1].id,data[1].series,data[1].steps)
  168. end})
  169. end
  170. ---点击通用天赋
  171. ---@param data cfg_master_commontalent_column
  172. function this:OnClickCommonTalent(control,data)
  173. local x,y = nil,nil
  174. local skillLv = InfoManager.masterTalentInfo:GetMasterLevel(self.type,data[1].series,data[1].id)
  175. if skillLv < data[1].minMaxLevel[2] then
  176. x,y = -220,0
  177. GUI:UIPanel_Open("dev/ui/Common/Panel/KLCalc/KLCalcPanel",nil,nil,
  178. {
  179. maxNum = InfoManager.masterTalentInfo:GetMaxPoint(data[1].id,skillLv,data[1].minMaxLevel[2],self.type,data[1].series),
  180. ins = self,
  181. isClosePanel = 0,
  182. x = 248,
  183. y = 90,
  184. callback = function(_,addValue)--升级
  185. self:UpLevel(data[1].id,nil,nil,addValue)
  186. end,
  187. intro = "增加点数"
  188. })
  189. end
  190. GUI:UIPanel_Open("dev/outui/SkillTips/Panel/KLUISkillUpTips/KLUISkillUpTipsPanel",_,_,
  191. {masterID = data[1].id,
  192. type = EMasterTalentType.COMMON,
  193. x = x,
  194. y = y,
  195. callBack = function() --升级
  196. self:UpLevel(data[1].id)
  197. end
  198. })
  199. end
  200. ---升级
  201. function this:UpLevel(id,series,step,upLv)
  202. local isCan = InfoManager.masterTalentInfo:IsCanUpLevel(id,series,step,self.type,true)
  203. if not isCan then
  204. return
  205. end
  206. if upLv and upLv == 0 then
  207. --SL:TipMessage({ "升级次数不能为0", 1, NoticeType.NoticeMid })
  208. return
  209. end
  210. if self.timer then
  211. SL:UnSchedule(self.timer)
  212. self.timer = nil
  213. end
  214. self.upLevelCfgId = id
  215. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_UPGRADE_MASTER_TALENT,
  216. {type = self.type,cfgId = id,addLv = upLv or 1})
  217. end
  218. ------------------------------------------------------------------------------------------------
  219. ---创建或者刷新界面数据时调用
  220. function this:Refresh()
  221. end
  222. function this:SetSkillData(skillData,type)
  223. self.SkillDataList = skillData
  224. self.type = type
  225. GUI:DataListUpdateData(self.view.SkillDataList)
  226. end
  227. function this:Close()
  228. if self.timer then
  229. SL:UnSchedule(self.timer)
  230. self.timer = nil
  231. end
  232. end
  233. return this