UISkillSettingsView.lua 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  1. local UISkillSettingsView = require("UISkill/UISkillSettingsView_Generate")
  2. local ColorExtension = require("ColorExtension")
  3. function UISkillSettingsView:OnAwake(data)
  4. self.controller = require("UISkill/UISkillSettingsCtr"):new()
  5. self.controller:Init(self)
  6. self.controller:SetData(data)
  7. end
  8. function UISkillSettingsView:AddEventListener()
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_PARTER_ADD, self, self.OnParterAdd)
  10. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_SKILL_SLOT_CHANGED, self, self.OnRefreshSlotSkillEvent)
  11. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_SKILL_CHANGED, self, self.OnSkillChanged)
  12. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_SKILL_RESET_LV_COUNT_CHANGED, self, self.OnSkillRestLvCountChanged)
  13. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.RED_POINT_NOTICE, self, self.OnRedPointNotice)
  14. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_CRUISE_CHANGED, self, self.OnCruiseChanged)
  15. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_ADVANCESKILLEXP_CHANGED, self, self.OnAdvanceSkillExpChanged)
  16. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.COIN_CHANGED, self, self.OnCoinChanged)
  17. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.SKILL_EQUIP_LV_UP_REFRESH, self, self.RefreshTreeView)
  18. end
  19. function UISkillSettingsView:FillContent(data, uiBase)
  20. self.uiBase = uiBase
  21. local gameObject = self.uiBase:GetRoot()
  22. if gameObject ~= nil then
  23. self.gameObject = gameObject
  24. self.transform = gameObject.transform
  25. end
  26. self:InitGenerate(self.transform, data)
  27. self:Init()
  28. end
  29. function UISkillSettingsView:Init()
  30. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.MAIN_VIEW_UP_SKILL_BTN)
  31. self.skillList.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
  32. return self:GetSkillTreeItemByRowColumn(gridView, itemIndex, row, column)
  33. end, nil)
  34. self.isEquiping = false
  35. -- 用于避免频繁向服务器发送升级,加一个限制
  36. -- 只在升级消息完成再去发送,避免由于中间过程出问题,导致其它技能也不能升级
  37. -- 则换算成,只要当前选择的技能刷新了就能继续发送消息
  38. self.isSendUpgradeLv = false
  39. self:InitResourceBox()
  40. self:RefreshHero()
  41. self:RefreshSwitchHero()
  42. self:HideUpLevelFx()
  43. end
  44. function UISkillSettingsView:RemoveEventListener()
  45. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  46. self.btnUpgrade.repeatButton:AddRepeatClickEventListener(nil, nil)
  47. self.dragContainer.reorderableList.OnElementSiblingChanged:RemoveAllListeners()
  48. self.dragContainer.reorderableList.OnElementEndDrag:RemoveAllListeners()
  49. self.skillList.loopGridView.ScrollRect.onValueChanged:RemoveAllListeners()
  50. end
  51. function UISkillSettingsView:AddUIEventListener()
  52. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  53. self.uiBase:AddButtonUniqueEventListener(self.btnLeft.button, self, self.OnClickLeftBtn)
  54. self.uiBase:AddButtonUniqueEventListener(self.btnRight.button, self, self.OnClickRightBtn)
  55. self.uiBase:AddButtonUniqueEventListener(self.btnReset.button, self, self.OnClickResetBtn)
  56. self.uiBase:AddButtonUniqueEventListener(self.btnInfo.button, self, self.OnClickInfoBtn)
  57. self.uiBase:AddButtonUniqueEventListener(self.btnLearn.button, self, self.OnClickLearnBtn)
  58. self.uiBase:AddButtonUniqueEventListener(self.btnSkillAdvance.button, self, self.OnClickAvanceBtn)
  59. self.uiBase:AddButtonUniqueEventListener(self.btnEquip.button, self, self.OnClickEquipBtn)
  60. self.uiBase:AddButtonUniqueEventListener(self.btnSkillAdvanceInfo.button, self, self.OnClickAdvanceAttrBtn)
  61. self.uiBase:AddButtonUniqueEventListener(self.image.button, self, self.OnClickShowChangeSkillExp)
  62. self.uiBase:AddButtonUniqueEventListener(self.cancelReplace.button, self, self.OnClickCancelReplaceBtn)
  63. self.btnUpgrade.repeatButton:AddRepeatClickEventListener(self, self.OnClickUpgradeBtn)
  64. self.uiBase:AddButtonUniqueEventListener(self.skillItem1.icon.button, self, self.OnClickSlotSkillBtn, 1)
  65. self.uiBase:AddButtonUniqueEventListener(self.skillItem2.icon.button, self, self.OnClickSlotSkillBtn, 2)
  66. self.uiBase:AddButtonUniqueEventListener(self.skillItem3.icon.button, self, self.OnClickSlotSkillBtn, 3)
  67. self.uiBase:AddButtonUniqueEventListener(self.skillItem4.icon.button, self, self.OnClickSlotSkillBtn, 4)
  68. self.uiBase:AddButtonUniqueEventListener(self.slotLabel.slot1.btnReplace.button, self, self.OnClickReplaceBtn, 1)
  69. self.uiBase:AddButtonUniqueEventListener(self.slotLabel.slot2.btnReplace.button, self, self.OnClickReplaceBtn, 2)
  70. self.uiBase:AddButtonUniqueEventListener(self.slotLabel.slot3.btnReplace.button, self, self.OnClickReplaceBtn, 3)
  71. self.uiBase:AddButtonUniqueEventListener(self.slotLabel.slot4.btnReplace.button, self, self.OnClickReplaceBtn, 4)
  72. self.uiBase:AddButtonUniqueEventListener(self.btnBack.button, self, self.OnClickBackBtn)
  73. self.dragContainer.reorderableList.OnElementSiblingChanged:AddListener(function(reorderableListEventStruct)
  74. self:OnDragSlotSkillList(reorderableListEventStruct)
  75. end)
  76. self.dragContainer.reorderableList.OnElementEndDrag:AddListener(function()
  77. self:OnEngDragSkillList()
  78. end)
  79. self.skillList.loopGridView.ScrollRect.onValueChanged:AddListener(function(offset)
  80. self:RefreshArrowHead(offset)
  81. end)
  82. end
  83. function UISkillSettingsView:OnHide()
  84. end
  85. function UISkillSettingsView:OnShow(data)
  86. if not data then return end
  87. self.controller:SetData(data)
  88. if self.upLevelFxTimer then
  89. self.upLevelFxTimer:Stop()
  90. self.upLevelFxTimer = nil
  91. end
  92. self.isEquiping = false
  93. self:RefreshHero()
  94. self:RefreshSwitchHero()
  95. self:HideUpLevelFx()
  96. end
  97. function UISkillSettingsView:OnClose()
  98. end
  99. function UISkillSettingsView:OnDispose()
  100. if self.delayTimer then
  101. self.delayTimer:Stop()
  102. end
  103. self.delayTimer = nil
  104. self:HideUpLevelFx()
  105. if self.upLevelFxTimer then
  106. self.upLevelFxTimer:Stop()
  107. self.upLevelFxTimer = nil
  108. end
  109. self.curSelectSkillItem = nil
  110. self.isSendUpgradeLv = nil
  111. self.isEquiping = nil
  112. self.skillList.loopGridView:Dispose()
  113. self.markShowDatas = nil
  114. end
  115. function UISkillSettingsView:OnParterAdd()
  116. local changeHero = self.controller:RefreshOwnedHeros()
  117. self:RefreshSwitchHero()
  118. if changeHero then
  119. self:RefreshHero()
  120. end
  121. end
  122. function UISkillSettingsView:OnRefreshSlotSkillEvent(heroId)
  123. if self.controller:GetHeroId() ~= heroId then return end
  124. self.controller:UpdateSlotSkills()
  125. self:RefreshTreeView(false)
  126. self:RefreshSelectSkillInfo()
  127. self:RefreshSlotSkill(false)
  128. if self.isEquiping then
  129. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay("SkillChange")
  130. self:OnClickCancelReplaceBtn()
  131. end
  132. end
  133. function UISkillSettingsView:OnSkillChanged(heroId, newSkills, upLevelSkills,downLvSkills,isRefeSelectId)
  134. if self.controller:GetHeroId() ~= heroId then return end
  135. self.controller:RefreshSkillList()
  136. if isRefeSelectId then
  137. local curSkillId = self.controller:GetSelectSkillId()
  138. while not self.controller:GetSkilldataByIndex(curSkillId) do
  139. local skillTreeData = self.controller:GetSkillTreeCfgData(curSkillId)
  140. local skillList = skillTreeData and skillTreeData.SuperSkill
  141. if not skillList then
  142. break
  143. end
  144. local heroid = self.controller:GetHeroId()
  145. local herodata = ManagerContainer.DataMgr.UserData:GetHeroData(heroid)
  146. local jobdata = ManagerContainer.CfgMgr:GetJobDataById(herodata.configId)
  147. if #skillList > 1 and jobdata and jobdata.JobBranch then
  148. curSkillId = skillList[jobdata.JobBranch][2]
  149. else
  150. curSkillId = skillList[1][2]
  151. end
  152. end
  153. if curSkillId ~= self.controller:GetSelectSkillId() then
  154. self.controller:SetSelectSkillId(curSkillId)
  155. end
  156. end
  157. self.controller:UpdateSlotSkills()
  158. self:RefreshTreeView(false)
  159. self:RefreshSelectSkillInfo()
  160. self:RefreshSlotSkill(false)
  161. if upLevelSkills and #upLevelSkills > 0 then
  162. self:ShowUpLevelFx()
  163. end
  164. end
  165. function UISkillSettingsView:OnSkillRestLvCountChanged()
  166. self:RefreshResetSkillLvBtn()
  167. end
  168. function UISkillSettingsView:OnRedPointNotice(rpType)
  169. if rpType ~= Enum.RedPointEnum.SkillUnlockRP then
  170. return
  171. end
  172. self:RefreshTreeView(false)
  173. end
  174. function UISkillSettingsView:OnCoinChanged()
  175. local itemCfgId = Enum.ItemType.Coin
  176. local count = CommonUtil.GetOwnResCountByItemId(itemCfgId)
  177. self.currency1.number.text.text = CommonUtil.FormatNumber(count)
  178. end
  179. function UISkillSettingsView:OnCruiseChanged()
  180. local itemCfgId = Enum.ItemType.SkillExp
  181. local count = CommonUtil.GetOwnResCountByItemId(itemCfgId)
  182. self.currency2.number.text.text = CommonUtil.FormatNumber(count)
  183. end
  184. function UISkillSettingsView:OnAdvanceSkillExpChanged()
  185. local itemCfgId = Enum.ItemType.AdvanceSkillExp
  186. local count = CommonUtil.GetOwnResCountByItemId(itemCfgId)
  187. self.currency3.number.text.text = CommonUtil.FormatNumber(count)
  188. end
  189. function UISkillSettingsView:OnClickSkillItem(btn, params)
  190. if self.isEquiping then return end
  191. local skillId = params[0]
  192. if not self.controller:SetSelectSkillId(skillId) then
  193. return
  194. end
  195. if self.curSelectSkillItem then
  196. self.curSelectSkillItem.selectSign:SetActive(false)
  197. end
  198. local itemlua = params[1]
  199. itemlua.selectSign:SetActive(true)
  200. self.curSelectSkillItem = itemlua
  201. self:RefreshSelectSkillInfo()
  202. local selectHeroId = self.controller:GetHeroId()
  203. ManagerContainer.RedPointMgr.HeroRPCtr:CancelSkillUnlockNotify(selectHeroId, skillId)
  204. end
  205. function UISkillSettingsView:OnClickLeftBtn()
  206. if self.isEquiping then return end
  207. if not self.controller:ChangeHero(false) then return end
  208. self:RefreshHero()
  209. end
  210. function UISkillSettingsView:OnClickRightBtn()
  211. if self.isEquiping then return end
  212. if not self.controller:ChangeHero(true) then return end
  213. self:RefreshHero()
  214. end
  215. function UISkillSettingsView:OnClickResetBtn()
  216. if self.isEquiping then return end
  217. local herodata = ManagerContainer.DataMgr.UserData:GetHeroData(self.controller:GetHeroId())
  218. local jobdata = ManagerContainer.CfgMgr:GetJobDataById(herodata.configId)
  219. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISkillResetTips, {{self.SendResetSkillLv, self},nil,jobdata and jobdata.JobStage >= 3})
  220. end
  221. function UISkillSettingsView:OnClickInfoBtn()
  222. if self.isEquiping then return end
  223. -- 计算显示的数据
  224. if not self.markShowDatas then
  225. self.markShowDatas = {}
  226. self.markShowDatas[1] = 'TitleSkillDsc'
  227. -- 'TitleNatureDsc'
  228. local markCfgDatas = ManagerContainer.CfgMgr:GetMarkCfg()
  229. if markCfgDatas then
  230. local datas = {}
  231. self.markShowDatas[2] = datas
  232. for id, markCfgData in pairs(markCfgDatas) do
  233. if markCfgData.ShowTypes == 0 or markCfgData.ShowTypes == 2 then
  234. datas[#datas + 1] = {id, markCfgData.Name, markCfgData.Desc, markCfgData.Icon}
  235. end
  236. end
  237. end
  238. end
  239. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRoleInfoPop, self.markShowDatas)
  240. end
  241. function UISkillSettingsView:OnClickLearnBtn()
  242. if self.isEquiping then return end
  243. local curSkillId = self.controller:GetSelectSkillId()
  244. local errorCode, itemCfgId = self.controller:GetActiveSkillErrorCode(curSkillId)
  245. if errorCode == 0 then
  246. self.controller:SendActiveSkill(curSkillId)
  247. else
  248. if errorCode == 139 then
  249. CommonUtil.ItemNotEnoughHandle(itemCfgId, self.uiData.id)
  250. elseif errorCode == 141 then
  251. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('LearnSkillCondition04')
  252. else
  253. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  254. end
  255. end
  256. end
  257. function UISkillSettingsView:OnClickShowChangeSkillExp()
  258. local count = CommonUtil.GetOwnResCountByItemId(Enum.ItemType.SkillExp)
  259. local maxExchangeCount
  260. local isSetColor
  261. local radio = GlobalConfig.Instance:GetConfigIntValue(320)
  262. if count < radio then
  263. isSetColor = true
  264. maxExchangeCount = 1
  265. else
  266. isSetColor = false
  267. maxExchangeCount = math.floor(count / radio)
  268. end
  269. --cfgid == Enum.ItemType.GaojiSkillExp
  270. local data = {cfgId = Enum.ItemType.AdvanceSkillExp,targetCfgId = Enum.ItemType.SkillExp, radio = radio , count = count,isSetColor = isSetColor, maxExchangeCount = maxExchangeCount, owner = self, ownerCB = self.OnCliclExchangeSkillExpBtn, isExchangeItem = true}
  271. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UITipsExchange, data)
  272. end
  273. function UISkillSettingsView:OnCliclExchangeSkillExpBtn(idx,num)
  274. --发送兑换技能经验消息
  275. local count = CommonUtil.GetOwnResCountByItemId(Enum.ItemType.SkillExp)
  276. local radio = GlobalConfig.Instance:GetConfigIntValue(320)
  277. local isCanExchange = count < radio
  278. if not isCanExchange then
  279. ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_CONVER_SKILL_EXP_REQ,{cnt = num})
  280. else
  281. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('SuperSkillExpNotEnough')
  282. end
  283. end
  284. function UISkillSettingsView:OnClickAdvanceAttrBtn()
  285. local skilldata = {}
  286. local attrs = {}
  287. ManagerContainer.DataMgr.UserData:GetSkillData(self.controller:GetHeroId()):GetAvanceSkillAttrs(attrs,skilldata)
  288. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISkillAdvanceTotal,{skilldata,attrs})
  289. end
  290. function UISkillSettingsView:OnAdvanceConfirm()
  291. local data = {}
  292. local skillId = self.controller:GetSelectSkillId()
  293. local skillTreeCfg = self.controller:GetSkillTreeCfgData(skillId)
  294. if skillTreeCfg and skillTreeCfg.SuperSkill and #skillTreeCfg.SuperSkill > 0 then
  295. local selectHeroId = self.controller:GetHeroId()
  296. local nextskillTreeCfg
  297. local herodata = ManagerContainer.DataMgr.UserData:GetHeroData(selectHeroId)
  298. local jobdata = ManagerContainer.CfgMgr:GetJobDataById(herodata.configId)
  299. for i = 1, #skillTreeCfg.SuperSkill do
  300. if skillTreeCfg.SuperSkill[i][1] == jobdata.JobBranch then
  301. nextskillTreeCfg = self.controller:GetSkillTreeCfgData(skillTreeCfg.SuperSkill[i][2])
  302. break
  303. end
  304. end
  305. data[1] = {id = skillId, lv = skillTreeCfg.MaxLv }
  306. data[2] = {id = nextskillTreeCfg.SkillId, lv = 1 }
  307. data[3] = self.controller:GetHeroId()
  308. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISkillAdvance,data)
  309. else
  310. LogError('[Wboy] SkillTreeCfg Data is Error. skillId : ' .. tostring(skillId) )
  311. end
  312. end
  313. function UISkillSettingsView:OnClickAvanceBtn()
  314. if self.isEquiping then return end
  315. local curSkillId = self.controller:GetSelectSkillId()
  316. local errorCode, itemCfgId = CommonUtil.CheckSkillCanAvance(self.controller:GetHeroId(),curSkillId)
  317. if errorCode == 0 then
  318. self:OnAdvanceConfirm()
  319. else
  320. if errorCode == 139 then
  321. CommonUtil.ItemNotEnoughHandle(itemCfgId, self.uiData.id)
  322. elseif errorCode == 200 then
  323. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('NeedAdvanceJobTips')
  324. elseif errorCode == 141 then
  325. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('LearnSkillCondition04')
  326. else
  327. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  328. end
  329. end
  330. end
  331. function UISkillSettingsView:OnClickUpgradeBtn()
  332. if self.isEquiping then return end
  333. if self.isSendUpgradeLv then return end
  334. local curSkillId = self.controller:GetSelectSkillId()
  335. local errorCode, itemCfgId = self.controller:GetUpgradeSkillErrorCode(curSkillId)
  336. if errorCode == 0 then
  337. self.isSendUpgradeLv = true
  338. self.controller:SendUpgradeSkill(curSkillId)
  339. else
  340. if errorCode == 139 then
  341. CommonUtil.ItemNotEnoughHandle(itemCfgId, self.uiData.id)
  342. elseif errorCode == 141 then
  343. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('LearnSkillCondition06')
  344. else
  345. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  346. end
  347. end
  348. end
  349. function UISkillSettingsView:OnClickEquipBtn()
  350. if self.isEquiping then return end
  351. if self.controller:GetUnlockSlotNum() <= 0 then
  352. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay('DscSkillSet3')
  353. return
  354. end
  355. self.isEquiping = true
  356. self:RefreshReplaceBtn()
  357. end
  358. function UISkillSettingsView:OnClickCancelReplaceBtn()
  359. if not self.isEquiping then return end
  360. self.isEquiping = false
  361. self:RefreshReplaceBtn()
  362. end
  363. function UISkillSettingsView:OnClickSlotSkillBtn(btn, params)
  364. if self.isEquiping then return end
  365. local slotIdx = params[0]
  366. local skillId = self.controller:GetSkillIdBySlotIdx(slotIdx)
  367. local isChanged = self.controller:SetSelectSkillId(skillId)
  368. if isChanged then
  369. if self.curSelectSkillItem then
  370. self.curSelectSkillItem.selectSign:SetActive(false)
  371. end
  372. self:RefreshSelectSkillInfo()
  373. end
  374. self:RefreshTreeView(true, true)
  375. end
  376. function UISkillSettingsView:OnClickReplaceBtn(btn, params)
  377. if not self.isEquiping then return end
  378. local curSkillId = self.controller:GetSelectSkillId()
  379. local slotIdx = params[0]
  380. self.controller:SendChangeSkill(curSkillId, slotIdx)
  381. end
  382. function UISkillSettingsView:OnClickBackBtn()
  383. if self.isEquiping then return end
  384. self:UIClose()
  385. if self.uiBase.MSourceUIID > 0 then
  386. ManagerContainer.LuaUIMgr:Open(self.uiBase.MSourceUIID, self.controller:GetHeroId())
  387. end
  388. end
  389. function UISkillSettingsView:ShowUpLevelFx()
  390. self:HideUpLevelFx()
  391. self.skillLvUP:SetActive(true)
  392. self.fx_ui_skillsettings_skillup.uIParticle:PlayCachedParticalSystem(true)
  393. if not self.upLevelFxTimer then
  394. self.upLevelFxTimer = Timer.New(function()
  395. self:HideUpLevelFx()
  396. end, 5)
  397. self.upLevelFxTimer:Start()
  398. else
  399. self.upLevelFxTimer.time = self.upLevelFxTimer.duration
  400. end
  401. end
  402. function UISkillSettingsView:HideUpLevelFx()
  403. self.skillLvUP:SetActive(false)
  404. self.fx_ui_skillsettings_skillup.uIParticle:PlayCachedParticalSystem(false)
  405. end
  406. function UISkillSettingsView:InitResourceBox()
  407. local itemCfgId = Enum.ItemType.Coin
  408. local count = CommonUtil.GetOwnResCountByItemId(itemCfgId)
  409. self.currency1.number.text.text = CommonUtil.FormatNumber(count)
  410. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(itemCfgId)
  411. CommonUtil.LoadIcon(self, itemCfgData.MiniIcon, function (sprite)
  412. self.currency1.icon.image.sprite = sprite
  413. end)
  414. itemCfgId = Enum.ItemType.SkillExp
  415. count = CommonUtil.GetOwnResCountByItemId(itemCfgId)
  416. self.currency2.number.text.text = CommonUtil.FormatNumber(count)
  417. itemCfgData = ManagerContainer.CfgMgr:GetItemById(itemCfgId)
  418. CommonUtil.LoadIcon(self, itemCfgData.MiniIcon, function (sprite)
  419. self.currency2.icon.image.sprite = sprite
  420. end)
  421. local herodata = ManagerContainer.DataMgr.UserData:GetHeroData(self.controller:GetHeroId())
  422. local jobdata = ManagerContainer.CfgMgr:GetJobDataById(herodata.configId)
  423. self.currency3:SetActive(jobdata and jobdata.JobStage >= 3)
  424. itemCfgId = Enum.ItemType.AdvanceSkillExp
  425. count = CommonUtil.GetOwnResCountByItemId(itemCfgId)
  426. self.currency3.number.text.text = CommonUtil.FormatNumber(count)
  427. itemCfgData = ManagerContainer.CfgMgr:GetItemById(itemCfgId)
  428. CommonUtil.LoadIcon(self, itemCfgData.MiniIcon, function (sprite)
  429. self.currency3.icon.image.sprite = sprite
  430. end)
  431. end
  432. function UISkillSettingsView:RefreshHero()
  433. self:RefreshRoleTop()
  434. self.curSelectSkillItem = nil
  435. self:RefreshTreeView()
  436. self:RefreshSelectSkillInfo()
  437. self:RefreshSlotSkill(true)
  438. self:RefreshReplaceBtn()
  439. self:RefreshResetSkillLvBtn()
  440. --未进阶二转角色隐藏 高级技能经验
  441. local herodata = ManagerContainer.DataMgr.UserData:GetHeroData(self.controller:GetHeroId())
  442. local jobdata = ManagerContainer.CfgMgr:GetJobDataById(herodata.configId)
  443. self.currency3:SetActive(jobdata and jobdata.JobStage >= 3)
  444. end
  445. function UISkillSettingsView:RefreshRoleTop()
  446. local id = self.controller:GetHeroId()
  447. local cfgData = CommonUtil.GetHeroCfgDataByUid(id)
  448. CommonUtil.LoadIcon(self, cfgData.BattleCartoonImg, function (sprite)
  449. self.roleImg.role.image.sprite = sprite
  450. end)
  451. local heroData = self.controller:GetHeroData()
  452. local jobName, roleName = CommonUtil.GetHeroSplitJobAndNameByUid(id, heroData.configId)
  453. self.roleImg.textBox.uILocalizeScript:SetContentAndValues("DscRoleTalk1", {jobName, roleName})
  454. end
  455. function UISkillSettingsView:RefreshSwitchHero()
  456. local num = self.controller:GetHeroVaildNum()
  457. if num > 1 then
  458. self.btnLeft:SetActive(true)
  459. self.btnRight:SetActive(true)
  460. else
  461. self.btnLeft:SetActive(false)
  462. self.btnRight:SetActive(false)
  463. end
  464. end
  465. --------------------------------- 技能列表 Start ----------------------------------
  466. function UISkillSettingsView:GetSkillTreeItemByRowColumn(gridView, itemIndex, row, column)
  467. local item = gridView:NewListViewItem('SkillSmallItem')
  468. local itemlua = CommonUtil.BindGridViewItem2Lua(self, 'SkillSmallItem', item.gameObject)
  469. if itemlua then
  470. local skillData = self.controller:GetSkillItemInfoByIndex(itemIndex)
  471. if skillData then
  472. local curSkillId = self.controller:GetSelectSkillId()
  473. if self.forceGuideSkillId ~= nil and self.forceGuideSkillId == skillData.SkillId then
  474. self.forceGuideTarget = item.gameObject
  475. end
  476. itemlua.selectSign:SetActive(skillData.SkillId == curSkillId)
  477. if skillData.SkillId == curSkillId then
  478. self.curSelectSkillItem = itemlua
  479. end
  480. local skillId = skillData.SkillId
  481. local skillType = skillData.SkillType
  482. local isUnlock = self.controller:GetIsUnlock(skillId)
  483. local skillLv
  484. if isUnlock then
  485. skillLv = self.controller:GetSkilllv(skillId)
  486. else
  487. skillLv = 1
  488. end
  489. itemlua.lock:SetActive(not isUnlock and not self.controller:GetIsCanUnlock(skillId))
  490. local skillCfgData = ManagerContainer.CfgMgr:GetSkillCfgByType(skillType, skillId, skillLv)
  491. itemlua.skillItem.icon.image.sprite = nil
  492. if skillCfgData then
  493. if skillCfgData.Icon then
  494. CommonUtil.LoadIcon(self, skillCfgData.Icon, function (sprite)
  495. itemlua.skillItem.icon.image.sprite = sprite
  496. end, itemlua, "SkillIconAsyncIdx")
  497. end
  498. itemlua.skillItem.num.text.text = isUnlock and (I18N.SetLanguageValue('Lv') .. tostring(skillLv)) or ''
  499. itemlua.skillName.text.text = I18N.SetLanguageValue(skillCfgData.Name)
  500. local skillShowData = ManagerContainer.CfgMgr:GetSkillShowCfgById(skillId)
  501. local tags = nil
  502. local num = 0
  503. if skillShowData then
  504. tags = skillShowData.Label
  505. if tags then
  506. if type(tags[1]) == 'number' then
  507. tags = {tags}
  508. end
  509. num = #tags
  510. end
  511. end
  512. for i = 1, 4 do
  513. local skillTagItem = itemlua['skillTagItem' .. i]
  514. if skillTagItem then
  515. if i <= num then
  516. local tagId = tags[i][1]
  517. local colorId = tags[i][2]
  518. skillTagItem:SetActive(true)
  519. skillTagItem.bgColorID.image.color = ColorExtension.HexStringToColor(I18N.SetLanguageValue('ColorID' .. tostring(colorId)))
  520. skillTagItem.textSkillID.uILocalizeScript:SetContent('SkillTagID' .. tostring(tagId))
  521. else
  522. skillTagItem:SetActive(false)
  523. end
  524. end
  525. end
  526. else
  527. itemlua.skillItem.icon.image.sprite = nil
  528. itemlua.skillItem.num.text.text = ''
  529. itemlua.skillName.text.text = ''
  530. itemlua.skillTagItem1:SetActive(false)
  531. itemlua.skillTagItem2:SetActive(false)
  532. itemlua.skillTagItem3:SetActive(false)
  533. itemlua.skillTagItem4:SetActive(false)
  534. LogError('[Wboy] Skill Cfg Data is Error. skillType :' .. tostring(skillType) .. ' skillId : ' .. tostring(skillId) .. ' skillLv : ' .. tostring(skillLv))
  535. end
  536. itemlua.skillItem.icon.button.enabled = false
  537. local isEquip = self.controller:GetSkillIsAtSlot(skillId)
  538. itemlua.equipSign:SetActive(isEquip)
  539. local selectHeroId = self.controller:GetHeroId()
  540. local rpStatus = ManagerContainer.RedPointMgr.HeroRPCtr:GetSkillUnlockRPStatus(selectHeroId, skillId)
  541. local herodata = ManagerContainer.DataMgr.UserData:GetHeroData(selectHeroId)
  542. local jobdata = ManagerContainer.CfgMgr:GetJobDataById(herodata.configId)
  543. local curskillLv = self.controller:GetSkilllv(skillData.SkillId)
  544. local isCanAvance = false
  545. local nextSkilldata
  546. if skillData.SuperSkill then
  547. nextSkilldata = self.controller:GetSkillTreeCfgData(skillData.SuperSkill[1][2])
  548. end
  549. --神器标记
  550. local artifactSkillState, idx = self.controller:GetSkillInSkillEquipDataState(skillId)
  551. itemlua.redPoint:SetActive(rpStatus ~= Enum.RedPointEnum.None and artifactSkillState == 0)
  552. itemlua.artifactStatus:SetActive(artifactSkillState > 0)
  553. itemlua.artifactStatus.activated:SetActive(artifactSkillState == 2)
  554. itemlua.artifactStatus.button.interactable = artifactSkillState > 0
  555. if artifactSkillState > 0 then
  556. CommonUtil.LoadIcon(self, self.controller:GetSkillEquipIcon(), function (sprite)
  557. itemlua.artifactStatus.icon.image.sprite = sprite
  558. end, itemlua, "ArtifactIcon")
  559. CommonUtil.NeedUIGray(itemlua.artifactStatus.icon.image, artifactSkillState == 1)
  560. self.uiBase:AddButtonUniqueEventListener(itemlua.artifactStatus.button, self, self.OnSkillEquipSignClick, artifactSkillState, idx)
  561. end
  562. if nextSkilldata and nextSkilldata.OpenNeedCost then
  563. local openNeedCost = nextSkilldata.OpenNeedCost
  564. isCanAvance = self:IsCanLearnOrAvance(openNeedCost,self.btnSkillAdvance.costBox,true)
  565. if herodata.baseLevel > nextSkilldata.OpenLevel and skillData.SuperSkill and jobdata
  566. and jobdata.JobStage >= nextSkilldata.JobStage and curskillLv >= skillData.MaxLv
  567. and isCanAvance then
  568. itemlua.newRedPoint:SetActive(artifactSkillState == 0)
  569. local redPointParent = itemlua.newRedPoint.transform
  570. if redPointParent then
  571. if redPointParent.childCount == 0 then
  572. self:CreateNormalRedPoint(redPointParent)
  573. end
  574. end
  575. else
  576. itemlua.newRedPoint:SetActive(false)
  577. end
  578. else
  579. itemlua.newRedPoint:SetActive(false)
  580. end
  581. self.uiBase:AddButtonUniqueEventListener(itemlua.button, self, self.OnClickSkillItem, skillId, itemlua)
  582. local quality = skillData and skillData.SkillQuality or 0
  583. if quality ~= 0 then
  584. CommonUtil.LoadIcon(self, Constant.Quality_Frame_Icons[quality], function (sprite)
  585. itemlua.skillItem.frame.image.sprite = sprite
  586. end)
  587. else
  588. CommonUtil.LoadIcon(self, "FrameNew/frame_item_gray", function (sprite)
  589. itemlua.skillItem.frame.image.sprite = sprite
  590. end)
  591. end
  592. else
  593. LogError('[Wboy] Skill Data is Error. index :' .. tostring(itemIndex))
  594. end
  595. end
  596. return item
  597. end
  598. function UISkillSettingsView:RefreshTreeView(resetPos, isCenter)
  599. if resetPos == nil then resetPos = true end
  600. local loopGridView = self.skillList.loopGridView
  601. local skillList = self.controller:SetSkillList()
  602. local len = skillList and #skillList or 0
  603. if resetPos then
  604. local curSkillId = self.controller:GetSelectSkillId()
  605. local moveTo = 0
  606. for i = 1, len do
  607. local skillTreeData = skillList[i]
  608. local skillId = skillTreeData.SkillId
  609. if skillId == curSkillId then
  610. moveTo = i - 1
  611. break
  612. end
  613. end
  614. if isCenter then
  615. local scrollRect = loopGridView.ScrollRect
  616. local viewport = scrollRect.viewport
  617. local viewportH = viewport.rect.height
  618. loopGridView:RefreshListByIndex(len, moveTo, 0, -viewportH * 0.5)
  619. else
  620. loopGridView:RefreshListByIndex(len, moveTo)
  621. end
  622. else
  623. if loopGridView.ItemTotalCount == len then
  624. loopGridView:RefreshListByIndex(len)
  625. else
  626. loopGridView:RefreshListByIndex(len)
  627. end
  628. end
  629. self:RefreshArrowHead()
  630. end
  631. function UISkillSettingsView:FindSkillItemById(id, owner, ownerCB)
  632. self.forceGuideSkillId = id
  633. local skillList = self.controller:SetSkillList()
  634. local idx
  635. for k,v in pairs(skillList) do
  636. local skillId = v.SkillId
  637. if skillId == id then
  638. idx = k
  639. break
  640. end
  641. end
  642. if idx == nil then
  643. if owner and ownerCB then
  644. ownerCB(owner)
  645. return
  646. end
  647. end
  648. local loopGridView = self.skillList.loopGridView
  649. loopGridView:RefreshAllShownItem()
  650. loopGridView:MovePanelToItemByIndex(idx - 1)
  651. self.delayTimer = FrameTimer.New(function()
  652. if owner and ownerCB then
  653. ownerCB(owner, self.forceGuideTarget)
  654. end
  655. end, 5)
  656. self.delayTimer:Start()
  657. end
  658. function UISkillSettingsView:RefreshArrowHead(offset)
  659. local loopGridView = self.skillList.loopGridView
  660. local scrollRect = loopGridView.ScrollRect
  661. local viewport = scrollRect.viewport
  662. local content = scrollRect.content
  663. local viewportH = viewport.rect.height
  664. local contentH = content.rect.height
  665. local vaildH = contentH - viewportH
  666. if vaildH <= 0 then
  667. self.upArrow:SetActive(false)
  668. self.bottomArrow:SetActive(false)
  669. return
  670. end
  671. vaildH = 1 / vaildH
  672. local padding = loopGridView.Padding
  673. local minH = (padding.top + 20) * vaildH
  674. local maxH = 1 - (padding.bottom + 20) * vaildH
  675. local offsetY
  676. if offset then
  677. offsetY = offset.y
  678. else
  679. offsetY = scrollRect.verticalNormalizedPosition
  680. end
  681. self.upArrow:SetActive((offsetY <= maxH))
  682. self.bottomArrow:SetActive((offsetY >= minH))
  683. end
  684. function UISkillSettingsView:RefreshSelectSkillInfo()
  685. self.isSendUpgradeLv = false
  686. local curSkillId = self.controller:GetSelectSkillId()
  687. local curSkillLv = self.controller:GetSkilllv(curSkillId)
  688. local curSkillMaxLv = self.controller:GetSkillMaxLv(curSkillId)
  689. local skillTreeCfgData = self.controller:GetSkillTreeCfgData(curSkillId)
  690. self.btnSkillAdvanceInfo:SetActive(skillTreeCfgData and skillTreeCfgData.SkillQuality > 0)
  691. if skillTreeCfgData and skillTreeCfgData.SkillQuality > 0 then
  692. self.btnSkillAdvanceInfo.text.text.text = string.formatbykey("Advance",skillTreeCfgData.SkillQuality - 2)
  693. end
  694. -- 当前
  695. local isUnlock = self.controller:GetIsUnlock(curSkillId)
  696. self.currentBox.title:SetActive(isUnlock)
  697. self.currentBox.desText:SetActive(isUnlock)
  698. self.currentBox.none:SetActive(not isUnlock)
  699. if isUnlock then
  700. self.currentBox.title.text.text.text = tostring(curSkillLv)
  701. self:RefreshSkillDes(self.currentBox, curSkillId, curSkillLv)
  702. else
  703. self.currentBox.title.text.text.text = '--'
  704. end
  705. -- 下一级
  706. local nextSkillLv = curSkillLv + 1
  707. local hasNextLv = (nextSkillLv <= curSkillMaxLv)
  708. self.nextBox.title:SetActive(hasNextLv)
  709. self.nextBox.desText:SetActive(hasNextLv)
  710. self.nextBox.max:SetActive(not hasNextLv)
  711. if hasNextLv then
  712. self.nextBox.title.text.text.text = tostring(nextSkillLv)
  713. self:RefreshSkillDes(self.nextBox, curSkillId, nextSkillLv, true)
  714. else
  715. self.nextBox.title.text.text.text = I18N.SetLanguageValue('Max')
  716. end
  717. self:RefreshSkillLvAttrs(curSkillMaxLv, curSkillId, curSkillLv)
  718. self:RefreshSkillBtnContainer()
  719. end
  720. function UISkillSettingsView:RefreshSkillDes(detailBox, skillId, skillLv, isNext)
  721. local skillCfgId = CommonUtil.GetSkillCfgIdByIdAndLv(skillId, skillLv)
  722. local skillCfgData = ManagerContainer.CfgMgr:GetSkillLevelCfgById(skillCfgId)
  723. if skillCfgData then
  724. local descParam = skillCfgData.DescParam
  725. if descParam then
  726. if type(descParam) == 'table' then
  727. if isNext then
  728. local ls = {}
  729. local colorStr = '<color=' .. string.formatbykey('ColorID8') .. '>'
  730. for i = 1, #descParam do
  731. ls[i] = colorStr .. tostring(descParam[i]) .. '</color>'
  732. end
  733. descParam = ls
  734. end
  735. detailBox.desText.text.text = string.formatbykey(skillCfgData.Desc, unpack(descParam))
  736. else
  737. if isNext then
  738. detailBox.desText.text.text = string.formatbykey(skillCfgData.Desc, '<color=' .. I18N.formatbykey('ColorID8') .. '>' .. tostring(descParam) .. '</color>')
  739. else
  740. detailBox.desText.text.text = string.formatbykey(skillCfgData.Desc, descParam)
  741. end
  742. end
  743. else
  744. detailBox.desText.text.text = string.formatbykey(skillCfgData.Desc)
  745. end
  746. else
  747. detailBox.desText.text.text = ''
  748. end
  749. end
  750. function UISkillSettingsView:RefreshSkillLvAttrs(curSkillMaxLv, curSkillId, curSkillLv)
  751. -- 获得这个技能所有能获得的属性列表
  752. local attrs = {}
  753. for i = 1, curSkillMaxLv do
  754. local cfgId = CommonUtil.GetSkillUpEffectCfgIdByIdAndLv(curSkillId, i)
  755. local cfgData = ManagerContainer.CfgMgr:GetSkillUpEffectCfgById(cfgId)
  756. if cfgData then
  757. local addAttributes = CommonUtil.DeserializeCfgItemList(cfgData.AddAttributes)
  758. if #addAttributes > 0 then
  759. table.insert(attrs, {lv = i, attr = addAttributes[1]})
  760. end
  761. end
  762. end
  763. for i = 1, 5 do
  764. local itemlua = self.lvAttrBox['skillLvAttrItem' .. i]
  765. if itemlua then
  766. local attr = attrs[i]
  767. if attr then
  768. itemlua:SetActive(true)
  769. local lvContent = (I18N.SetLanguageValue('LV') .. tostring(attr.lv))
  770. local attrId = attr.attr[1]
  771. local attrValue = attr.attr[2]
  772. local attrContent = (I18N.SetLanguageValue('KeySkillUpEffectCfg', CommonUtil.HeroAttrFormatValueNoSign(attrId, attrValue), I18N.SetLanguageValue(CommonUtil.HeroAttrFormatName(attrId, attrValue))))
  773. if curSkillLv >= attr.lv then
  774. lvContent = string.format(Constant.GreenColorText, lvContent)
  775. attrContent = string.format(Constant.GreenColorText, attrContent)
  776. end
  777. itemlua.lvText.text.text = lvContent
  778. itemlua.attrText.text.text = attrContent
  779. else
  780. itemlua:SetActive(false)
  781. end
  782. end
  783. end
  784. end
  785. function UISkillSettingsView:RefreshSkillBtnContainer()
  786. local curSkillId = self.controller:GetSelectSkillId()
  787. local curSkillLv = self.controller:GetSkilllv(curSkillId)
  788. local isUnlock = self.controller:GetIsUnlock(curSkillId)
  789. local curSkillMaxLv = self.controller:GetSkillMaxLv(curSkillId)
  790. if isUnlock then
  791. local isEquip = self.controller:GetSkillIsAtSlot(curSkillId)
  792. self.btnEquip:SetActive(not isEquip)
  793. self.labelEquipped:SetActive(isEquip)
  794. else
  795. self.btnEquip:SetActive(false)
  796. self.labelEquipped:SetActive(false)
  797. end
  798. if not isUnlock then
  799. self.btnLearn:SetActive(true)
  800. self.btnUpgrade:SetActive(false)
  801. self.btnSkillAdvance:SetActive(false)
  802. local skillTreeCfgData = self.controller:GetSkillTreeCfgData(curSkillId)
  803. if skillTreeCfgData then
  804. -- 检查条件是否能学习
  805. local openLevel = skillTreeCfgData.OpenLevel
  806. if openLevel and openLevel > 0 then
  807. if not self:RefreshLockInfo(self.btnLearn.lockBox, openLevel) then
  808. self.btnLearn.lockBox:SetActive(true)
  809. self.btnLearn.costBox:SetActive(false)
  810. -- self.btnLearn.button.interactable = false
  811. return
  812. end
  813. end
  814. self.btnLearn.lockBox:SetActive(false)
  815. local openNeedCost = skillTreeCfgData.OpenNeedCost
  816. if openNeedCost then
  817. self:IsCanLearnOrAvance(openNeedCost,self.btnLearn.costBox)
  818. else
  819. self.btnLearn.costBox:SetActive(false)
  820. end
  821. -- self.btnLearn.button.interactable = canLearn
  822. -- else
  823. -- self.btnLearn.button.interactable = false
  824. end
  825. elseif curSkillLv < curSkillMaxLv then
  826. self.btnLearn:SetActive(false)
  827. self.btnSkillAdvance:SetActive(false)
  828. self.btnUpgrade:SetActive(true)
  829. local skillTreeCfgData = self.controller:GetSkillTreeCfgData(curSkillId)
  830. if skillTreeCfgData then
  831. -- 检查条件是否能升级
  832. local upgradeLevel = ManagerContainer.CfgMgr:GetSkillDemandCfgUpGradeLevelById(skillTreeCfgData.OpenLevel) --skillTreeCfgData.UpGradeLevel
  833. if upgradeLevel and upgradeLevel[curSkillLv] then
  834. if not self:RefreshLockInfo(self.btnUpgrade.lockBox, upgradeLevel[curSkillLv]) then
  835. self.btnUpgrade.redPointRoot:SetActive(false)
  836. self.btnUpgrade.lockBox:SetActive(true)
  837. self.btnUpgrade.costBox:SetActive(false)
  838. -- self.btnUpgrade.button.interactable = false
  839. return
  840. end
  841. else
  842. self.btnUpgrade.redPointRoot:SetActive(false)
  843. self.btnUpgrade.lockBox:SetActive(false)
  844. self.btnUpgrade.costBox:SetActive(false)
  845. -- self.btnUpgrade.button.interactable = false
  846. LogError('[Wboy] UpGradeLevel Cfg is Error. skillId : ' .. tostring(curSkillId) .. ' skillLv : ' .. tostring(curSkillLv))
  847. return
  848. end
  849. self.btnUpgrade.lockBox:SetActive(false)
  850. local canUpgrade = true
  851. local upgradeCost = ManagerContainer.CfgMgr:GetSkillDemandCfgUpGradeCostById(skillTreeCfgData.OpenLevel) --skillTreeCfgData.UpGradeCost
  852. if upgradeCost and upgradeCost[curSkillLv] or #(upgradeCost[curSkillLv]) < 2 then
  853. self.btnUpgrade.costBox:SetActive(true)
  854. local itemCfgId = upgradeCost[curSkillLv][1]
  855. local itemNum = upgradeCost[curSkillLv][2]
  856. if not self:RefreshCostInfo(self.btnUpgrade.costBox, itemCfgId, itemNum) then
  857. canUpgrade = false
  858. end
  859. else
  860. self.btnUpgrade.costBox:SetActive(false)
  861. canUpgrade = false
  862. LogError('[Wboy] UpGradeCost Cfg is Error. skillId : ' .. tostring(curSkillId) .. ' skillLv : ' .. tostring(curSkillLv))
  863. end
  864. -- self.btnUpgrade.button.interactable = canUpgrade
  865. if canUpgrade then
  866. self.btnUpgrade.redPointRoot:SetActive(true)
  867. local redPointParent = self.btnUpgrade.redPointRoot.transform
  868. if redPointParent then
  869. if redPointParent.childCount == 0 then
  870. self:CreateNormalRedPoint(redPointParent)
  871. end
  872. end
  873. else
  874. self.btnUpgrade.redPointRoot:SetActive(false)
  875. end
  876. -- else
  877. -- self.btnUpgrade.button.interactable = false
  878. end
  879. elseif curSkillLv == curSkillMaxLv then
  880. local curSkilldata = self.controller:GetSkillTreeCfgData(curSkillId)
  881. if not curSkilldata then
  882. return
  883. end
  884. if curSkilldata.SuperSkill then
  885. self.btnLearn:SetActive(false)
  886. self.btnUpgrade:SetActive(false)
  887. self.btnSkillAdvance:SetActive(true)
  888. else
  889. self.btnSkillAdvance:SetActive(false)
  890. self.btnLearn:SetActive(false)
  891. self.btnUpgrade:SetActive(false)
  892. return
  893. end
  894. --self.btnJinjie:SetActive(true)
  895. local heroid = self.controller:GetHeroId()
  896. local herodata = ManagerContainer.DataMgr.UserData:GetHeroData(heroid)
  897. local jobdata = ManagerContainer.CfgMgr:GetJobDataById(herodata.configId)
  898. local nextSkilldata
  899. if curSkilldata.SuperSkill then
  900. nextSkilldata = self.controller:GetSkillTreeCfgData(curSkilldata.SuperSkill[1][2])
  901. end
  902. if jobdata and nextSkilldata and jobdata.JobStage < nextSkilldata.JobStage then
  903. self.btnSkillAdvance.redPointRoot:SetActive(false)
  904. self.btnSkillAdvance.lockBox:SetActive(true)
  905. self.btnSkillAdvance.costBox:SetActive(false)
  906. self.btnSkillAdvance.lockBox.text.text.text = I18N.SetLanguageValue('NeedAdvanceJob')
  907. return
  908. --需要进阶二转
  909. end
  910. local nextSkilldata
  911. if curSkilldata.SuperSkill then
  912. nextSkilldata = self.controller:GetSkillTreeCfgData(curSkilldata.SuperSkill[1][2])
  913. end
  914. if nextSkilldata and nextSkilldata.OpenLevel and ManagerContainer.DataMgr.UserData:GetHeroLv(heroid) < nextSkilldata.OpenLevel then
  915. self.btnSkillAdvance.redPointRoot:SetActive(false)
  916. self.btnSkillAdvance.lockBox:SetActive(true)
  917. self.btnSkillAdvance.costBox:SetActive(false)
  918. self:RefreshLockInfo(self.btnSkillAdvance.lockBox, nextSkilldata.OpenLevel)
  919. return
  920. --角色等级不足
  921. end
  922. if nextSkilldata.OpenNeedCost then
  923. local openNeedCost = nextSkilldata.OpenNeedCost
  924. local canLearn = self:IsCanLearnOrAvance(openNeedCost,self.btnSkillAdvance.costBox)
  925. if canLearn then
  926. --可进阶
  927. self.btnSkillAdvance.redPointRoot:SetActive(true)
  928. local redPointParent = self.btnSkillAdvance.redPointRoot.transform
  929. if redPointParent then
  930. if redPointParent.childCount == 0 then
  931. self:CreateNormalRedPoint(redPointParent)
  932. end
  933. end
  934. else
  935. self.btnSkillAdvance.redPointRoot:SetActive(false)
  936. end
  937. else
  938. self.btnSkillAdvance.costBox:SetActive(false)
  939. end
  940. self.btnSkillAdvance.lockBox:SetActive(false)
  941. else
  942. self.btnSkillAdvance:SetActive(false)
  943. self.btnLearn:SetActive(false)
  944. self.btnUpgrade:SetActive(false)
  945. end
  946. end
  947. --判断是否能进阶技能或学习技能
  948. function UISkillSettingsView:IsCanLearnOrAvance(openNeedCost,CostBox,isReset)
  949. --CostBox:SetActive(true)
  950. local canLearn = true
  951. local openNeedCosts = nil
  952. if type(openNeedCost[1]) == 'number' then
  953. if #openNeedCost > 1 then
  954. openNeedCosts = {openNeedCost}
  955. end
  956. else
  957. openNeedCosts = openNeedCost
  958. end
  959. for i = 1, #openNeedCosts do
  960. local itemCfgId = openNeedCosts[i][1]
  961. local itemNum = openNeedCosts[i][2]
  962. if i == 1 then
  963. if not self:RefreshCostInfo(CostBox, itemCfgId, itemNum, isReset) then
  964. canLearn = false
  965. break
  966. end
  967. else
  968. local ownNum = self.controller:GetOwnResCountByItemId(itemCfgId)
  969. if ownNum < itemNum then
  970. canLearn = false
  971. break
  972. end
  973. end
  974. end
  975. return canLearn
  976. end
  977. function UISkillSettingsView:CreateNormalRedPoint(parent)
  978. local redPoint = ManagerContainer.ResMgr:GetGoFromPool(Constants.UICommonPath, 'UIRedPointRP')
  979. if redPoint then
  980. redPoint.transform:SetParent(parent)
  981. redPoint.transform.localPosition = Vector3.zero
  982. redPoint.transform.localRotation = Quaternion.identity
  983. redPoint.transform.localScale = Vector3.one
  984. redPoint:SetActive(true)
  985. end
  986. end
  987. function UISkillSettingsView:RefreshLockInfo(lockBox, upgradeLv)
  988. local canUpgrade
  989. if (self.controller:GetHeroLv() < upgradeLv) then
  990. lockBox:SetActive(true)
  991. lockBox.text.text.text = I18N.SetLanguageValue('LvLock', upgradeLv)
  992. canUpgrade = false
  993. else
  994. lockBox:SetActive(false)
  995. canUpgrade = true
  996. end
  997. return canUpgrade
  998. end
  999. function UISkillSettingsView:RefreshCostInfo(costBox, itemCfgId, costNum, isReset)
  1000. local canCost = false
  1001. if not isReset then
  1002. costBox:SetActive(true)
  1003. costBox.ic.image.sprite = nil
  1004. end
  1005. local ownNum = self.controller:GetOwnResCountByItemId(itemCfgId)
  1006. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(itemCfgId)
  1007. if itemCfgData and not isReset then
  1008. CommonUtil.LoadIcon(self, itemCfgData.MiniIcon, function (sprite)
  1009. costBox.ic.image.sprite = sprite
  1010. end, self, "CostItemIconAsyncIdx")
  1011. end
  1012. local content
  1013. if costNum then
  1014. if not itemCfgData or itemCfgData.ResType == Enum.ItemType.Coin or itemCfgData.ResType == Enum.ItemType.SkillExp or itemCfgData.ResType == Enum.ItemType.AdvanceSkillExp then
  1015. content = tostring(costNum)
  1016. else
  1017. content = (tostring(ownNum) .. '/' .. tostring(costNum))
  1018. end
  1019. if ownNum < costNum then
  1020. content = string.format(Constant.PinkColorText, content)
  1021. else
  1022. canCost = true
  1023. end
  1024. else
  1025. content = '--'
  1026. end
  1027. if not isReset then
  1028. costBox.text.text.text = content
  1029. end
  1030. return canCost
  1031. end
  1032. --------------------------------- 技能列表 End ----------------------------------
  1033. ---------------------------------- 技能槽 Start -----------------------------------
  1034. function UISkillSettingsView:RefreshSlotSkill(isResetIdx)
  1035. local slotNum = self.controller:GetSlotNum()
  1036. for i = 1, slotNum do
  1037. local slotIdx = self.controller:GeSlotIdxById(i)
  1038. local skillItem = self['skillItem' .. slotIdx]
  1039. if skillItem then
  1040. if isResetIdx then
  1041. skillItem.transform:SetSiblingIndex(slotIdx - 1)
  1042. end
  1043. self:RefreshSlotSkillItem(skillItem, self.controller:GetSkillIdBySlotIdx(slotIdx), i)
  1044. end
  1045. end
  1046. local num = self.controller:GetSlotVaildSkillNum()
  1047. self.dragContainer.reorderableList.IsDraggable = (num >= 1)
  1048. end
  1049. function UISkillSettingsView:OnDragSlotSkillList(reorderableListEventStruct)
  1050. local droppedObject = reorderableListEventStruct.DroppedObject
  1051. local index = reorderableListEventStruct.ToIndex + 1
  1052. local slotIdxs = {}
  1053. -- 槽位上技能发生变化,需要更改技能描述等
  1054. local slotNum = self.controller:GetSlotNum()
  1055. for i = 1, slotNum do
  1056. local skillItem = self['skillItem' .. i]
  1057. if skillItem then
  1058. if skillItem.gameObject == droppedObject then
  1059. slotIdxs[index] = i
  1060. else
  1061. local sibilingIndex = skillItem.transform:GetSiblingIndex() + 1
  1062. slotIdxs[sibilingIndex] = i
  1063. end
  1064. end
  1065. end
  1066. self.controller:UpdateSlotIdxs(slotIdxs)
  1067. end
  1068. function UISkillSettingsView:OnEngDragSkillList()
  1069. self.controller:SendSlotSkillChange()
  1070. end
  1071. function UISkillSettingsView:RefreshSlotSkillItem(skillItem, skillId, slotId)
  1072. local slotRoot = self.slotRoot['slot' .. slotId]
  1073. local isUnlock = self.controller:GetSlotIsUnlock(slotId)
  1074. if not isUnlock or not skillId or skillId <= 0 then
  1075. skillItem:SetActive(false)
  1076. local unlock, languageKey, content = self:CheckSlotUnlock(slotId, 1)
  1077. if languageKey then
  1078. if content then
  1079. slotRoot.locked.textLocked.uILocalizeScript:SetContentAndValues(languageKey, content)
  1080. else
  1081. slotRoot.locked.textLocked.uILocalizeScript:SetContent(languageKey)
  1082. end
  1083. end
  1084. slotRoot.locked:SetActive(not unlock)
  1085. slotRoot.noSkill:SetActive(unlock)
  1086. return
  1087. end
  1088. skillItem:SetActive(true)
  1089. slotRoot.locked:SetActive(false)
  1090. slotRoot.noSkill:SetActive(false)
  1091. local skillLv = self.controller:GetSkilllv(skillId)
  1092. if skillLv == 0 then
  1093. skillLv = 1
  1094. end
  1095. local skillCfgId = CommonUtil.GetSkillCfgIdByIdAndLv(skillId, skillLv)
  1096. local skillCfgData = ManagerContainer.CfgMgr:GetSkillCfgById(skillId)
  1097. local skillTreeCfgData = self.controller:GetSkillTreeCfgData(skillId)
  1098. local quality = skillTreeCfgData and skillTreeCfgData.SkillQuality or 0
  1099. if skillCfgData then
  1100. CommonUtil.LoadIcon(self, skillCfgData.Icon, function (sprite)
  1101. skillItem.icon.image.sprite = sprite
  1102. end, skillItem, "IconAsyncIdx")
  1103. skillItem.num.text.text = (I18N.SetLanguageValue('Lv') .. tostring(skillLv))
  1104. else
  1105. skillItem.icon.image.sprite = nil
  1106. skillItem.num.text.text = ""
  1107. end
  1108. if quality ~= 0 then
  1109. CommonUtil.LoadIcon(self, Constant.Quality_Frame_Icons[quality], function (sprite)
  1110. skillItem.frame.image.sprite = sprite
  1111. end)
  1112. else
  1113. CommonUtil.LoadIcon(self, "FrameNew/frame_item_gray", function (sprite)
  1114. skillItem.frame.image.sprite = sprite
  1115. end)
  1116. end
  1117. end
  1118. function UISkillSettingsView:CheckSlotUnlock(slotId, slotLv)
  1119. local skillSlotCfgId = CommonUtil.GetSkillSlotCfgIdByIdxAndLv(slotId, slotLv)
  1120. local skillSlotCfgData = ManagerContainer.CfgMgr:GetSkillSlotCfgById(skillSlotCfgId)
  1121. if not skillSlotCfgData then
  1122. return false
  1123. end
  1124. local condition
  1125. if self.controller:IsLeaderHero() then
  1126. condition = skillSlotCfgData.Condition
  1127. else
  1128. condition = skillSlotCfgData.ParterCondition
  1129. end
  1130. if not condition then
  1131. return true
  1132. end
  1133. local levelData = self.controller:GetCurMapAndLevel()
  1134. if levelData and condition >= levelData.Id then
  1135. local condLevelData = ManagerContainer.CfgMgr:GetLevelDataById(condition)
  1136. return false, 'SkillSlotUnlock_LevelId', {(condLevelData and I18N.SetLanguageValue(condLevelData.Name) or '')}
  1137. end
  1138. return true
  1139. end
  1140. function UISkillSettingsView:RefreshReplaceBtn()
  1141. local show = self.isEquiping or false
  1142. self.mask:SetActive(show)
  1143. self.cancelReplace:SetActive(show)
  1144. local slotNum = self.controller:GetSlotNum()
  1145. for i = 1, slotNum do
  1146. local btnReplace = self.slotLabel['slot' .. i].btnReplace
  1147. if btnReplace then
  1148. if show then
  1149. local isUnlock = self.controller:GetSlotIsUnlock(i)
  1150. btnReplace:SetActive(isUnlock)
  1151. btnReplace.fx_ui_skillsettings_tihuan.uIParticle:PlayCachedParticalSystem(isUnlock)
  1152. else
  1153. btnReplace:SetActive(false)
  1154. end
  1155. end
  1156. end
  1157. end
  1158. ---------------------------------- 技能槽 End -----------------------------------
  1159. function UISkillSettingsView:RefreshResetSkillLvBtn()
  1160. local resetCount = ManagerContainer.DataMgr.UserData:GetSkillResetCount()
  1161. self.btnReset:SetActive(resetCount >= 0)
  1162. end
  1163. function UISkillSettingsView:SendResetSkillLv(type)
  1164. local itemCfgId, num = CommonUtil.GetResetSkillLvCost()
  1165. local ownNum = self.controller:GetOwnResCountByItemId(itemCfgId)
  1166. if ownNum < num then
  1167. CommonUtil.ItemNotEnoughHandle(itemCfgId, self.uiData.id)
  1168. return
  1169. end
  1170. local skillData = ManagerContainer.DataMgr.UserData:GetSkillData(self.controller:GetHeroId())
  1171. --判断是否有技能可重置 type 为类型 1为重置进阶技能 0或nil 重置所有技能
  1172. if skillData:IsCanResetSkill(type) then
  1173. self.controller:SendResetSkillLv(type)
  1174. else
  1175. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(143)
  1176. end
  1177. end
  1178. function UISkillSettingsView:SureJumpBuy()
  1179. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIRuneShopBT, {Enum.RuneShopType.Gifts, Enum.RuneShopSubType.Gold}, self.uiData.id)
  1180. end
  1181. function UISkillSettingsView:OnSkillEquipSignClick(button, params)
  1182. local state = params[0]
  1183. local idx = params[1]
  1184. local heroId = self.controller:GetHeroId()
  1185. local heroData = CommonUtil.GetHeroLogicDataByUid(heroId)
  1186. local skillEquipData = self.controller:GetCurSkillEquipData()
  1187. local cfgData = ManagerContainer.CfgMgr:GetArtifactCfgDataByCfgId(skillEquipData.cfgId)
  1188. if not cfgData then return end
  1189. if state == 1 then
  1190. --灰态
  1191. local data = cfgData.ArtifacFuncId[idx]
  1192. local skillData = heroData.skillData
  1193. local slotSkills = skillData.slotSkills
  1194. local unLockSkillMap = skillData.unlockSkillMap
  1195. local oldSkillId = heroId == 1 and data[2] or data[3]
  1196. local condition1 = unLockSkillMap[oldSkillId] ~= nil
  1197. local condition2 = false
  1198. for i = 1, #slotSkills do
  1199. if slotSkills[i].isUnlock and slotSkills[i].skillId == oldSkillId then
  1200. condition2 = true
  1201. break
  1202. end
  1203. end
  1204. local condition3 = data ~= nil and idx <= skillEquipData.starLv
  1205. local data = {heroId = self.controller:GetHeroId(), skillEquipData = skillEquipData, idx = idx, condition1 = condition1, condition2 = condition2, condition3 = condition3}
  1206. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIArtifactNotesTips, data)
  1207. elseif state == 2 then
  1208. --亮态
  1209. local jobType
  1210. if heroId == 1 then
  1211. local jobData = ManagerContainer.CfgMgr:GetJobDataById(heroData.configId)
  1212. jobType = jobData.JobType
  1213. else
  1214. local cfgData = ManagerContainer.CfgMgr:GetPartnerDataById(heroData.configId)
  1215. jobType = cfgData.JobType
  1216. end
  1217. local data = {{cfgId = skillEquipData.cfgId, jobType = jobType, logicData = skillEquipData, heroId = heroId, heroCfgId = heroData.configId, nickname = heroData.nickname}, Enum.ItemIEnterType.Bag, self.uiData.id}
  1218. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIArtifactTips, data)
  1219. end
  1220. end
  1221. return UISkillSettingsView