HeroEquipProxy.lua 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local proxyUtils = requireProxy("proxyUtils")
  3. local HeroEquipProxy = class("HeroEquipProxy", RemoteProxy)
  4. HeroEquipProxy.NAME = global.ProxyTable.HeroEquipProxy
  5. function HeroEquipProxy:ctor()
  6. HeroEquipProxy.super.ctor(self)
  7. self._equipDataByMakeIndex = {} --item
  8. self._equipPosData = {}--makeindex
  9. self.EquipPosData = requireConfig("EquipPosTypeConfig")
  10. self.EquipPosType = self.EquipPosData.EquipPosTypeConfig
  11. self.ModelViewEquipOff = {}
  12. self.ModelViewHairOff = {}
  13. self.ItemBelongType = global.MMO.ITEM_FROM_BELONG_HEROEQUIP
  14. self.posfight = {}
  15. self.suitnum = {}
  16. self.lastTakeOnPos = {}
  17. self.bestRingsOpen = false
  18. self.equipQuality = {
  19. DEFAULT_EQUIP = 1, --战装
  20. GOD_MAGIC_EQUIP = 2, --魔神装
  21. FASHION_EQUIP = 3 --神器(魔神武器衣服)
  22. }
  23. self._helmet_cap_part = nil --头盔斗笠内观是否是分开显示的
  24. self:loadJson()
  25. end
  26. function HeroEquipProxy:loadJson()
  27. local cjson = require("cjson")
  28. -- 装备偏移
  29. local function loadEquipOffset(filename, index)
  30. if global.FileUtilCtl:isFileExist(filename) then
  31. local jsonStr = global.FileUtilCtl:getDataFromFileEx(filename)
  32. local jsonData = {}
  33. xpcall(function()
  34. jsonData = cjson.decode(jsonStr)
  35. end,
  36. function()
  37. if global.isDebugMode or global.isGMMode then
  38. ShowSystemTips(string.format("json文件格式错误: %s", filename))
  39. end
  40. end
  41. )
  42. for key, value in pairs(jsonData) do
  43. local offValue = {
  44. x = value.x,
  45. y = value.y
  46. }
  47. if global.isWinPlayMode then
  48. if value.x1 then
  49. offValue.x = value.x1
  50. end
  51. if value.y1 then
  52. offValue.y = value.y1
  53. end
  54. end
  55. self.ModelViewEquipOff[tonumber(key) + index * 10000] = offValue
  56. end
  57. end
  58. end
  59. for i = 0, 10 do
  60. local filename = string.format("res/player_show/player_show_%s/equip_offest.txt", i)
  61. if global.FileUtilCtl:isFileExist(filename) then
  62. loadEquipOffset(filename, i)
  63. end
  64. end
  65. -- 头发偏移
  66. local function loadHairOffset(filename)
  67. if global.FileUtilCtl:isFileExist(filename) then
  68. local jsonStr = global.FileUtilCtl:getDataFromFileEx(filename)
  69. local jsonData = {}
  70. xpcall(function()
  71. jsonData = cjson.decode(jsonStr)
  72. end,
  73. function()
  74. if global.isDebugMode or global.isGMMode then
  75. ShowSystemTips(string.format("json文件格式错误: %s", filename))
  76. end
  77. end
  78. )
  79. for key, value in pairs(jsonData) do
  80. local offValue = {
  81. x = value.x,
  82. y = value.y
  83. }
  84. if global.isWinPlayMode then
  85. if value.x1 then
  86. offValue.x = value.x1
  87. end
  88. if value.y1 then
  89. offValue.y = value.y1
  90. end
  91. end
  92. self.ModelViewHairOff[tonumber(key)] = offValue
  93. end
  94. end
  95. end
  96. loadHairOffset("data_config/hair_offest.txt")
  97. end
  98. function HeroEquipProxy:loginOut()
  99. return self._helmet_cap_part
  100. end
  101. function HeroEquipProxy:GetEquipModelOffSet()
  102. return self.ModelViewEquipOff
  103. end
  104. function HeroEquipProxy:GetModelHairOffSet()
  105. return self.ModelViewHairOff
  106. end
  107. function HeroEquipProxy:GetEquipPosByStdMode(StdMode)
  108. local posList = self.EquipPosData.EquipPosByStdMode[StdMode]
  109. if posList and next(posList) then
  110. for k, pos in pairs(posList) do
  111. local equip = self:GetEquipDataByPos(pos)
  112. if not equip then
  113. return pos
  114. end
  115. end
  116. return posList[1]
  117. end
  118. return nil
  119. end
  120. -- tips部位列表
  121. function HeroEquipProxy:GetTipsEquipPosByStdModeList(StdMode)
  122. if self.EquipPosData.TipsEquipPosByStdMode[StdMode] then
  123. return self.EquipPosData.TipsEquipPosByStdMode[StdMode]
  124. end
  125. return self:GetEquipPosByStdModeList(StdMode)
  126. end
  127. function HeroEquipProxy:GetEquipPosByStdModeList(StdMode)
  128. return self.EquipPosData.EquipPosByStdMode[StdMode]
  129. end
  130. function HeroEquipProxy:GetEquipMappingConfig(pos)
  131. return self.EquipPosData.EquipPosMapping[pos]
  132. end
  133. -- 反向
  134. function HeroEquipProxy:GetDeEquipMappingConfig(pos)
  135. if not pos then
  136. return nil
  137. end
  138. for belongPos, v in pairs(self.EquipPosData.EquipPosMapping) do
  139. for k, position in pairs(v) do
  140. if position == pos then
  141. return belongPos
  142. end
  143. end
  144. end
  145. return nil
  146. end
  147. function HeroEquipProxy:IsShowEquipItems(pos)
  148. local equipPos = pos or 0
  149. local noShowItem = {
  150. [self.EquipPosType.Equip_Type_Dress] = true,
  151. [self.EquipPosType.Equip_Type_Weapon] = true,
  152. [self.EquipPosType.Equip_Type_Helmet] = true,
  153. [self.EquipPosType.Equip_Type_Cap] = true,
  154. [self.EquipPosType.Equip_Type_Shield] = true,
  155. [self.EquipPosType.Equip_Type_Veil] = true,
  156. [self.EquipPosType.Equip_Type_Super_Dress] = true,
  157. [self.EquipPosType.Equip_Type_Super_Weapon] = true,
  158. [self.EquipPosType.Equip_Type_Super_Helmet] = true,
  159. [self.EquipPosType.Equip_Type_Super_Cap] = true,
  160. [self.EquipPosType.Equip_Type_Super_Shield] = true,
  161. [self.EquipPosType.Equip_Type_Super_Veil] = true,
  162. [self.EquipPosType.Equip_Fashion_Dress] = true,
  163. [self.EquipPosType.Equip_Fashion_Weapon] = true,
  164. }
  165. return not noShowItem[pos]
  166. end
  167. function HeroEquipProxy:GetEquipTypeConfig()
  168. return self.EquipPosType
  169. end
  170. function HeroEquipProxy:ClearEquipData()
  171. self._equipDataByMakeIndex = {}
  172. self._equipPosData = {}
  173. end
  174. function HeroEquipProxy:GetEquipData()
  175. return self._equipDataByMakeIndex
  176. end
  177. function HeroEquipProxy:GetEquipPosData()
  178. return self._equipPosData
  179. end
  180. function HeroEquipProxy:GetEquipDataByMakeIndex(makeIndex)
  181. return self._equipDataByMakeIndex[makeIndex]
  182. end
  183. function HeroEquipProxy:FindEquipDataByPos(pos)
  184. if not self._equipPosData[pos] then
  185. return nil
  186. end
  187. return self:GetEquipDataByMakeIndex(self._equipPosData[pos])
  188. end
  189. function HeroEquipProxy:GetEquipDataByPos(pos, beginOnMoving)
  190. local data = self:FindEquipDataByPos(pos)
  191. if beginOnMoving then
  192. local list = self:GetEquipMappingConfig(pos) -- 单显示位置 多个装备位置共享
  193. if list then
  194. data = nil
  195. for _, v in ipairs(list) do
  196. data = self:FindEquipDataByPos(v)
  197. if data then
  198. break
  199. end
  200. end
  201. end
  202. end
  203. return data
  204. end
  205. function HeroEquipProxy:GetEquipDataByName(Name)
  206. local list = {}
  207. local data = self:GetEquipData()
  208. if not Name or Name == "" or not data or next(data) == nil then
  209. return list
  210. end
  211. local originName = nil
  212. for k, v in pairs(data) do
  213. originName = v.originName or v.Name
  214. if originName == Name then
  215. table.insert(list, v)
  216. end
  217. end
  218. return list
  219. end
  220. function HeroEquipProxy:GetEquipDataPosDataList(pos)
  221. local data = {}
  222. local list = self:GetEquipMappingConfig(pos) -- 单显示位置 多个装备位置共享
  223. if list then
  224. for _, v in ipairs(list) do
  225. local equipData = self:FindEquipDataByPos(v)
  226. if equipData then
  227. table.insert(data, equipData)
  228. end
  229. end
  230. else
  231. local equipData = self:FindEquipDataByPos(pos)
  232. if equipData then
  233. table.insert(data, equipData)
  234. end
  235. end
  236. if next(data) == nil then
  237. data = nil
  238. end
  239. return data
  240. end
  241. -- 战力对比 checkPosData: 指定部位数据战力对比( {[1]={data, pos}})
  242. function HeroEquipProxy:GetMinPowerPosByStdMode(StdMode, param, checkPosData)
  243. local StdMode = StdMode or 0
  244. local onEquipMinPower = 0
  245. local minPowerPos = -1
  246. local hasEquip = true
  247. local pos = checkPosData or self:GetEquipPosByStdModeList(StdMode)
  248. if not pos or next(pos) == nil then
  249. print("this StdMode is not a equip")
  250. return minPowerPos, onEquipMinPower
  251. end
  252. if param.checkPos then
  253. local index = table.indexof(pos, param.checkPos)
  254. if index then
  255. local fristPos = pos[1]
  256. pos[1] = param.checkPos
  257. pos[index] = fristPos
  258. end
  259. end
  260. local isChekcPos = false
  261. if checkPosData then
  262. isChekcPos = true
  263. end
  264. for k, v in ipairs(pos) do
  265. local equipData = isChekcPos and v.data or self:GetEquipDataByPos(v)
  266. if not equipData then
  267. minPowerPos = isChekcPos and v.pos or v
  268. onEquipMinPower = 0
  269. hasEquip = false
  270. break
  271. end
  272. local equipPower = GUIFunction:GetEquipPower(equipData, param, true)
  273. if onEquipMinPower == 0 or onEquipMinPower > equipPower then
  274. onEquipMinPower = equipPower
  275. minPowerPos = isChekcPos and v.pos or v
  276. if StdMode == 25 then
  277. break
  278. end
  279. end
  280. end
  281. return minPowerPos, onEquipMinPower, hasEquip
  282. end
  283. function HeroEquipProxy:GetEquipTakeOnPosByStdMode(StdMode, param)
  284. local StdMode = StdMode or 0
  285. local onEquipMinPower = 0
  286. local minPowerPos = -1
  287. local hasEquip = true
  288. local pos = self:GetEquipPosByStdModeList(StdMode)
  289. if not pos or next(pos) == nil then
  290. print("this StdMode is not a equip")
  291. return minPowerPos, onEquipMinPower
  292. end
  293. local posCount = #pos
  294. if posCount > 1 then
  295. for k, v in pairs(pos) do
  296. local equipData = self:GetEquipDataByPos(v)
  297. if not equipData then
  298. minPowerPos = v
  299. onEquipMinPower = 0
  300. hasEquip = false
  301. break
  302. end
  303. end
  304. if hasEquip then -- 如果没有空位
  305. if not self.lastTakeOnPos[pos[1]] then
  306. self.lastTakeOnPos[pos[1]] = 1
  307. else
  308. self.lastTakeOnPos[pos[1]] = self.lastTakeOnPos[pos[1]] + 1
  309. if self.lastTakeOnPos[pos[1]] > posCount then
  310. self.lastTakeOnPos[pos[1]] = 1
  311. end
  312. end
  313. local chooseIndex = self.lastTakeOnPos[pos[1]] or 1
  314. local choosePos = pos[chooseIndex] or pos[1]
  315. local equipData = self:GetEquipDataByPos(choosePos)
  316. if equipData then
  317. local equipPower = GUIFunction:GetEquipPower(equipData, param, true)
  318. onEquipMinPower = equipPower
  319. minPowerPos = choosePos
  320. else
  321. minPowerPos = choosePos
  322. onEquipMinPower = 0
  323. hasEquip = false
  324. end
  325. end
  326. else -- 单位置 直接为改位置
  327. local onlyPos = pos[1]
  328. local equipData = self:GetEquipDataByPos(onlyPos)
  329. minPowerPos = onlyPos
  330. if not equipData then
  331. onEquipMinPower = 0
  332. hasEquip = false
  333. else
  334. local equipPower = GUIFunction:GetEquipPower(equipData, param, true)
  335. onEquipMinPower = equipPower
  336. end
  337. end
  338. return minPowerPos, onEquipMinPower, hasEquip
  339. end
  340. function HeroEquipProxy:CheckEquipNeedSex(item, sex)
  341. if not item or not next(item) then
  342. return false
  343. end
  344. local PlayerPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroPropertyProxy)
  345. local stdMode = item.StdMode
  346. local sexOk = true
  347. local needSex = sex and sex or PlayerPropertyProxy:GetRoleSex()
  348. local equipNeedSexConfig = self.EquipPosData.EquipSexNeed or {}
  349. if equipNeedSexConfig[stdMode] and equipNeedSexConfig[stdMode] ~= needSex then
  350. sexOk = false
  351. end
  352. return sexOk
  353. end
  354. function HeroEquipProxy:CheckEquipWeight(onItem, pos)
  355. if not onItem or not next(onItem) or not pos or pos < 0 then
  356. return false
  357. end
  358. local offItem = self:GetEquipDataByPos(pos)
  359. local PlayerPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroPropertyProxy)
  360. local equipNeedSexConfig = self.EquipPosData.EquipHandWeightType or {}
  361. local AttType = GUIFunction:PShowAttType()
  362. local maxWeightType = AttType.Max_Wear_Weight
  363. local nowWeightType = AttType.Wear_Weight
  364. if equipNeedSexConfig[onItem.StdMode] then
  365. maxWeightType = AttType.Max_Hand_Weight
  366. nowWeightType = AttType.Hand_Weight
  367. end
  368. local onItemWeight = onItem.Weight
  369. local offItemWeight = offItem and offItem.Weight or 0
  370. local playerMaxWeight = PlayerPropertyProxy:GetRoleAttByAttType(maxWeightType) or 0
  371. local nowWearWeight = PlayerPropertyProxy:GetRoleAttByAttType(nowWeightType) or 0
  372. local afterEquip = onItemWeight - offItemWeight + nowWearWeight
  373. return afterEquip <= playerMaxWeight
  374. end
  375. --检测附身符使用 (因为护身符可以穿戴在右手镯,当附身符有穿戴,双击以及自动使用时不能穿戴,只能拖拽穿戴)
  376. function HeroEquipProxy:CheckBujukUse(item, putPos)
  377. -- body
  378. if item and item.StdMode then
  379. if item.StdMode == 25 then
  380. return true, 9
  381. end
  382. return true
  383. end
  384. return false
  385. end
  386. function HeroEquipProxy:CheckBestRingsSpace()
  387. for pos = self.EquipPosType.Equip_Type_BestRing1, self.EquipPosType.Equip_Type_BestRing12 do
  388. local data = self:GetEquipDataByPos(pos)
  389. if not data then
  390. return pos
  391. end
  392. end
  393. return false
  394. end
  395. function HeroEquipProxy:GetBestRingsOpenState()
  396. return self.bestRingsOpen
  397. end
  398. function HeroEquipProxy:SetBestRingsOpenState(state)
  399. self.bestRingsOpen = state
  400. end
  401. function HeroEquipProxy:AddEquipData(item, isInit)
  402. local MakeIndex = item.MakeIndex
  403. local Where = item.Where
  404. -- 当前位置已有装备,先删除
  405. local lastItem = self:GetEquipDataByPos(item.Where)
  406. if lastItem then
  407. self:DelEquipData(lastItem)
  408. end
  409. -- 数据存储
  410. self._equipDataByMakeIndex[MakeIndex] = item
  411. self._equipPosData[Where] = MakeIndex
  412. local ItemManagerProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemManagerProxy)
  413. ItemManagerProxy:SetItemBelong(item.MakeIndex, self.ItemBelongType)
  414. if not isInit then
  415. local sData = {}
  416. sData.MakeIndex = item.MakeIndex
  417. sData.Where = item.Where
  418. sData.opera = global.MMO.Operator_Add
  419. sData.ItemData = item
  420. global.Facade:sendNotification(global.NoticeTable.PlayEquip_Oper_Data_Hero, sData)
  421. SLBridge:onLUAEvent(LUA_EVENT_HERO_EQUIP_CHANGE, sData)
  422. end
  423. end
  424. function HeroEquipProxy:DelEquipData(item)
  425. local MakeIndex = item.MakeIndex
  426. local item = self:GetEquipDataByMakeIndex(MakeIndex)
  427. if not item then
  428. return
  429. end
  430. local AutoUseItemProxy = global.Facade:retrieveProxy(global.ProxyTable.AutoUseItemProxy)
  431. AutoUseItemProxy:AddEquipOffMakeIndex(item.MakeIndex)
  432. -- 存储数据
  433. local Where = item.Where
  434. self._equipPosData[Where] = nil
  435. self._equipDataByMakeIndex[MakeIndex] = nil
  436. local ItemManagerProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemManagerProxy)
  437. ItemManagerProxy:SetItemBelong(MakeIndex, nil)
  438. local sData = {}
  439. sData.MakeIndex = MakeIndex
  440. sData.Where = Where
  441. sData.opera = global.MMO.Operator_Sub
  442. sData.ItemData = item
  443. global.Facade:sendNotification(global.NoticeTable.PlayEquip_Oper_Data_Hero, sData)
  444. SLBridge:onLUAEvent(LUA_EVENT_HERO_EQUIP_CHANGE, sData)
  445. end
  446. function HeroEquipProxy:ChangeEquipData(item, bagDelayUpdate, isChangeLook)
  447. local MakeIndex = item.MakeIndex
  448. local Where = item.Where
  449. local oldItem = self:GetEquipDataByMakeIndex(MakeIndex)
  450. if not oldItem then
  451. return
  452. end
  453. -- 数据存储
  454. self._equipDataByMakeIndex[MakeIndex] = item
  455. local sData = {}
  456. sData.MakeIndex = MakeIndex
  457. sData.Where = Where
  458. sData.opera = global.MMO.Operator_Change
  459. sData.bagDelayUpdate = bagDelayUpdate
  460. sData.isChangeLook = isChangeLook
  461. global.Facade:sendNotification(global.NoticeTable.PlayEquip_Oper_Data_Hero, sData)
  462. SLBridge:onLUAEvent(LUA_EVENT_HERO_EQUIP_CHANGE, sData)
  463. end
  464. function HeroEquipProxy:SetEmbattle(data)
  465. self.embattle = {}
  466. if data and data ~= 0 then
  467. self.embattle[1] = H16Bit(data)
  468. self.embattle[2] = L16Bit(data)
  469. end
  470. end
  471. function HeroEquipProxy:GetEmbattle()
  472. return self.embattle
  473. end
  474. function HeroEquipProxy:handle_MSG_SC_EQUIP_Embattle_RESPONSE(msg)
  475. local header = msg:GetHeader()
  476. local recog = header.recog
  477. self:SetEmbattle(recog)
  478. global.Facade:sendNotification(global.NoticeTable.Layer_Embattle_Refresh_Hero)
  479. SLBridge:onLUAEvent(LUA_EVENT_HERO_EMBATTLE_CHANGE)
  480. end
  481. -- --更换iconID
  482. function HeroEquipProxy:ChangeEquipLook(MakeIndex)
  483. if not MakeIndex then
  484. return
  485. end
  486. local item = self:GetEquipDataByMakeIndex(MakeIndex)
  487. if not item then
  488. return
  489. end
  490. local ItemConfigProxy = global.Facade:retrieveProxy(global.ProxyTable.ItemConfigProxy)
  491. item.Looks, item.bEffect, item.sEffect = ItemConfigProxy:GetChangeItemLook(item.MakeIndex, item.Index)
  492. self:ChangeEquipData(item, nil, true)
  493. end
  494. -- 自定义装备使用
  495. function HeroEquipProxy:SetCustUserItem(custUserItem)
  496. if not custUserItem or string.len(custUserItem) <= 0 then
  497. return
  498. end
  499. local ItemsConfig = requireConfig("ItemsConfig")
  500. ItemsConfig.EquipMapByStdMode = {}
  501. ItemsConfig.EquipMapByStdMode = ItemsConfig.EquipMapByStdModeTemp
  502. self.EquipPosData.EquipPosByStdMode = {}
  503. self.EquipPosData.EquipPosByStdMode = self.EquipPosData.EquipPosByStdModeTemp
  504. local itemArray = string.split(custUserItem, "#")
  505. for i, v in ipairs(itemArray) do
  506. local posArray = string.split(v, "=")
  507. local pos = posArray[1] and tonumber(posArray[1]) or nil
  508. local stdModeStr = posArray[2]
  509. if stdModeStr and string.len(stdModeStr) > 0 then
  510. local StdModeArray = string.split(stdModeStr, ",")
  511. for _i, _StdMode in ipairs(StdModeArray) do
  512. local StdMode = _StdMode and tonumber(_StdMode) or nil
  513. if StdMode and pos then
  514. if not self.EquipPosData.EquipPosByStdMode[StdMode] then
  515. self.EquipPosData.EquipPosByStdMode[StdMode] = {}
  516. end
  517. table.insert(self.EquipPosData.EquipPosByStdMode[StdMode], pos)
  518. ItemsConfig.EquipMapByStdMode[StdMode] = true
  519. end
  520. end
  521. end
  522. end
  523. end
  524. function HeroEquipProxy:handle_MSG_SC_PLAYER_EQUIP_ON_FAIL(msg)
  525. local header = msg:GetHeader()
  526. local data = {}
  527. data.isSuccess = false
  528. data.header = header
  529. global.Facade:sendNotification(global.NoticeTable.HeroTakeOnResponse, data)
  530. end
  531. function HeroEquipProxy:handle_MSG_SC_PLAYER_EQUIP_ON_SUCCESS(msg)
  532. local header = msg:GetHeader()
  533. local data = {}
  534. data.isSuccess = true
  535. data.header = header
  536. data.pos = header.recog
  537. global.Facade:sendNotification(global.NoticeTable.HeroTakeOnResponse, data)
  538. end
  539. function HeroEquipProxy:handle_MSG_SC_PLAYER_EQUIP_OFF_SUCCESS( msg )
  540. local header = msg:GetHeader()
  541. global.Facade:sendNotification(global.NoticeTable.HeroTakeOffResponse, {isSuccess = true, pos = header.recog})
  542. end
  543. function HeroEquipProxy:handle_MSG_SC_PLAYER_EQUIP_OFF_FAIL(msg)
  544. global.Facade:sendNotification(global.NoticeTable.HeroTakeOffResponse, {isSuccess = false, header = msg:GetHeader()})
  545. end
  546. function HeroEquipProxy:handle_MSG_SC_PALYER_EQUIP_INFO_HERO(msg)
  547. local jsonData = ParseRawMsgToJson(msg)
  548. if not jsonData or next(jsonData) == nil then
  549. return
  550. end
  551. for k, equip in pairs(jsonData) do
  552. if equip and equip ~= "" then
  553. equip = ChangeItemServersSendDatas(equip)
  554. self:AddEquipData(equip, true)
  555. end
  556. end
  557. global.Facade:sendNotification(global.NoticeTable.PlayEquip_Oper_Init_Hero)
  558. SLBridge:onLUAEvent(LUA_EVENT_HERO_EQUIP_CHANGE, {opera = global.MMO.Operator_Init})
  559. end
  560. function HeroEquipProxy:RequestBestRingsOpenState()
  561. LuaSendMsg(global.MsgType.MSG_CS_PLAYER_EQUIP_BEST_RINGS_STATE_HERO, 0, 0, 0, 0)
  562. end
  563. function HeroEquipProxy:handle_MSG_SC_PLAYER_EQUIP_BEST_RINGS_STATE(msg)
  564. local header = msg:GetHeader()
  565. local state = header.recog == 1
  566. local isOpen = false
  567. if self.bestRingsOpen and state then
  568. isOpen = true
  569. end
  570. self:SetBestRingsOpenState(state)
  571. global.Facade:sendNotification(global.NoticeTable.Layer_PlayerBestRing_State_Hero, { isOpen = isOpen })
  572. SLBridge:onLUAEvent(LUA_EVENT_HERO_BESTRINGBOX_STATE, {isOpen = isOpen})
  573. end
  574. function HeroEquipProxy:onRegister()
  575. HeroEquipProxy.super.onRegister(self)
  576. end
  577. function HeroEquipProxy:RegisterMsgHandler()
  578. HeroEquipProxy.super.RegisterMsgHandler(self)
  579. local msgType = global.MsgType
  580. --初始化装备信息
  581. LuaRegisterMsgHandler(msgType.MSG_SC_PALYER_EQUIP_INFO_HERO, handler(self, self.handle_MSG_SC_PALYER_EQUIP_INFO_HERO))
  582. -- 装备穿上确认-成功
  583. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_ON_SUCCESS_HERO, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_ON_SUCCESS))
  584. -- -- 装备穿上确认-失败
  585. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_ON_FAIL_HERO, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_ON_FAIL))
  586. -- -- 装备脱下确认-成功
  587. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_OFF_SUCCESS_HERO, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_OFF_SUCCESS))
  588. -- -- 装备脱下确认-失败
  589. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_OFF_FAIL_HERO, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_OFF_FAIL))
  590. -- -- 首饰盒开启状态
  591. LuaRegisterMsgHandler(msgType.MSG_SC_PLAYER_EQUIP_BEST_RINGS_STATE_HERO, handler(self, self.handle_MSG_SC_PLAYER_EQUIP_BEST_RINGS_STATE))
  592. -- 法阵
  593. LuaRegisterMsgHandler( msgType.MSG_SC_EQUIP_Embattle_RESPONSE_HERO,handler(self, self.handle_MSG_SC_EQUIP_Embattle_RESPONSE) )
  594. end
  595. return HeroEquipProxy