| [10114] | 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 "DodgeRaceHUDinfo.h" |
|---|
| 28 | |
|---|
| 29 | #include "core/CoreIncludes.h" |
|---|
| 30 | #include "core/XMLPort.h" |
|---|
| 31 | #include "util/Convert.h" |
|---|
| [10117] | 32 | //#include "DodgeRace.h" |
|---|
| [10114] | 33 | |
|---|
| 34 | namespace orxonox |
|---|
| 35 | { |
|---|
| 36 | RegisterClass(DodgeRaceHUDinfo); |
|---|
| 37 | |
|---|
| 38 | DodgeRaceHUDinfo::DodgeRaceHUDinfo(Context* context) : OverlayText(context) |
|---|
| 39 | { |
|---|
| 40 | RegisterObject(DodgeRaceHUDinfo); |
|---|
| [10124] | 41 | |
|---|
| [11071] | 42 | this->DodgeRaceGame = nullptr; |
|---|
| [10166] | 43 | this->bShowPoints_ = true; |
|---|
| [10114] | 44 | } |
|---|
| [10166] | 45 | |
|---|
| [10114] | 46 | void DodgeRaceHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
|---|
| 47 | { |
|---|
| 48 | SUPER(DodgeRaceHUDinfo, XMLPort, xmlelement, mode); |
|---|
| 49 | |
|---|
| [10166] | 50 | XMLPortParam(DodgeRaceHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); |
|---|
| [10114] | 51 | } |
|---|
| 52 | |
|---|
| 53 | void DodgeRaceHUDinfo::tick(float dt) |
|---|
| 54 | { |
|---|
| 55 | SUPER(DodgeRaceHUDinfo, tick, dt); |
|---|
| 56 | |
|---|
| [10166] | 57 | |
|---|
| [10236] | 58 | if(this->bShowPoints_) |
|---|
| 59 | { |
|---|
| 60 | const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints()); |
|---|
| 61 | if (this->DodgeRaceGame->lives <= 0) |
|---|
| 62 | { |
|---|
| 63 | setTextSize(0.2); |
|---|
| 64 | setPosition(Vector2(0.1, 0.02)); |
|---|
| 65 | this->setCaption("Final score:\n" + points); |
|---|
| 66 | this->setColour(ColourValue(1, 0, 0, 1)); |
|---|
| 67 | } |
|---|
| 68 | else |
|---|
| 69 | { |
|---|
| 70 | setTextSize(0.04); |
|---|
| 71 | setPosition(Vector2(0.14, 0.02)); |
|---|
| 72 | this->setColour(ColourValue(1, 1, 1, 1)); |
|---|
| 73 | this->setCaption(points); |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| [10114] | 76 | } |
|---|
| 77 | |
|---|
| 78 | void DodgeRaceHUDinfo::changedOwner() |
|---|
| 79 | { |
|---|
| 80 | SUPER(DodgeRaceHUDinfo, changedOwner); |
|---|
| 81 | |
|---|
| 82 | if (this->getOwner() && this->getOwner()->getGametype()) |
|---|
| 83 | { |
|---|
| [10624] | 84 | this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype()); |
|---|
| [10114] | 85 | } |
|---|
| 86 | else |
|---|
| 87 | { |
|---|
| [11071] | 88 | this->DodgeRaceGame = nullptr; |
|---|
| [10114] | 89 | } |
|---|
| [10166] | 90 | } |
|---|
| [10114] | 91 | } |
|---|