Portal.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include "Portal.h"
  2. #include "Model.h"
  3. #include <iostream>
  4. #include "Player.h"
  5. #include "WorldHandler.h"
  6. Portal::Portal(const std::string &fileName,
  7. const Vec3f &position,
  8. Vec3f &rotation,
  9. const float &scale)
  10. {
  11. model = Model::load(fileName);
  12. this->position = position;
  13. this->rotation = rotation;
  14. this->scale = scale;
  15. this->canCollide = true;
  16. started = false;
  17. delay = 0;
  18. sound_id = CrystalPoint::GetSoundSystem().LoadSound("WAVE/portal.wav", false);
  19. music = CrystalPoint::GetSoundSystem().GetSound(sound_id);
  20. music->SetPos(position, Vec3f());
  21. mayEnter = false;
  22. maxCrystals = 0;
  23. }
  24. Portal::~Portal()
  25. {
  26. // Model::unload(model);
  27. // delete music;
  28. }
  29. void Portal::collide()
  30. {
  31. if (maxCrystals == (Player::getInstance()->crystals) && !mayEnter)
  32. {
  33. canCollide = false;
  34. mayEnter = true;
  35. }
  36. }
  37. bool Portal::enter(float deltaTime)
  38. {
  39. if (delay > 3 && started)
  40. {
  41. delete music;
  42. delay = 0;
  43. return true;
  44. }
  45. if (delay == 0 && !started)
  46. {
  47. music->Play();
  48. started = true;
  49. }
  50. delay += deltaTime;
  51. return false;
  52. }