[11503] | 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 | * Florian Zinggeler |
---|
| 24 | * |
---|
| 25 | */ |
---|
| 26 | |
---|
| 27 | #include "FlappyOrxHUDinfo.h" |
---|
| 28 | |
---|
| 29 | #include "core/CoreIncludes.h" |
---|
| 30 | #include "core/XMLPort.h" |
---|
| 31 | #include "util/Convert.h" |
---|
| 32 | #include "FlappyOrx.h" |
---|
| 33 | |
---|
| 34 | namespace orxonox |
---|
| 35 | { |
---|
| 36 | RegisterClass(FlappyOrxHUDinfo); |
---|
| 37 | |
---|
| 38 | FlappyOrxHUDinfo::FlappyOrxHUDinfo(Context* context) : OverlayText(context) |
---|
| 39 | { |
---|
| 40 | RegisterObject(FlappyOrxHUDinfo); |
---|
| 41 | |
---|
| 42 | this->FlappyOrxGame = nullptr; |
---|
| 43 | this->bShowLives_ = false; |
---|
[11533] | 44 | this->bShowLevel_ = true; |
---|
[11503] | 45 | this->bShowPoints_ = false; |
---|
| 46 | this->bShowMultiplier_ = false; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | void FlappyOrxHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 50 | { |
---|
| 51 | SUPER(FlappyOrxHUDinfo, XMLPort, xmlelement, mode); |
---|
| 52 | |
---|
[11533] | 53 | XMLPortParam(FlappyOrxHUDinfo, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false); |
---|
| 54 | XMLPortParam(FlappyOrxHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); |
---|
| 55 | |
---|
| 56 | |
---|
[11503] | 57 | } |
---|
| 58 | |
---|
| 59 | void FlappyOrxHUDinfo::tick(float dt) |
---|
| 60 | { |
---|
| 61 | SUPER(FlappyOrxHUDinfo, tick, dt); |
---|
| 62 | |
---|
| 63 | if (this->FlappyOrxGame) |
---|
| 64 | { |
---|
[11533] | 65 | // if (this->bShowLives_) //preperation for easy mode |
---|
[11521] | 66 | // { |
---|
[11533] | 67 | // const std::string& lives = multi_cast<std::string>(this->InvaderGame->getLives()); |
---|
[11521] | 68 | // this->setCaption(lives); |
---|
| 69 | // } |
---|
| 70 | if(this->bShowPoints_) |
---|
[11503] | 71 | { |
---|
| 72 | const std::string& points = multi_cast<std::string>(this->FlappyOrxGame->getPoints()); |
---|
| 73 | if (this->FlappyOrxGame->lives <= 0) |
---|
| 74 | { |
---|
| 75 | setTextSize(0.2); |
---|
[11533] | 76 | setPosition(Vector2(0.1, 0.02)); |
---|
[11503] | 77 | this->setCaption("Final score:\n" + points); |
---|
| 78 | this->setColour(ColourValue(1, 0, 0, 1)); |
---|
| 79 | } |
---|
| 80 | else |
---|
| 81 | { |
---|
| 82 | setTextSize(0.04); |
---|
[11533] | 83 | setPosition(Vector2(0.14, 0.02)); |
---|
[11503] | 84 | this->setColour(ColourValue(1, 1, 1, 1)); |
---|
| 85 | this->setCaption(points); |
---|
| 86 | } |
---|
| 87 | } |
---|
[11533] | 88 | |
---|
[11503] | 89 | } |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | void FlappyOrxHUDinfo::changedOwner() |
---|
| 93 | { |
---|
| 94 | SUPER(FlappyOrxHUDinfo, changedOwner); |
---|
| 95 | |
---|
| 96 | if (this->getOwner() && this->getOwner()->getGametype()) |
---|
| 97 | { |
---|
| 98 | this->FlappyOrxGame = orxonox_cast<FlappyOrx*>(this->getOwner()->getGametype()); |
---|
| 99 | } |
---|
| 100 | else |
---|
| 101 | { |
---|
| 102 | this->FlappyOrxGame = nullptr; |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | } |
---|