Crystal.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "Crystal.h"
  2. #include "Model.h"
  3. #include "Player.h"
  4. Crystal::Crystal(const std::string & filled, const std::string & empty, const Vec3f & position, Vec3f & rotation, const float & scale)
  5. {
  6. this->filled = Model::load(filled);
  7. this->empty = Model::load(empty);
  8. model = this->filled;
  9. this->position = position;
  10. this->rotation = rotation;
  11. this->scale = scale;
  12. this->canCollide = true;
  13. isFilled = true;
  14. sound_id = CrystalPoint::GetSoundSystem().LoadSound("WAVE/Crystal.wav", false);
  15. music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
  16. music->SetPos(position, Vec3f());
  17. }
  18. Crystal::~Crystal()
  19. {
  20. CrystalPoint::GetSoundSystem().UnloadSound(sound_id);
  21. if (model)
  22. Model::unload(model);
  23. //if isfilled, means model is model filled, so model empty has to been deleted.
  24. //if is not filled, means model is model empty, so model filled has to been deleted.
  25. if (isFilled)
  26. if(empty)
  27. Model::unload(empty);
  28. else
  29. if(filled)
  30. Model::unload(filled);
  31. }
  32. void Crystal::draw()
  33. {
  34. Entity::draw();
  35. }
  36. void Crystal::collide()
  37. {
  38. if (isFilled)
  39. {
  40. music->Play();
  41. Player::getInstance()->crystals++;
  42. isFilled = false;
  43. model = empty;
  44. }
  45. }