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 | |
---|
31 | #include "util/Convert.h" |
---|
32 | #include "core/CoreIncludes.h" |
---|
33 | #include "infos/GametypeInfo.h" |
---|
34 | #include "infos/PlayerInfo.h" |
---|
35 | #include "worldentities/ControllableEntity.h" |
---|
36 | #include "worldentities/pawns/Spectator.h" |
---|
37 | |
---|
38 | namespace orxonox |
---|
39 | { |
---|
40 | CreateFactory(GametypeStatus); |
---|
41 | |
---|
42 | GametypeStatus::GametypeStatus(BaseObject* creator) : OverlayText(creator) |
---|
43 | { |
---|
44 | RegisterObject(GametypeStatus); |
---|
45 | |
---|
46 | this->owner_ = 0; |
---|
47 | } |
---|
48 | |
---|
49 | GametypeStatus::~GametypeStatus() |
---|
50 | { |
---|
51 | } |
---|
52 | |
---|
53 | void GametypeStatus::tick(float dt) |
---|
54 | { |
---|
55 | SUPER(GametypeStatus, tick, dt); |
---|
56 | |
---|
57 | if (this->owner_ && this->owner_->getGametypeInfo() && this->owner_->getControllableEntity()) |
---|
58 | { |
---|
59 | const GametypeInfo* gtinfo = this->owner_->getGametypeInfo(); |
---|
60 | ControllableEntity* ce = this->owner_->getControllableEntity(); |
---|
61 | |
---|
62 | if (!gtinfo->hasStarted() && !gtinfo->isStartCountdownRunning()) |
---|
63 | { |
---|
64 | if (!this->owner_->isReadyToSpawn()) |
---|
65 | this->setCaption("Press [Fire] to start the match"); |
---|
66 | else |
---|
67 | this->setCaption("Waiting for other players"); |
---|
68 | } |
---|
69 | else if (!gtinfo->hasEnded()) |
---|
70 | { |
---|
71 | if (gtinfo->isStartCountdownRunning()) |
---|
72 | this->setCaption(multi_cast<std::string>(static_cast<int>(ceil(gtinfo->getStartCountdown())))); |
---|
73 | else if (ce->isA(Class(Spectator))) |
---|
74 | this->setCaption("Press [Fire] to respawn"); |
---|
75 | else |
---|
76 | this->setCaption(""); |
---|
77 | } |
---|
78 | else |
---|
79 | this->setCaption("Game has ended"); |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | |
---|
84 | void GametypeStatus::changedOwner() |
---|
85 | { |
---|
86 | SUPER(GametypeStatus, changedOwner); |
---|
87 | |
---|
88 | this->owner_ = orxonox_cast<PlayerInfo*>(this->getOwner()); |
---|
89 | } |
---|
90 | } |
---|