Orxonox  0.0.5 Codename: Arcturus
GametypeInfo.h
Go to the documentation of this file.
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  * Damian 'Mozork' Frick
26  *
27  */
28 
34 #ifndef _GametypeInfo_H__
35 #define _GametypeInfo_H__
36 
37 #include "OrxonoxPrereqs.h"
38 
39 #include <string>
40 
41 #include "Info.h"
42 
43 namespace orxonox
44 {
45 
56  {
57  friend class Gametype;
58 
59  public:
60  GametypeInfo(Context* context);
61  virtual ~GametypeInfo();
62 
67  inline bool hasStarted() const
68  { return this->bStarted_; }
69  void changedStarted(void); // Is called when the game has changed to started.
70 
75  inline bool hasEnded() const
76  { return this->bEnded_; }
77  void changedEnded(void); // Is called when the game has changed to ended.
78 
83  inline bool isStartCountdownRunning() const
84  { return this->bStartCountdownRunning_; }
85 
86  void changedStartCountdownRunning(void); // Is called when the start countdown has been either started or stopped.
87 
92  inline float getStartCountdown() const
93  { return this->startCountdown_; }
94 
100  inline unsigned int getStartCountdownCounter() const
101  { return this->counter_; }
102  void changedCountdownCounter(void); // Is called when the start countdown counter has changed.
103 
108  inline bool isReadyToSpawn() const
109  { return this->readyToSpawn_; }
110  void changedReadyToSpawn(bool ready); // Inform the GametypeInfo that the local player has changed its spawned status.
111 
116  inline bool isSpawned() const
117  { return this->spawned_; }
118  void changedSpawned(bool spawned); // Inform the GametypeInfo that the local player has changed its spawned status.
119 
120  inline const std::string& getHUDTemplate() const
121  { return this->hudtemplate_; }
122 
123  void sendAnnounceMessage(const std::string& message) const;
124  void sendAnnounceMessage(const std::string& message, unsigned int clientID) const;
125  void sendKillMessage(const std::string& message, unsigned int clientID) const;
126  void sendDeathMessage(const std::string& message, unsigned int clientID) const;
127  void sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour) const;
128  void sendFadingMessage(const std::string& message, unsigned int clientID) const;
129 
130  void dispatchAnnounceMessage(const std::string& message) const;
131  void dispatchKillMessage(const std::string& message) const;
132  void dispatchDeathMessage(const std::string& message) const;
133  void dispatchStaticMessage(const std::string& message,const ColourValue& colour) const;
134  void dispatchFadingMessage(const std::string& message) const;
135 
136  protected:
137  void start(void); // Inform the GametypeInfo that the game has started.
138  void end(void); // Inform the GametypeInfo that the game has ended.
139  void setStartCountdown(float countdown); // Set the start countdown to the input value.
140  void countdownStartCountdown(float countDown); // Count down the start countdown by the specified value.
141  void countDown(); // Count down the start countdown counter.
142  void startStartCountdown(void); // Inform the GametypeInfo about the start of the start countdown.
143  void stopStartCountdown(void); // Inform the GametypeInfo about the stop of the start countdown.
144  void playerReadyToSpawn(PlayerInfo* player); // Inform the GametypeInfo about a player that is ready to spawn.
145  void pawnKilled(PlayerInfo* player); // Inform the GametypeInfo about a player whose Pawn has been killed.
146  void playerSpawned(PlayerInfo* player); // Inform the GametypeInfo about a player that has spawned.
147  void playerEntered(PlayerInfo* player); // Inform the GametypeInfo about a player that has entered,
148 
149  inline void setHUDTemplate(const std::string& templateName)
150  { this->hudtemplate_ = templateName; };
151 
152  private:
153  void registerVariables();
154  void setSpawnedHelper(PlayerInfo* player, bool spawned); // Helper method. Sends changedReadyToSpawn notifiers over the network.
155  void setReadyToSpawnHelper(PlayerInfo* player, bool ready); // Helper method. Sends changedSpawned notifiers over the network.
156 
158 
159  bool bStarted_;
160  bool bEnded_;
163  unsigned int counter_;
165 
166  std::set<PlayerInfo*> spawnedPlayers_;
167  bool spawned_;
170  };
171 }
172 
173 #endif /* _GametypeInfo_H__ */
bool hasEnded() const
Get whether the game has ended yet.
Definition: GametypeInfo.h:75
static const std::string NOTIFICATION_SENDER
The name of the sender for the sending of notifications.
Definition: GametypeInfo.h:157
float startCountdown_
The current value of the start countdown.
Definition: GametypeInfo.h:162
bool spawned_
Whether the local Player is currently spawned.
Definition: GametypeInfo.h:167
bool readyToSpawn_
Whether the local Player is ready to spawn.
Definition: GametypeInfo.h:168
::std::string string
Definition: gtest-port.h:756
unsigned int getStartCountdownCounter() const
Get the current start countdown counter.
Definition: GametypeInfo.h:100
Output level, used for messages directed to the user (e.g. "Press any key to continue") ...
Definition: OutputDefinitions.h:89
Ogre::ColourValue colour(const btVector3 &color, btScalar alpha)
Definition: OgreBulletUtils.h:41
bool bEnded_
Whether the game has ended.
Definition: GametypeInfo.h:160
float getStartCountdown() const
Get the current value of the start countdown.
Definition: GametypeInfo.h:92
bool isFirstSpawn_
Definition: GametypeInfo.h:169
bool isSpawned() const
Get whether the local player is spawned.
Definition: GametypeInfo.h:116
Definition: Info.h:39
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
bool hasStarted() const
Get whether the game has started yet.
Definition: GametypeInfo.h:67
Definition: Gametype.h:63
const std::string & getHUDTemplate() const
Definition: GametypeInfo.h:120
std::set< PlayerInfo * > spawnedPlayers_
A set of players that are currently spawned.
Definition: GametypeInfo.h:166
Shared library macros, enums, constants and forward declarations for the orxonox library ...
unsigned int counter_
The current integer value of the start countdown, the start countdown counter.
Definition: GametypeInfo.h:163
Definition: Context.h:45
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
bool isReadyToSpawn() const
Get whether the local player is ready to spawn.
Definition: GametypeInfo.h:108
void setHUDTemplate(const std::string &templateName)
Definition: GametypeInfo.h:149
bool bStartCountdownRunning_
Whether the start countdown is running.
Definition: GametypeInfo.h:161
bool bStarted_
Whether the game has started,.
Definition: GametypeInfo.h:159
bool isStartCountdownRunning() const
Get whether the start countdown is currently running.
Definition: GametypeInfo.h:83
The GametypeInfo class keeps track of the state of the game and provides facilities to inform the pla...
Definition: GametypeInfo.h:55
Definition: PlayerInfo.h:39
std::string hudtemplate_
Definition: GametypeInfo.h:164