| 1 | /* | 
|---|
| 2 |  *   ORXONOX - the hottest 3D action shooter ever to exist | 
|---|
| 3 |  *                    > www.orxonox.net < | 
|---|
| 4 |  * | 
|---|
| 5 |  * | 
|---|
| 6 |  *   License notice: | 
|---|
| 7 |  * | 
|---|
| 8 |  *   This program is free software; you can redistribute it and/or | 
|---|
| 9 |  *   modify it under the terms of the GNU General Public License | 
|---|
| 10 |  *   as published by the Free Software Foundation; either version 2 | 
|---|
| 11 |  *   of the License, or (at your option) any later version. | 
|---|
| 12 |  * | 
|---|
| 13 |  *   This program is distributed in the hope that it will be useful, | 
|---|
| 14 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 15 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 16 |  *   GNU General Public License for more details. | 
|---|
| 17 |  * | 
|---|
| 18 |  *   You should have received a copy of the GNU General Public License | 
|---|
| 19 |  *   along with this program; if not, write to the Free Software | 
|---|
| 20 |  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | 
|---|
| 21 |  * | 
|---|
| 22 |  *   Author: | 
|---|
| 23 |  *      Marc Dreher | 
|---|
| 24 |  *   Co-authors: | 
|---|
| 25 |  *       | 
|---|
| 26 |  * | 
|---|
| 27 |  */ | 
|---|
| 28 |  | 
|---|
| 29 | #include "PacmanPointSphere.h" | 
|---|
| 30 |  | 
|---|
| 31 | #include "core/CoreIncludes.h" | 
|---|
| 32 | #include "BulletDynamics/Dynamics/btRigidBody.h" | 
|---|
| 33 |  | 
|---|
| 34 | namespace orxonox | 
|---|
| 35 | { | 
|---|
| 36 |     RegisterClass(PacmanPointSphere); | 
|---|
| 37 |  | 
|---|
| 38 |     /** | 
|---|
| 39 |     @brief | 
|---|
| 40 |         Constructor. Registers the object and initializes some default values. | 
|---|
| 41 |     @param creator | 
|---|
| 42 |         The creator of this object. | 
|---|
| 43 |     */ | 
|---|
| 44 |     PacmanPointSphere::PacmanPointSphere(Context* context) : ControllableEntity(context) | 
|---|
| 45 |     { | 
|---|
| 46 |         RegisterObject(PacmanPointSphere); | 
|---|
| 47 |         this->setCollisionType(CollisionType::None); | 
|---|
| 48 |     } | 
|---|
| 49 |  | 
|---|
| 50 |     /** | 
|---|
| 51 |     @brief | 
|---|
| 52 |         Destructor. Destroys controller, if present. | 
|---|
| 53 |     */ | 
|---|
| 54 |     PacmanPointSphere::~PacmanPointSphere() | 
|---|
| 55 |     { | 
|---|
| 56 |         // Deletes the controller if the object was initialized and the pointer to the controller is not NULL. | 
|---|
| 57 |     } | 
|---|
| 58 |  | 
|---|
| 59 |     /** | 
|---|
| 60 |     @brief | 
|---|
| 61 |         Method for creating a AutonomousDrone through XML. | 
|---|
| 62 |     */ | 
|---|
| 63 |     void PacmanPointSphere::XMLPort(Element& xmlelement, XMLPort::Mode mode) | 
|---|
| 64 |     { | 
|---|
| 65 |         SUPER(PacmanPointSphere, XMLPort, xmlelement, mode); | 
|---|
| 66 |     } | 
|---|
| 67 |  | 
|---|
| 68 |  | 
|---|
| 69 |     void PacmanPointSphere::tick(float dt) | 
|---|
| 70 |     { | 
|---|
| 71 |         SUPER(PacmanPointSphere, tick, dt); | 
|---|
| 72 |     } | 
|---|
| 73 |  | 
|---|
| 74 |     //Check for collision | 
|---|
| 75 |     bool PacmanPointSphere::taken(Vector3 playerpos) | 
|---|
| 76 |     { | 
|---|
| 77 |         resetposition = this->getPosition(); | 
|---|
| 78 |       if((abs(this->resetposition.x - playerpos.x)<10) && (abs(this->resetposition.y - playerpos.y)<10) && (abs(this->resetposition.z - playerpos.z)<5)){ | 
|---|
| 79 |         this->setPosition(Vector3(resetposition.x, -50, resetposition.z)); | 
|---|
| 80 |         return true; | 
|---|
| 81 |       }  | 
|---|
| 82 |       return false; | 
|---|
| 83 |     } | 
|---|
| 84 |  | 
|---|
| 85 |     //Reset position | 
|---|
| 86 |     void PacmanPointSphere::resetPacmanPointSphere(){ | 
|---|
| 87 |         resetposition = this->getPosition(); | 
|---|
| 88 |         resetposition.y = 10; | 
|---|
| 89 |         this->setPosition(resetposition); | 
|---|
| 90 |     } | 
|---|
| 91 | } | 
|---|