HeroSkillProxy.lua 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local HeroSkillProxy = class("HeroSkillProxy", RemoteProxy)
  3. HeroSkillProxy.NAME = global.ProxyTable.HeroSkillProxy
  4. local cjson = require("cjson")
  5. local function parseOneSkillData(data)
  6. data.id = data.MagicID
  7. data.DelayTime = data.DelayTime or 0
  8. -- extension
  9. data.isCD = false
  10. data.curTime = 0
  11. return data
  12. end
  13. function HeroSkillProxy:ctor()
  14. HeroSkillProxy.super.ctor(self)
  15. self._data = {}
  16. self._configs = {}
  17. self._heroSkillID = nil
  18. self:Init()
  19. end
  20. function HeroSkillProxy:Init()
  21. self._data.skills = {} -- 所有拥有技能
  22. self._data.ngSkills = {} -- 所有拥有内功技能
  23. self._data.setComboSkill = {} -- 设置加入连击的连击技能
  24. self._data.comboSkills = {} -- 所有拥有的连击技能
  25. self._data.openComboNum = 3 -- 默认开启连击设置格子数
  26. end
  27. function HeroSkillProxy:LoadConfig()
  28. self._configs = requireGameConfig("cfg_magicinfo")
  29. end
  30. -- 技能配置
  31. function HeroSkillProxy:GetConfigs()
  32. return self._configs
  33. end
  34. function HeroSkillProxy:FindConfigBySkillID(skillID)
  35. return self._configs[skillID]
  36. end
  37. function HeroSkillProxy:FindAllSkillsByJob(job)
  38. if not job then
  39. local PlayerProperty = global.Facade:retrieveProxy(global.ProxyTable.HeroPropertyProxy)
  40. job = PlayerProperty:GetRoleJob()
  41. end
  42. local configs = self:GetConfigs()
  43. local items = {}
  44. for _, v in pairs(configs) do
  45. if v.job == job or v.job == 3 then
  46. table.insert(items, v)
  47. end
  48. end
  49. return items
  50. end
  51. -- 获取技能名字
  52. function HeroSkillProxy:GetSkillNameByID(skillID)
  53. local config = self:FindConfigBySkillID(skillID)
  54. if not config then
  55. return "ERROR SKILL NAME"
  56. end
  57. return config.HeroMagicName
  58. end
  59. -- 获取技能Icon 圆形
  60. function HeroSkillProxy:GetIconPathByID(skillID, isCombo)
  61. if skillID == 0 then
  62. local PlayerInputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  63. if PlayerInputProxy:CheckMiningAble() then
  64. skillID = 999
  65. end
  66. end
  67. local config = self:FindConfigBySkillID(skillID)
  68. if not config then
  69. local path = string.format("%s%s.jpg", global.MMO.PATH_RES_SKILL_ICON_C, "default")
  70. if global.FileUtilCtl:isFileExist(path) then
  71. return path
  72. end
  73. return string.format("%s%s.png", global.MMO.PATH_RES_SKILL_ICON_C, "default")
  74. end
  75. local data = isCombo and self:GetComboSkillByID(skillID) or self:GetSkillByID(skillID)
  76. if not data or not data.LevelUpIcon or data.LevelUpIcon <= 0 then
  77. local path = string.format("%s%s.jpg", global.MMO.PATH_RES_SKILL_ICON_C, config.icon)
  78. if global.FileUtilCtl:isFileExist(path) then
  79. return path
  80. end
  81. return string.format("%s%s.png", global.MMO.PATH_RES_SKILL_ICON_C, config.icon)
  82. end
  83. local path = string.format("%s%s_%s.jpg", global.MMO.PATH_RES_SKILL_ICON_C, config.icon, data.LevelUpIcon)
  84. if global.FileUtilCtl:isFileExist(path) then
  85. return path
  86. end
  87. return string.format("%s%s_%s.png", global.MMO.PATH_RES_SKILL_ICON_C, config.icon, data.LevelUpIcon)
  88. end
  89. -- 获取技能Icon 矩形
  90. function HeroSkillProxy:GetIconRectPathByID(skillID, isCombo)
  91. local config = self:FindConfigBySkillID(skillID)
  92. if not config then
  93. local path = string.format("%s%s.png", global.MMO.PATH_RES_SKILL_ICON, "default")
  94. if global.FileUtilCtl:isFileExist(path) then
  95. return path
  96. end
  97. return string.format("%s%s.jpg", global.MMO.PATH_RES_SKILL_ICON, "default")
  98. end
  99. local data = isCombo and self:GetComboSkillByID(skillID) or self:GetSkillByID(skillID)
  100. if not data or not data.LevelUpIcon or data.LevelUpIcon <= 0 then
  101. local path = string.format("%s%s.png", global.MMO.PATH_RES_SKILL_ICON, config.icon)
  102. if global.FileUtilCtl:isFileExist(path) then
  103. return path
  104. end
  105. return string.format("%s%s.jpg", global.MMO.PATH_RES_SKILL_ICON, config.icon)
  106. end
  107. local path = string.format("%s%s_%s.png", global.MMO.PATH_RES_SKILL_ICON, config.icon, data.LevelUpIcon)
  108. if global.FileUtilCtl:isFileExist(path) then
  109. return path
  110. end
  111. return string.format("%s%s_%s.jpg", global.MMO.PATH_RES_SKILL_ICON, config.icon, data.LevelUpIcon)
  112. end
  113. -- 技能数据
  114. function HeroSkillProxy:GetSkills(noBasicSkill, activeOnly)
  115. -- 已有技能数据 param1:是否排除普攻 param2:是否只获取主动技能
  116. local skills = {}
  117. for _, v in pairs(self._data.skills) do
  118. local config = self:FindConfigBySkillID(v.MagicID)
  119. if (noBasicSkill and v.MagicID == global.MMO.SKILL_INDEX_BASIC) then
  120. elseif activeOnly and false == self:IsActiveSkill(v.MagicID) then
  121. else
  122. skills[v.MagicID] = v
  123. end
  124. end
  125. return skills
  126. end
  127. function HeroSkillProxy:IsActiveSkill(skillID)
  128. local config = self:FindConfigBySkillID(skillID)
  129. if not config then
  130. return false
  131. end
  132. return config.type == 1
  133. end
  134. function HeroSkillProxy:GetSkillByID(skillID)
  135. -- 获取技能数据
  136. return self._data.skills[skillID]
  137. end
  138. function HeroSkillProxy:DelAllSkill()
  139. self._data.skills = {}
  140. self._heroSkillID = nil
  141. self._data.ngSkills = {}
  142. self._data.setComboSkill = {}
  143. self._data.comboSkills = {}
  144. end
  145. function HeroSkillProxy:GetLevel(skillID)
  146. -- 技能等级
  147. local data = self:GetSkillByID(skillID)
  148. if data then
  149. return data.Level
  150. end
  151. return -1
  152. end
  153. function HeroSkillProxy:AddSkill(data, bIsInit)
  154. --增加技能
  155. -- dump(data)
  156. if not data then
  157. return false
  158. end
  159. if self._data.skills[data.MagicID] then
  160. return false
  161. end
  162. if not self:FindConfigBySkillID(data.MagicID) then
  163. print("add skill error, skill config is nil " .. data.MagicID)
  164. return false
  165. end
  166. if self:isHeroSkill(data.MagicID) then
  167. self._heroSkillID = data.MagicID
  168. end
  169. -- 增加技能
  170. self._data.skills[data.MagicID] = data
  171. -- 广播新增技能
  172. global.Facade:sendNotification(global.NoticeTable.SkillAdd_Hero, data)
  173. SLBridge:onLUAEvent(LUA_EVENT_HERO_SKILL_ADD, data)
  174. -- 判断一遍合击技能是否是可以是否状态
  175. SLBridge:onLUAEvent(LUA_EVENT_HERO_ANGER_CAHNGE, {forceRefresh=true})
  176. end
  177. function HeroSkillProxy:DelSkill(skillID, bIsInit)
  178. --删除技能
  179. if not skillID then
  180. return false
  181. end
  182. if not self._data.skills[skillID] then
  183. return false
  184. end
  185. -- 删除技能
  186. local data = self._data.skills[skillID]
  187. self._data.skills[skillID] = nil
  188. if self:isHeroSkill(skillID) then
  189. self._heroSkillID = nil
  190. end
  191. -- 广播
  192. global.Facade:sendNotification(global.NoticeTable.SkillDel_Hero, data)
  193. SLBridge:onLUAEvent(LUA_EVENT_HERO_SKILL_DEL, data)
  194. end
  195. function HeroSkillProxy:UpdateSkillData(data)
  196. -- 更新技能数据
  197. if not data then
  198. return
  199. end
  200. if not data.skillID then
  201. return nil
  202. end
  203. local skill = self:GetSkillByID(data.skillID)
  204. if not skill then
  205. return nil
  206. end
  207. -- 更新技能属性
  208. for k, v in pairs(data) do
  209. skill[k] = v
  210. end
  211. global.Facade:sendNotification(global.NoticeTable.SkillUpdate_Hero, skill)
  212. SLBridge:onLUAEvent(LUA_EVENT_HERO_SKILL_UPDATE, skill)
  213. end
  214. function HeroSkillProxy:GetSkillTrainData(skillID)
  215. -- 技能等级>3的全部特殊处理下
  216. local maxStr = "-"
  217. if not skillID or not self._data.skills[skillID] then
  218. return maxStr
  219. end
  220. if skillID == global.MMO.SKILL_INDEX_BASIC then
  221. return maxStr
  222. end
  223. local skillData = self._data.skills[skillID]
  224. local isBaseSkill = skillData.Level <= 3
  225. local skillLevel = skillData.Level
  226. local maxSkillLevel = skillData.TrainLv
  227. if skillLevel >= maxSkillLevel then
  228. return maxStr
  229. end
  230. local skillMaxTrain = {
  231. [0] = skillData.MaxTrain1,
  232. [1] = skillData.MaxTrain2,
  233. [2] = skillData.MaxTrain3,
  234. [3] = skillData.MaxTrain4
  235. }
  236. local curTrain = skillData.CurTrain or 0
  237. local maxTrain = (isBaseSkill and skillMaxTrain[skillLevel] or skillData.MaxTrain1) or 0
  238. local str = curTrain >= maxTrain and maxStr or string.format(GET_STRING(1053), curTrain, maxTrain)
  239. return str
  240. end
  241. --
  242. --是否使用技能书 通过书名
  243. function HeroSkillProxy:CheckAbleToUseBookByName(bookname)
  244. local allSkills = self:FindAllSkillsByJob()
  245. local tskillID = nil
  246. for _, v in pairs(allSkills) do
  247. if v.magName == bookname or v.HeroMagicName == bookname then
  248. tskillID = v.MagicID
  249. break
  250. end
  251. end
  252. if not tskillID then
  253. return false
  254. end
  255. -- 已学习
  256. if self:IsLearned(tskillID) then
  257. return false
  258. end
  259. return true
  260. end
  261. -- 是否已经学习
  262. function HeroSkillProxy:IsLearned(skillID)
  263. local skillData = self:GetSkillByID(skillID)
  264. return skillData and true or false
  265. end
  266. -- MP 是否满足
  267. function HeroSkillProxy:IsEnoughMana(skillID)
  268. local skill = self:GetSkillByID(skillID)
  269. if not skill then
  270. return false
  271. end
  272. if not skill.Spell or not skill.DefSpell then
  273. -- 没有告诉我是否耗蓝
  274. return true
  275. end
  276. local propertyProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  277. local currMP = propertyProxy:GetRoleCurrMP()
  278. return currMP and currMP >= (skill.Spell + skill.DefSpell)
  279. end
  280. -- skill key
  281. function HeroSkillProxy:GetSkillKey(skillID)
  282. if not skillID then
  283. return nil
  284. end
  285. local skill = self:GetSkillByID(skillID)
  286. if not skill then
  287. return nil
  288. end
  289. return skill.Key
  290. end
  291. function HeroSkillProxy:SetSkillKey(skillID, key)
  292. if not skillID then
  293. return nil
  294. end
  295. local skill = self:GetSkillByID(skillID)
  296. if not skill then
  297. return nil
  298. end
  299. skill.Key = key
  300. self:sendMCMessage(skillID, key, 0)
  301. end
  302. -- skill 开关
  303. function HeroSkillProxy:GetNGSkillOnOff(skillID, skillType)
  304. if not skillID then
  305. return nil
  306. end
  307. local skill = self:GetNGSkillData(skillID, skillType)
  308. if not skill then
  309. return nil
  310. end
  311. return skill.Key
  312. end
  313. function HeroSkillProxy:SetNGSkillOnOff(skillID, skillType, key)
  314. if not skillID then
  315. return nil
  316. end
  317. local skill = self:GetNGSkillData(skillID, skillType)
  318. if not skill then
  319. return nil
  320. end
  321. skill.Key = key
  322. self:sendMCMessage(skillID, key, 1, skillType)
  323. end
  324. --key 0 开启 1关闭
  325. --type 0英雄 1内功 2连击
  326. --skillType 0=人物技能, 1=英雄技能 2=人物怒内功技能 3=英雄怒内功技能 4=人物静内功技能 5=英雄静内功技能 6=人物连击技能 7=英雄连击技能
  327. function HeroSkillProxy:sendMCMessage(skillID, key, type, ngType)
  328. local skillType = 0
  329. if type == 0 then
  330. skillType = 1
  331. elseif type == 1 and ngType then
  332. skillType = ngType
  333. end
  334. LuaSendMsg(global.MsgType.MSG_CS_PLAYER_ONOFF_SKILL_HERO, skillID, key, skillType, 0)
  335. end
  336. function HeroSkillProxy:RespPlayerSkillDataHero(msg)
  337. local jsonData = ParseRawMsgToJson(msg)
  338. if jsonData then
  339. for _, v in ipairs(jsonData) do
  340. local skill = parseOneSkillData(v)
  341. if skill.SkillType == 7 then -- 英雄连击技能
  342. self._data.comboSkills[skill.MagicID] = skill
  343. SLBridge:onLUAEvent(LUA_EVENT_HERO_COMBO_SKILL_ADD, skill)
  344. else
  345. self:AddSkill(skill, true)
  346. end
  347. end
  348. end
  349. end
  350. function HeroSkillProxy:RespPlayerAddSkillHero(msg)
  351. local jsonData = ParseRawMsgToJson(msg)
  352. local skill = parseOneSkillData(jsonData)
  353. if skill.SkillType == 7 then -- 英雄连击技能
  354. self._data.comboSkills[skill.MagicID] = skill
  355. SLBridge:onLUAEvent(LUA_EVENT_HERO_COMBO_SKILL_ADD, skill)
  356. else
  357. self:AddSkill(skill, false)
  358. end
  359. end
  360. --删除技能
  361. function HeroSkillProxy:RespPlayerDelSkillHero(msg)
  362. local header = msg:GetHeader()
  363. local skillID = header.recog
  364. local skillType = header.param1
  365. if skillType == 7 then -- 英雄连击技能
  366. local data = self._data.comboSkills[skillID]
  367. if data then
  368. self._data.comboSkills[skillID] = nil
  369. SLBridge:onLUAEvent(LUA_EVENT_HERO_COMBO_SKILL_DEL, data)
  370. end
  371. else
  372. self:DelSkill(skillID)
  373. end
  374. end
  375. function HeroSkillProxy:RespPlayerUpdateSkillHero(msg)
  376. local jsonData = ParseRawMsgToJson(msg)
  377. -- dump(jsonData)
  378. if not jsonData then
  379. return
  380. end
  381. -- dump(msg,"RespPlayerUpdateSkillHero___")
  382. -- dump(header)
  383. local data = {
  384. skillID = jsonData.MagicId,
  385. Level = jsonData.Level,
  386. CurTrain = jsonData.TranPoint,
  387. LevelUp = jsonData.LevelUp,
  388. LevelUpIcon = jsonData.LevelUpIcon,
  389. }
  390. if jsonData.SkillType == 7 then -- 英雄连击
  391. data.LJBJRate = jsonData.LJBJRate
  392. self:UpdateComboSkillData(data)
  393. elseif jsonData.SkillType == 3 or jsonData.SkillType == 5 then -- 英雄内功
  394. self:UpdateNGSkillData(data, jsonData.SkillType)
  395. else
  396. self:UpdateSkillData(data)
  397. end
  398. end
  399. --是否拥有英雄技能 返回技能id
  400. function HeroSkillProxy:haveHeroSkill()
  401. return self._heroSkillID
  402. end
  403. --是否是英雄技能 返回技能id 60-65
  404. function HeroSkillProxy:isHeroSkill(skillID)
  405. local skillbegin = 60
  406. local res = false
  407. for i = 0,5 do
  408. if skillbegin + i == skillID then
  409. res = skillID
  410. break
  411. end
  412. end
  413. return res
  414. end
  415. --------------------------- 内功技能 ----------------------------------
  416. function HeroSkillProxy:GetNGSkills()
  417. return self._data.ngSkills
  418. end
  419. function HeroSkillProxy:GetNGSkillsList()
  420. local list = {}
  421. for _, data in pairs(self._data.ngSkills) do
  422. for i, skill in pairs(data) do
  423. table.insert(list, skill)
  424. end
  425. end
  426. table.sort(list, function(a, b)
  427. if a.MagicID ~= b.MagicID then
  428. return a.MagicID < b.MagicID
  429. end
  430. return a.SkillType < b.SkillType
  431. end)
  432. return list
  433. end
  434. function HeroSkillProxy:GetNGSkillData(skillID, skillType)
  435. return self._data.ngSkills[skillType] and self._data.ngSkills[skillType][skillID]
  436. end
  437. --skillType 3=英雄怒内功技能 5=英雄静内功技能
  438. function HeroSkillProxy:GetNGSkillName(skillID, skillType)
  439. local config = self:FindConfigBySkillID(skillID)
  440. if not config then
  441. return "ERROR SKILL NAME"
  442. end
  443. if skillType == 3 then
  444. return config.nMagicName
  445. elseif skillType == 5 then
  446. return config.jMagicName
  447. end
  448. end
  449. function HeroSkillProxy:GetNGSkillDesc(skillID, skillType)
  450. local config = self:FindConfigBySkillID(skillID)
  451. if not config then
  452. return "ERROR SKILL DESC"
  453. end
  454. if skillType == 3 then
  455. return config.nDesc
  456. elseif skillType == 5 then
  457. return config.jDesc
  458. end
  459. end
  460. -- 获取内功技能Icon 矩形
  461. function HeroSkillProxy:GetNGIconRectPath(skillID, skillType)
  462. local config = self:FindConfigBySkillID(skillID)
  463. if not config then
  464. local path = string.format("%s%s.png", global.MMO.PATH_RES_SKILL_ICON, "default")
  465. if global.FileUtilCtl:isFileExist(path) then
  466. return path
  467. end
  468. return string.format("%s%s.jpg", global.MMO.PATH_RES_SKILL_ICON, "default")
  469. end
  470. local data = self:GetNGSkillData(skillID, skillType)
  471. local icon = nil
  472. if skillType == 3 then -- 怒
  473. icon = config.nIcon
  474. elseif skillType == 5 then -- 静
  475. icon = config.jIcon
  476. end
  477. icon = icon or config.icon
  478. if not data or not data.LevelUpIcon or data.LevelUpIcon <= 0 then
  479. local path = string.format("%s%s.png", global.MMO.PATH_RES_SKILL_ICON, icon)
  480. if global.FileUtilCtl:isFileExist(path) then
  481. return path
  482. end
  483. return string.format("%s%s.jpg", global.MMO.PATH_RES_SKILL_ICON, icon)
  484. end
  485. local path = string.format("%s%s_%s.png", global.MMO.PATH_RES_SKILL_ICON, icon, data.LevelUpIcon)
  486. if global.FileUtilCtl:isFileExist(path) then
  487. return path
  488. end
  489. return string.format("%s%s_%s.jpg", global.MMO.PATH_RES_SKILL_ICON, icon, data.LevelUpIcon)
  490. end
  491. function HeroSkillProxy:GetNGSkillTrainData(skillID, skillType)
  492. -- 技能等级>3的全部特殊处理下
  493. local maxStr = "-"
  494. if not skillID or not self._data.ngSkills[skillType] or not self._data.ngSkills[skillType][skillID] then
  495. return maxStr
  496. end
  497. if skillID == global.MMO.SKILL_INDEX_BASIC then
  498. return maxStr
  499. end
  500. local skillData = self._data.ngSkills[skillType][skillID]
  501. local isBaseSkill = skillData.Level <= 3
  502. local skillLevel = skillData.Level
  503. local maxSkillLevel = skillData.TrainLv
  504. if skillLevel >= maxSkillLevel then
  505. return maxStr
  506. end
  507. local skillMaxTrain = {
  508. [0] = skillData.MaxTrain1,
  509. [1] = skillData.MaxTrain2,
  510. [2] = skillData.MaxTrain3,
  511. [3] = skillData.MaxTrain4
  512. }
  513. local curTrain = skillData.CurTrain or 0
  514. local maxTrain = (isBaseSkill and skillMaxTrain[skillLevel] or skillData.MaxTrain1) or 0
  515. return curTrain >= maxTrain and maxStr or string.format(GET_STRING(1053), curTrain, maxTrain)
  516. end
  517. function HeroSkillProxy:UpdateNGSkillData(data, skillType)
  518. -- 更新技能数据
  519. if not data then
  520. return
  521. end
  522. if not data.skillID then
  523. return nil
  524. end
  525. local skill = self:GetNGSkillData(data.skillID, skillType)
  526. if not skill then
  527. return nil
  528. end
  529. -- 更新技能属性
  530. for k, v in pairs(data) do
  531. skill[k] = v
  532. end
  533. SLBridge:onLUAEvent(LUA_EVENT_HERO_INTERNAL_SKILL_UPDATE, skill)
  534. end
  535. function HeroSkillProxy:RespHeroNGSkillData(msg)
  536. local jsonData = ParseRawMsgToJson(msg)
  537. if jsonData then
  538. for _, v in ipairs(jsonData) do
  539. local skill = parseOneSkillData(v)
  540. if not self._data.ngSkills[skill.SkillType] then
  541. self._data.ngSkills[skill.SkillType] = {}
  542. end
  543. self._data.ngSkills[skill.SkillType][skill.MagicID] = skill
  544. end
  545. end
  546. end
  547. function HeroSkillProxy:RespHeroAddNGSkill(msg)
  548. local jsonData = ParseRawMsgToJson(msg)
  549. local skill = parseOneSkillData(jsonData)
  550. if not self._data.ngSkills[skill.SkillType] then
  551. self._data.ngSkills[skill.SkillType] = {}
  552. end
  553. self._data.ngSkills[skill.SkillType][skill.MagicID] = skill
  554. SLBridge:onLUAEvent(LUA_EVENT_HERO_INTERNAL_SKILL_ADD, skill)
  555. end
  556. --删除技能
  557. function HeroSkillProxy:RespHeroDelNGSkill(msg)
  558. local header = msg:GetHeader()
  559. local skillID = header.recog
  560. local skillType = header.param1
  561. local data = self._data.ngSkills[skillType] and self._data.ngSkills[skillType][skillID]
  562. if data then
  563. self._data.ngSkills[skillType][skillID] = nil
  564. SLBridge:onLUAEvent(LUA_EVENT_HERO_INTERNAL_SKILL_DEL, data)
  565. end
  566. end
  567. --------------------------- 连击技能 ----------------------------------
  568. function HeroSkillProxy:haveSetComboSkill()
  569. return self._data.setComboSkill
  570. end
  571. function HeroSkillProxy:SetComboSkill(idx, skillID)
  572. self._data.setComboSkill[idx] = skillID
  573. end
  574. function HeroSkillProxy:GetComboSkills()
  575. return self._data.comboSkills
  576. end
  577. function HeroSkillProxy:GetComboSkillByID(skillID)
  578. -- 获取技能数据
  579. return self._data.comboSkills[skillID]
  580. end
  581. function HeroSkillProxy:GetComboSkillTrainData(skillID)
  582. -- 技能等级>3的全部特殊处理下
  583. local maxStr = "-"
  584. if not skillID or not self._data.comboSkills[skillID] then
  585. return maxStr
  586. end
  587. local skillData = self._data.comboSkills[skillID]
  588. local isBaseSkill = skillData.Level <= 3
  589. local skillLevel = skillData.Level
  590. local maxSkillLevel = skillData.TrainLv
  591. if skillLevel >= maxSkillLevel then
  592. return maxStr
  593. end
  594. local skillMaxTrain = {
  595. [0] = skillData.MaxTrain1,
  596. [1] = skillData.MaxTrain2,
  597. [2] = skillData.MaxTrain3,
  598. [3] = skillData.MaxTrain4
  599. }
  600. local curTrain = skillData.CurTrain or 0
  601. local maxTrain = (isBaseSkill and skillMaxTrain[skillLevel] or skillData.MaxTrain1) or 0
  602. return curTrain >= maxTrain and maxStr or string.format(GET_STRING(1053), curTrain, maxTrain)
  603. end
  604. function HeroSkillProxy:SetComboOpenNum(openNum)
  605. self._data.openComboNum = openNum
  606. end
  607. function HeroSkillProxy:GetComboOpenNum()
  608. return self._data.openComboNum
  609. end
  610. function HeroSkillProxy:UpdateComboSkillData(data)
  611. -- 更新技能数据
  612. if not data then
  613. return
  614. end
  615. if not data.skillID then
  616. return nil
  617. end
  618. local skill = self:GetComboSkillByID(data.skillID)
  619. if not skill then
  620. return nil
  621. end
  622. -- 更新技能属性
  623. for k, v in pairs(data) do
  624. skill[k] = v
  625. end
  626. SLBridge:onLUAEvent(LUA_EVENT_HERO_COMBO_SKILL_UPDATE, skill)
  627. end
  628. --------------------------------------------------------------------------
  629. function HeroSkillProxy:RegisterMsgHandler()
  630. HeroSkillProxy.super.RegisterMsgHandler(self)
  631. local msgType = global.MsgType
  632. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_SKILL_DATA_HERO, handler(self, self.RespPlayerSkillDataHero)) -- 已学技能 信息
  633. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_ADD_SKILL_HERO, handler(self, self.RespPlayerAddSkillHero)) -- 新增技能
  634. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_DEL_SKILL_HERO, handler(self, self.RespPlayerDelSkillHero)) -- 删除技能
  635. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_UP_SKILL_HERO, handler(self, self.RespPlayerUpdateSkillHero)) -- 技能数据更新
  636. LuaRegisterMsgHandler(msgType.MSG_SC_HERO_NG_SKILL_DATA, handler(self, self.RespHeroNGSkillData)) -- 内功技能
  637. LuaRegisterMsgHandler(msgType.MSG_SC_HERO_ADD_NG_SKILL, handler(self, self.RespHeroAddNGSkill))
  638. LuaRegisterMsgHandler(msgType.MSG_SC_HERO_DEL_NG_SKILL, handler(self, self.RespHeroDelNGSkill))
  639. end
  640. return HeroSkillProxy