[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 | |
---|
[10114] | 42 | this->DodgeRaceGame = 0; |
---|
| 43 | this->bShowLives_ = false; |
---|
| 44 | this->bShowLevel_ = false; |
---|
| 45 | this->bShowPoints_ = false; |
---|
[10124] | 46 | this->bShowMultiplier_ = false; |
---|
[10114] | 47 | } |
---|
[10118] | 48 | /* |
---|
[10114] | 49 | void DodgeRaceHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 50 | { |
---|
| 51 | SUPER(DodgeRaceHUDinfo, XMLPort, xmlelement, mode); |
---|
| 52 | |
---|
| 53 | XMLPortParam(DodgeRaceHUDinfo, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false); |
---|
| 54 | XMLPortParam(DodgeRaceHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); |
---|
| 55 | XMLPortParam(DodgeRaceHUDinfo, "showLevel", setShowLevel, getShowLevel, xmlelement, mode).defaultValues(false); |
---|
| 56 | XMLPortParam(DodgeRaceHUDinfo, "showMultiplier", setShowMultiplier, getShowMultiplier, xmlelement, mode).defaultValues(false); |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | void DodgeRaceHUDinfo::tick(float dt) |
---|
| 60 | { |
---|
| 61 | SUPER(DodgeRaceHUDinfo, tick, dt); |
---|
| 62 | |
---|
| 63 | if (this->DodgeRaceGame) |
---|
| 64 | { |
---|
| 65 | if (this->bShowLives_) |
---|
| 66 | { |
---|
| 67 | const std::string& lives = multi_cast<std::string>(this->DodgeRaceGame->getLives()); |
---|
| 68 | this->setCaption(lives); |
---|
| 69 | } |
---|
| 70 | else if(this->bShowLevel_) |
---|
| 71 | { |
---|
| 72 | const std::string& Level = multi_cast<std::string>(this->DodgeRaceGame->getLevel()); |
---|
| 73 | if (this->DodgeRaceGame->lives <= 0) |
---|
| 74 | { |
---|
| 75 | setPosition(Vector2(0.1, 0.65)); |
---|
| 76 | this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!"); |
---|
| 77 | setTextSize(0.05); |
---|
| 78 | this->DodgeRaceGame->bEndGame = true; |
---|
| 79 | } |
---|
| 80 | else if (this->DodgeRaceGame->bShowLevel) |
---|
| 81 | { |
---|
| 82 | setTextSize(0.1); |
---|
| 83 | setPosition(Vector2(0.3, 0.55)); |
---|
| 84 | std::stringstream sstm; |
---|
| 85 | sstm << "Level " << Level; |
---|
| 86 | this->setCaption(sstm.str()); // + level |
---|
| 87 | } |
---|
| 88 | else |
---|
| 89 | { |
---|
| 90 | setTextSize(0.04); |
---|
| 91 | setPosition(Vector2(0.14, 0.055)); |
---|
| 92 | this->setCaption(Level); |
---|
| 93 | } |
---|
| 94 | } |
---|
| 95 | else if(this->bShowPoints_) |
---|
| 96 | { |
---|
| 97 | const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints()); |
---|
| 98 | if (this->DodgeRaceGame->lives <= 0) |
---|
| 99 | { |
---|
| 100 | setTextSize(0.2); |
---|
| 101 | setPosition(Vector2(0.1, 0.25)); |
---|
| 102 | this->setCaption("Final score:\n" + points); |
---|
| 103 | this->setColour(ColourValue(1, 0, 0, 1)); |
---|
| 104 | } |
---|
| 105 | else |
---|
| 106 | { |
---|
| 107 | setTextSize(0.04); |
---|
| 108 | setPosition(Vector2(0.14, 0.1)); |
---|
| 109 | this->setColour(ColourValue(1, 1, 1, 1)); |
---|
| 110 | this->setCaption(points); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | else if(this->bShowMultiplier_) |
---|
| 114 | { |
---|
| 115 | int mult = this->DodgeRaceGame->getMultiplier(); |
---|
| 116 | const std::string& Multiplier = "X " + multi_cast<std::string>(mult); |
---|
| 117 | this->setCaption(Multiplier); |
---|
| 118 | this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f))); |
---|
| 119 | this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01f + 0.04f); |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | void DodgeRaceHUDinfo::changedOwner() |
---|
| 125 | { |
---|
| 126 | SUPER(DodgeRaceHUDinfo, changedOwner); |
---|
| 127 | |
---|
| 128 | if (this->getOwner() && this->getOwner()->getGametype()) |
---|
| 129 | { |
---|
| 130 | this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype().get()); |
---|
| 131 | } |
---|
| 132 | else |
---|
| 133 | { |
---|
| 134 | this->DodgeRaceGame = 0; |
---|
| 135 | } |
---|
[10118] | 136 | }*/ |
---|
[10114] | 137 | } |
---|