[10078] | 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 | * Fabien Vultier |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | @file JumpScore.cc |
---|
| 31 | @brief HUD of thejump minigame. If showScore_ is set, it displays the score. If showMessages_ is set, it displays the game over message. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | #include "JumpScore.h" |
---|
| 35 | #include "core/CoreIncludes.h" |
---|
| 36 | #include "core/XMLPort.h" |
---|
| 37 | #include "util/Convert.h" |
---|
| 38 | #include "infos/PlayerInfo.h" |
---|
| 39 | #include "Jump.h" |
---|
| 40 | #include "sound/WorldSound.h" |
---|
| 41 | |
---|
| 42 | namespace orxonox |
---|
| 43 | { |
---|
| 44 | RegisterClass(JumpScore); |
---|
| 45 | |
---|
| 46 | JumpScore::JumpScore(Context* context) : OverlayText(context) |
---|
| 47 | { |
---|
| 48 | RegisterObject(JumpScore); |
---|
| 49 | |
---|
| 50 | owner_ = NULL; |
---|
| 51 | showScore_ = false; |
---|
[10260] | 52 | showFuel_ = false; |
---|
[10078] | 53 | showMessages_ = false; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | JumpScore::~JumpScore() |
---|
| 57 | { |
---|
| 58 | |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | void JumpScore::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 62 | { |
---|
| 63 | SUPER(JumpScore, XMLPort, xmlelement, mode); |
---|
| 64 | |
---|
| 65 | XMLPortParam(JumpScore, "showScore", setShowScore, getShowScore, xmlelement, mode); |
---|
[10260] | 66 | XMLPortParam(JumpScore, "showFuel", setShowFuel, getShowFuel, xmlelement, mode); |
---|
[10078] | 67 | XMLPortParam(JumpScore, "showMessages", setShowMessages, getShowMessages, xmlelement, mode); |
---|
| 68 | XMLPortParam(JumpScore, "gameOverText", setGameOverText, getGameOverText, xmlelement, mode); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | void JumpScore::tick(float dt) |
---|
| 72 | { |
---|
| 73 | SUPER(JumpScore, tick, dt); |
---|
| 74 | |
---|
| 75 | if (owner_ != NULL) |
---|
| 76 | { |
---|
| 77 | if (!owner_->hasEnded()) |
---|
| 78 | { |
---|
| 79 | player_ = owner_->getPlayer(); |
---|
| 80 | |
---|
| 81 | if (player_ != NULL) |
---|
| 82 | { |
---|
[10215] | 83 | if (showScore_ == true) |
---|
| 84 | { |
---|
| 85 | int score = owner_->getScore(player_); |
---|
[10078] | 86 | |
---|
[10215] | 87 | std::string str = multi_cast<std::string>(score); |
---|
| 88 | setCaption(str); |
---|
| 89 | } |
---|
[10260] | 90 | else if (showFuel_ == true) |
---|
| 91 | { |
---|
| 92 | float fuel = owner_->getFuel(); |
---|
| 93 | std::string str; |
---|
| 94 | |
---|
| 95 | if (fuel <= 0.0) |
---|
| 96 | { |
---|
| 97 | str = ""; |
---|
| 98 | } |
---|
| 99 | else |
---|
| 100 | { |
---|
| 101 | str = multi_cast<std::string>(fuel); |
---|
| 102 | } |
---|
| 103 | setCaption(str); |
---|
| 104 | } |
---|
[10215] | 105 | else if (showMessages_ == true) |
---|
| 106 | { |
---|
| 107 | setCaption(owner_->getDead(player_) == true ? gameOverText_ : ""); |
---|
| 108 | } |
---|
[10078] | 109 | } |
---|
| 110 | } |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | void JumpScore::changedOwner() |
---|
| 115 | { |
---|
| 116 | SUPER(JumpScore, changedOwner); |
---|
| 117 | |
---|
| 118 | if (this->getOwner() != NULL && this->getOwner()->getGametype()) |
---|
| 119 | { |
---|
[10624] | 120 | this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype()); |
---|
[10078] | 121 | } |
---|
| 122 | else |
---|
| 123 | { |
---|
| 124 | this->owner_ = NULL; |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | } |
---|