[2428] | 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 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "GametypeStatus.h" |
---|
| 30 | |
---|
[3196] | 31 | #include "util/Convert.h" |
---|
[2428] | 32 | #include "core/CoreIncludes.h" |
---|
[7204] | 33 | #include "core/command/ConsoleCommand.h" |
---|
[5735] | 34 | #include "infos/GametypeInfo.h" |
---|
| 35 | #include "infos/PlayerInfo.h" |
---|
| 36 | #include "worldentities/ControllableEntity.h" |
---|
| 37 | #include "worldentities/pawns/Spectator.h" |
---|
[2428] | 38 | |
---|
| 39 | namespace orxonox |
---|
| 40 | { |
---|
| 41 | CreateFactory(GametypeStatus); |
---|
| 42 | |
---|
[7163] | 43 | /*static*/ bool GametypeStatus::noCaption_s = false; |
---|
| 44 | SetConsoleCommand(GametypeStatus, setGametypeStatus, true); |
---|
| 45 | |
---|
[2428] | 46 | GametypeStatus::GametypeStatus(BaseObject* creator) : OverlayText(creator) |
---|
| 47 | { |
---|
| 48 | RegisterObject(GametypeStatus); |
---|
| 49 | |
---|
| 50 | this->owner_ = 0; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | GametypeStatus::~GametypeStatus() |
---|
| 54 | { |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | void GametypeStatus::tick(float dt) |
---|
| 58 | { |
---|
| 59 | SUPER(GametypeStatus, tick, dt); |
---|
| 60 | |
---|
[2973] | 61 | if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->getControllableEntity()) |
---|
[2428] | 62 | { |
---|
| 63 | const GametypeInfo* gtinfo = this->owner_->getGametypeInfo(); |
---|
[2973] | 64 | ControllableEntity* ce = this->owner_->getControllableEntity(); |
---|
[2428] | 65 | |
---|
[7163] | 66 | if(GametypeStatus::noCaption_s) // No captions are displayed. |
---|
| 67 | { |
---|
| 68 | this->setCaption(""); |
---|
| 69 | return; |
---|
| 70 | } |
---|
| 71 | |
---|
[2428] | 72 | if (!gtinfo->hasStarted() && !gtinfo->isStartCountdownRunning()) |
---|
| 73 | { |
---|
[2973] | 74 | if (!this->owner_->isReadyToSpawn()) |
---|
[2428] | 75 | this->setCaption("Press [Fire] to start the match"); |
---|
| 76 | else |
---|
| 77 | this->setCaption("Waiting for other players"); |
---|
| 78 | } |
---|
| 79 | else if (!gtinfo->hasEnded()) |
---|
| 80 | { |
---|
| 81 | if (gtinfo->isStartCountdownRunning()) |
---|
[3300] | 82 | this->setCaption(multi_cast<std::string>(static_cast<int>(ceil(gtinfo->getStartCountdown())))); |
---|
[2973] | 83 | else if (ce->isA(Class(Spectator))) |
---|
[2428] | 84 | this->setCaption("Press [Fire] to respawn"); |
---|
| 85 | else |
---|
| 86 | this->setCaption(""); |
---|
| 87 | } |
---|
| 88 | else |
---|
| 89 | this->setCaption("Game has ended"); |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | void GametypeStatus::changedOwner() |
---|
| 95 | { |
---|
| 96 | SUPER(GametypeStatus, changedOwner); |
---|
| 97 | |
---|
[3325] | 98 | this->owner_ = orxonox_cast<PlayerInfo*>(this->getOwner()); |
---|
[2428] | 99 | } |
---|
[7163] | 100 | |
---|
| 101 | /** |
---|
| 102 | @brief |
---|
| 103 | Sets whether the gametype status is displayed. |
---|
| 104 | @param bValue |
---|
| 105 | If true captions are displayed, if false, not. |
---|
| 106 | */ |
---|
| 107 | /*static*/ void GametypeStatus::setGametypeStatus(bool bValue) |
---|
| 108 | { |
---|
| 109 | GametypeStatus::noCaption_s = !bValue; |
---|
| 110 | } |
---|
| 111 | |
---|
[2428] | 112 | } |
---|