[3104] | 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 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "UnderAttackHealthBar.h" |
---|
| 30 | |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
| 32 | #include "core/XMLPort.h" |
---|
| 33 | #include "objects/infos/PlayerInfo.h" |
---|
| 34 | #include "objects/gametypes/UnderAttack.h" |
---|
| 35 | #include "objects/worldentities/pawns/Destroyer.h" |
---|
| 36 | |
---|
| 37 | namespace orxonox |
---|
| 38 | { |
---|
| 39 | CreateFactory(UnderAttackHealthBar); |
---|
| 40 | |
---|
| 41 | UnderAttackHealthBar::UnderAttackHealthBar(BaseObject* creator) : HUDHealthBar(creator) |
---|
| 42 | { |
---|
| 43 | RegisterObject(UnderAttackHealthBar); |
---|
| 44 | |
---|
| 45 | this->owner_ = 0; |
---|
| 46 | |
---|
| 47 | this->text_ = new OverlayText(this); |
---|
| 48 | this->text_->setFont("Monofur"); |
---|
[3196] | 49 | this->text_->setTextSize(0.04f); |
---|
[3104] | 50 | this->text_->setAlignmentString("center"); |
---|
| 51 | this->text_->setColour(ColourValue::White); |
---|
| 52 | this->text_->setPickPoint(Vector2(0.5, 0)); |
---|
| 53 | |
---|
| 54 | this->inittimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&UnderAttackHealthBar::init))); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | UnderAttackHealthBar::~UnderAttackHealthBar() |
---|
| 58 | { |
---|
| 59 | if (this->isInitialized()) |
---|
| 60 | delete this->text_; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | void UnderAttackHealthBar::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 64 | { |
---|
| 65 | SUPER(UnderAttackHealthBar, XMLPort, xmlelement, mode); |
---|
| 66 | |
---|
| 67 | XMLPortParam(UnderAttackHealthBar, "descriptionpickpoint", setDescriptionPickPoint, getDescriptionPickPoint, xmlelement, mode); |
---|
| 68 | XMLPortParam(UnderAttackHealthBar, "descriptionoffset", setDescriptionOffset, getDescriptionOffset, xmlelement, mode); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | void UnderAttackHealthBar::changedOwner() |
---|
| 72 | { |
---|
| 73 | SUPER(UnderAttackHealthBar, changedOwner); |
---|
| 74 | |
---|
| 75 | PlayerInfo* player = dynamic_cast<PlayerInfo*>(this->getOwner()); |
---|
| 76 | if (player) |
---|
| 77 | { |
---|
| 78 | this->owner_ = player; |
---|
| 79 | |
---|
| 80 | UnderAttack* ua = dynamic_cast<UnderAttack*>(player->getGametype()); |
---|
| 81 | if (ua) |
---|
| 82 | { |
---|
| 83 | this->setOwner(ua->getDestroyer()); |
---|
| 84 | |
---|
| 85 | if (ua->getTeam(player) == 0) |
---|
| 86 | this->text_->setCaption("Attack the Transporter!"); |
---|
| 87 | else |
---|
| 88 | this->text_->setCaption("Defend the Transporter!"); |
---|
| 89 | } |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | void UnderAttackHealthBar::init() |
---|
| 94 | { |
---|
| 95 | this->setOwner(this->owner_); |
---|
| 96 | } |
---|
| 97 | } |
---|