[10657] | 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: |
---|
[10659] | 23 | * Cyrill Burgener |
---|
[10657] | 24 | * |
---|
| 25 | */ |
---|
| 26 | |
---|
| 27 | /** |
---|
[10659] | 28 | @file HoverShip.cc |
---|
[10929] | 29 | @brief Implementation of the HoverShip control |
---|
[10657] | 30 | */ |
---|
| 31 | |
---|
[10659] | 32 | #include "HoverShip.h" |
---|
[10657] | 33 | #include "core/CoreIncludes.h" |
---|
[11041] | 34 | #include "core/XMLPort.h" |
---|
[10657] | 35 | |
---|
[11041] | 36 | #include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h> |
---|
| 37 | |
---|
[10657] | 38 | namespace orxonox |
---|
| 39 | { |
---|
[10659] | 40 | RegisterClass(HoverShip); |
---|
[10657] | 41 | |
---|
[10659] | 42 | HoverShip::HoverShip(Context* context) : SpaceShip(context) |
---|
[10657] | 43 | { |
---|
[10659] | 44 | RegisterObject(HoverShip); |
---|
[10784] | 45 | enableCollisionCallback(); |
---|
| 46 | isFloor_ = false; |
---|
[12292] | 47 | jumpBoost_ = 0; |
---|
[10657] | 48 | } |
---|
| 49 | |
---|
[12410] | 50 | // //moves slightly right and left, that zombieship approaches |
---|
| 51 | // void HoverShip::leftright(const Vector2& value) |
---|
| 52 | // { |
---|
| 53 | // this->steering_.z += 5; |
---|
| 54 | // this->steering_.z -= 5; |
---|
| 55 | // } |
---|
| 56 | |
---|
[10784] | 57 | void HoverShip::moveFrontBack(const Vector2& value) |
---|
[12292] | 58 | { this->steering_.z -= value.x; } |
---|
[10694] | 59 | |
---|
| 60 | void HoverShip::moveRightLeft(const Vector2& value) |
---|
[12410] | 61 | { this->steering_.x += value.x; |
---|
| 62 | // value.x += 0.001; |
---|
| 63 | // value.x -= 0.001; |
---|
| 64 | } |
---|
[10694] | 65 | |
---|
| 66 | void HoverShip::moveUpDown(const Vector2& value) |
---|
[12292] | 67 | { this->steering_.y += value.x; } |
---|
[10694] | 68 | |
---|
[10784] | 69 | void HoverShip::rotateYaw(const Vector2& value) |
---|
| 70 | { |
---|
| 71 | this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x); |
---|
[10694] | 72 | |
---|
[10784] | 73 | Pawn::rotateYaw(value); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | void HoverShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 77 | { |
---|
| 78 | SUPER(HoverShip, XMLPort, xmlelement, mode); |
---|
| 79 | |
---|
| 80 | XMLPortParam(HoverShip, "jumpBoost", setJumpBoost, getJumpBoost, xmlelement, mode); |
---|
| 81 | } |
---|
| 82 | |
---|
[10929] | 83 | /** |
---|
| 84 | @brief |
---|
| 85 | Removed, does nothing. |
---|
[10784] | 86 | @param value |
---|
| 87 | */ |
---|
| 88 | void HoverShip::rotatePitch(const Vector2& value) { } |
---|
| 89 | |
---|
| 90 | /** |
---|
| 91 | @brief |
---|
[10929] | 92 | Removed, does nothing. |
---|
[10784] | 93 | @param value |
---|
| 94 | */ |
---|
| 95 | void HoverShip::rotateRoll(const Vector2& value) { } |
---|
| 96 | |
---|
[10929] | 97 | /** |
---|
| 98 | @brief |
---|
| 99 | Checks if the ship is touching the floor. The ship can only jump if there is contact with someting beneath it. |
---|
| 100 | */ |
---|
[10760] | 101 | bool HoverShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) |
---|
[10694] | 102 | { |
---|
[10784] | 103 | SpaceShip::collidesAgainst(otherObject, cs, contactPoint); |
---|
| 104 | //SUPER(HoverShip, collidesAgainst, otherObject, cs, contactPoint); |
---|
[10760] | 105 | |
---|
[10784] | 106 | if (contactPoint.m_normalWorldOnB.y() > 0.6 |
---|
| 107 | && this->getVelocity().y < 1) { |
---|
[10694] | 108 | this->isFloor_ = true; |
---|
[10784] | 109 | } else { |
---|
[10694] | 110 | this->isFloor_ = false; |
---|
[10784] | 111 | } |
---|
[10694] | 112 | |
---|
[12410] | 113 | if(otherObject->isA(Class(SpaceShip))) |
---|
| 114 | { |
---|
| 115 | removeHealth(0.2); |
---|
| 116 | } |
---|
| 117 | |
---|
[10694] | 118 | return false; |
---|
| 119 | } |
---|
| 120 | |
---|
[10929] | 121 | /** |
---|
| 122 | @brief |
---|
| 123 | Makes the ship jump |
---|
| 124 | @param bBoost |
---|
| 125 | */ |
---|
[10694] | 126 | void HoverShip::boost(bool bBoost) { |
---|
[10784] | 127 | if (bBoost && this->isFloor_) |
---|
[10694] | 128 | { |
---|
[10784] | 129 | this->setVelocity( |
---|
| 130 | this->getVelocity().x, |
---|
| 131 | jumpBoost_, |
---|
| 132 | this->getVelocity().z |
---|
| 133 | ); |
---|
[10694] | 134 | this->isFloor_ = false; |
---|
[10784] | 135 | } |
---|
[10694] | 136 | } |
---|
[10657] | 137 | } |
---|