UIPetAttributeCtr.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. local UIPetAttributeCtr = class("UIPetAttributeCtr", require("UICtrBase"))
  2. function UIPetAttributeCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIPetAttributeCtr:SetData(data)
  6. self.asyncIdx = 0
  7. if data == nil then return end
  8. self.data = data
  9. end
  10. function UIPetAttributeCtr:GetAsyncIdx()
  11. self.asyncIdx = self.asyncIdx + 1
  12. return self.asyncIdx
  13. end
  14. function UIPetAttributeCtr:GetData()
  15. return self.data
  16. end
  17. function UIPetAttributeCtr:GetId()
  18. return self.data.id
  19. end
  20. function UIPetAttributeCtr:GetType()
  21. return self.data.type
  22. end
  23. function UIPetAttributeCtr:GetCfgId()
  24. return self.data.cfgId
  25. end
  26. function UIPetAttributeCtr:GetBaseAttrList()
  27. return self.data.baseList
  28. end
  29. function UIPetAttributeCtr:GetAddAttrList()
  30. return self.data.addList
  31. end
  32. function UIPetAttributeCtr:GetPetActorData()
  33. local id = self.data.id
  34. local actorData = ManagerContainer.DataMgr.PetDataMgr:GetPetActorData(id)
  35. if not actorData then
  36. return
  37. end
  38. return actorData
  39. end
  40. function UIPetAttributeCtr:GetRelationAddAttrs()
  41. local function GetMaxActiveRelationIdx(relationPets, cfgData)
  42. local count = 3
  43. local maxIdx = 0
  44. for j = 3, 1, -1 do
  45. local condition = cfgData['Condition'..j]
  46. local state
  47. if condition then
  48. local curCount = 0
  49. if relationPets then
  50. for k,v1 in pairs(relationPets) do
  51. local cfgId = condition[k][1]
  52. local num = condition[k][2]
  53. if v1.cfgId == cfgId and v1.advanceLevel >= num and v1.petId > 0 then
  54. curCount = curCount + 1
  55. end
  56. end
  57. end
  58. state = curCount >= count
  59. if state then
  60. if maxIdx == 0 then
  61. maxIdx = j
  62. end
  63. end
  64. end
  65. end
  66. return maxIdx
  67. end
  68. local list = {}
  69. local relationDatas = ManagerContainer.DataMgr.PetDataMgr:GetAllPetRelationDatas()
  70. for _,v in pairs(relationDatas) do
  71. local cfgData = ManagerContainer.CfgMgr:GetPetPartnerDataById(v.cfgId)
  72. local maxIdx = GetMaxActiveRelationIdx(v.relationPets, cfgData)
  73. if maxIdx > 0 then
  74. for i = maxIdx, 1, -1 do
  75. for k, v1 in pairs(cfgData["attribute"..i]) do
  76. if not list[v1[1]] then
  77. list[v1[1]] = 0
  78. end
  79. list[v1[1]] = list[v1[1]] + v1[2]
  80. end
  81. end
  82. end
  83. end
  84. return list
  85. end
  86. function UIPetAttributeCtr:OnDispose()
  87. self.data = nil
  88. self.view = nil
  89. end
  90. return UIPetAttributeCtr