ItemSkill.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "ItemSkill.h"
  2. #include "Block.h"
  3. #include "Entity.h"
  4. #include "ItemType.h"
  5. ItemSkill::ItemSkill(float xp, float maxXp, float level)
  6. : Framework::ReferenceCounter(),
  7. xp(xp),
  8. maxXP(maxXp),
  9. level(level),
  10. itemTypeId(-1)
  11. {}
  12. void ItemSkill::load(Framework::StreamReader* zReader)
  13. {
  14. zReader->lese((char*)&xp, 4);
  15. zReader->lese((char*)&maxXP, 4);
  16. zReader->lese((char*)&level, 4);
  17. zReader->lese((char*)&itemTypeId, 4);
  18. }
  19. void ItemSkill::save(Framework::StreamWriter* zWriter)
  20. {
  21. zWriter->schreibe((char*)&xp, 4);
  22. zWriter->schreibe((char*)&maxXP, 4);
  23. zWriter->schreibe((char*)&level, 4);
  24. zWriter->schreibe((char*)&itemTypeId, 4);
  25. }
  26. bool ItemSkill::interact(Entity* zActor, Item* zUsedItem, Block* zTarget)
  27. {
  28. return zTarget->interact(zUsedItem, zActor);
  29. }
  30. bool ItemSkill::interact(Entity* zActor, Item* zUsedItem, Entity* zTarget)
  31. {
  32. return zTarget->interact(zUsedItem, zActor);
  33. }
  34. void ItemSkill::setXp(float xp)
  35. {
  36. this->xp = xp;
  37. }
  38. float ItemSkill::getXp() const
  39. {
  40. return xp;
  41. }
  42. void ItemSkill::setMaxXp(float maxXp)
  43. {
  44. this->maxXP = maxXp;
  45. }
  46. float ItemSkill::getMaxXp() const
  47. {
  48. return maxXP;
  49. }
  50. void ItemSkill::setLevel(float level)
  51. {
  52. this->level = level;
  53. }
  54. float ItemSkill::getLevel() const
  55. {
  56. return level;
  57. }
  58. void ItemSkill::setItemTypeId(int itemTypeId)
  59. {
  60. this->itemTypeId = itemTypeId;
  61. }
  62. int ItemSkill::getItemTypeId() const
  63. {
  64. return itemTypeId;
  65. }