#ifndef _OrxoBloxBall_H__ #define _OrxoBloxBall_H__ #include "OrxoBlox/OrxoBloxPrereqs.h" #include "util/Math.h" #include "worldentities/pawns/Pawn.h" #include namespace orxonox { /** @brief This class manages the ball for @ref orxonox::OrxoBlox "OrxoBlox". It is responsible for both the movement of the ball in the x,z-plane as well as its interaction with the boundaries of the playing field (defined by the @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint") and the @ref orxonox::OrxoBloxBat "OrxoBloxBats". Or more precisely, it makes the ball bounce off then upper and lower delimiters of the playing field, it makes the ball bounce off the bats and also detects when a player scores and takes appropriate measures. @author Fabian 'x3n' Landau @ingroup OrxoBlox */ class _OrxoBloxExport OrxoBloxBall : public Pawn { public: OrxoBloxBall(Context* context); virtual ~OrxoBloxBall(); virtual void tick(float dt) override; virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; /** @brief Set the dimensions of the playing field. @param width The width of the playing field. @param height The height of the playing field. */ void setFieldDimension(float width, float height) { this->fieldWidth_ = width; this->fieldHeight_ = height; } /** @brief Get the dimensions of the playing field. @param dimension A vector with the width as the first and height as the second component. */ void setFieldDimension(const Vector2& dimension) { this->setFieldDimension(dimension.x, dimension.y); } /** @brief Get the dimensions of the playing field. @return Returns a vector with the width as the first and height as the second component. */ Vector2 getFieldDimension() const { return Vector2(this->fieldWidth_, this->fieldHeight_); } void setSpeed(float speed); //!< Set the speed of the ball (in x-direction). /** @brief Get the speed of the ball (in x-direction). @return Returns the speed of the ball (in x-direction). */ float getSpeed() const { return this->speed_; } /** @brief Set the acceleration factor of the ball. @param factor The factor the acceleration of the ball is set to. */ void setAccelerationFactor(float factor) { this->accelerationFactor_ = factor; } /** @brief Get the acceleration factor of the ball. @return Returns the acceleration factor of the ball. */ float getAccelerationFactor() const { return this->accelerationFactor_; } void Bounce(WorldEntity* Stone); void Collides(OrxoBloxStones* otherObject); bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; static const float MAX_REL_Z_VELOCITY; void setDefScoreSound(const std::string& engineSound); const std::string& getDefScoreSound(); void setDefBoundarySound(const std::string& engineSound); const std::string& getDefBoundarySound(); float getRadius(); private: void registerVariables(); OrxoBlox* getOrxoBlox(); float radius_; float fieldWidth_; //!< The width of the playing field. float fieldHeight_; //!< The height of the playing field. float speed_; //!< The speed (in x-direction) of the ball. float accelerationFactor_; //!< The acceleration factor of the ball. unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network. float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have. WorldSound* defScoreSound_; WorldSound* defBoundarySound_; OrxoBlox* orxoblox_; }; } #endif /* _OrxoBloxBall_H__ */