ActorAttributeData.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. local ActorAttributeData = class("ActorAttributeData",require("DataBase"))
  2. -- Enum EnActorAttribute
  3. -- {
  4. -- }
  5. function ActorAttributeData:ctor()
  6. self.tbAttribut = {}
  7. self.actor_id = 0
  8. self.is_hero_pet = false
  9. end
  10. function ActorAttributeData:Clear()
  11. self.tbAttribut = {}
  12. self.actor_id = 0
  13. self.is_hero_pet = false
  14. end
  15. function ActorAttributeData:Destroy()
  16. self.tbAttribut = nil
  17. end
  18. function ActorAttributeData:SetAttribute(Key,value)
  19. local IsFinde = false
  20. for i=1,#self.tbAttribut do
  21. if tostring(self.tbAttribut[i].AttrKey) == tostring(Key) then
  22. self.tbAttribut[i].AttrValue = value
  23. IsFinde = true
  24. end
  25. end
  26. if not IsFinde then
  27. table.insert(self.tbAttribut,{AttrKey = Key,AttrValue = value})
  28. end
  29. end
  30. function ActorAttributeData:GetAttribute(Key)
  31. for i=1,#self.tbAttribut do
  32. if self.tbAttribut[i].AttrKey == Key then
  33. return self.tbAttribut[i].AttrValue
  34. end
  35. end
  36. return nil
  37. end
  38. function ActorAttributeData:GetAllAttributeKey()
  39. local tbKeys = {}
  40. for i=1,#self.tbAttribut do
  41. table.insert(tbKeys,self.tbAttribut[i].AttrKey)
  42. end
  43. return tbKeys
  44. end
  45. return ActorAttributeData