Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/skybox2/src/modules/overlays/hud/GametypeStatus.cc @ 6772

Last change on this file since 6772 was 6772, checked in by gionc, 14 years ago

update Skybox Generator

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