GuardPetInfo.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ---@class GuardPetInfo
  2. GuardPetInfo = class()
  3. local this = GuardPetInfo
  4. function this:ctor()
  5. end
  6. function this:Reset()
  7. end
  8. function this:Init()
  9. self.guardPetInfoList={}
  10. self:InitData()
  11. self:RegistMessages()
  12. end
  13. function this:InitData()
  14. end
  15. function this:RegistMessages()
  16. SL:RegisterLuaNetMsg(LuaMessageIdToClient.EQUIP_GUARD_ALL_RES,self.EquipGuardAllRes,self)
  17. SL:RegisterLuaNetMsg(LuaMessageIdToClient.EQUIP_GUARD_RES,self.EquipGuardRes,self)
  18. SL:RegisterLUAEvent(LUA_EVENT_GUARDPET_PUT,self.LUA_EVENT_GUARDPET_PUT,self)
  19. end
  20. function this:LUA_EVENT_GUARDPET_PUT(_,data)
  21. local _data = data._data
  22. local tbl = SL:GetConfig("cfg_equip_guard",data.cfgId)
  23. local data = { id = _data.id, cfgId = data.cfgId, x = _data.oldCoord.x, y = _data.oldCoord.z, isUI = _data.isUI, guardTbl = tbl}
  24. SL:CreateGuardPet(data)
  25. end
  26. function this:EquipGuardAllRes(_,message)
  27. if message == "" then
  28. return
  29. end
  30. for i, v in pairs(message) do
  31. self.guardPetInfoList[v.id] = v
  32. end
  33. end
  34. function this:EquipGuardRes(_,message)
  35. if message == "" then
  36. return
  37. end
  38. self.guardPetInfoList[message.id] = message
  39. end
  40. function this:GetGuardHp(id)
  41. if self.guardPetInfoList[id] then
  42. return self.guardPetInfoList[id].hp
  43. end
  44. SL:LogWarning("this guard id->hp is nil")
  45. return 0
  46. end
  47. function this:GetGuardBaseAttr(equip_pos, cfgId, id)
  48. local itemInfo = SL:GetPosItemInfo(equip_pos, cfgId, id)
  49. --玩家背包穿戴读不到就去读配置表
  50. local grade = SL:GetEquipValue(EMetaVarGetKey.EQUIP_GRADE, equip_pos, cfgId, id)
  51. local attribute = SL:GetConfig("cfg_equip_guard",cfgId).stage
  52. if attribute then
  53. local baseAttr = {}
  54. for i, v in pairs(attribute) do
  55. local oneAttr = {}
  56. oneAttr.type = v[1]
  57. oneAttr.num = v[2]
  58. table.insert(baseAttr, oneAttr)
  59. end
  60. return baseAttr
  61. end
  62. end
  63. function this:GetGuardSpecialShowData(cfgId)
  64. ---@type cfg_equip_guard_column
  65. local guardInfo = SL:GetConfig("cfg_equip_guard",cfgId)
  66. local attr = {}
  67. if guardInfo.ability == 1 then
  68. table.insert(attr,{title = "tips_attribute20"})
  69. table.insert(attr,{name="自动拾取",value = ""})
  70. --elseif guardInfo.ability == 2 then
  71. -- table.insert(attr,{title = "tips_attribute20"})
  72. -- for i, skill_id in pairs(guardInfo.abilityParameter) do
  73. -- local skill_name = SL:GetConfig("cfg_skill",skill_id).name
  74. -- table.insert(attr, { name = skill_name, value = "" })
  75. -- end
  76. end
  77. return attr
  78. end