| 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; |
|---|
| 52 | showMessages_ = false; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | JumpScore::~JumpScore() |
|---|
| 56 | { |
|---|
| 57 | |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | void JumpScore::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
|---|
| 61 | { |
|---|
| 62 | SUPER(JumpScore, XMLPort, xmlelement, mode); |
|---|
| 63 | |
|---|
| 64 | XMLPortParam(JumpScore, "showScore", setShowScore, getShowScore, xmlelement, mode); |
|---|
| 65 | XMLPortParam(JumpScore, "showMessages", setShowMessages, getShowMessages, xmlelement, mode); |
|---|
| 66 | XMLPortParam(JumpScore, "gameOverText", setGameOverText, getGameOverText, xmlelement, mode); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | void JumpScore::tick(float dt) |
|---|
| 70 | { |
|---|
| 71 | SUPER(JumpScore, tick, dt); |
|---|
| 72 | |
|---|
| 73 | if (owner_ != NULL) |
|---|
| 74 | { |
|---|
| 75 | if (!owner_->hasEnded()) |
|---|
| 76 | { |
|---|
| 77 | player_ = owner_->getPlayer(); |
|---|
| 78 | |
|---|
| 79 | if (player_ != NULL) |
|---|
| 80 | { |
|---|
| 81 | if (showScore_ == true) |
|---|
| 82 | { |
|---|
| 83 | int score = owner_->getScore(player_); |
|---|
| 84 | |
|---|
| 85 | std::string str = multi_cast<std::string>(score); |
|---|
| 86 | setCaption(str); |
|---|
| 87 | } |
|---|
| 88 | else if (showMessages_ == true) |
|---|
| 89 | { |
|---|
| 90 | |
|---|
| 91 | setCaption(owner_->getDead(player_) == true ? gameOverText_ : ""); |
|---|
| 92 | } |
|---|
| 93 | } |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | void JumpScore::changedOwner() |
|---|
| 99 | { |
|---|
| 100 | SUPER(JumpScore, changedOwner); |
|---|
| 101 | |
|---|
| 102 | if (this->getOwner() != NULL && this->getOwner()->getGametype()) |
|---|
| 103 | { |
|---|
| 104 | this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype().get()); |
|---|
| 105 | } |
|---|
| 106 | else |
|---|
| 107 | { |
|---|
| 108 | this->owner_ = NULL; |
|---|
| 109 | } |
|---|
| 110 | } |
|---|
| 111 | } |
|---|