Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain.older/src/util/multiplayer_team_deathmatch.h @ 10765

Last change on this file since 10765 was 9110, checked in by bensch, 18 years ago

orxonox/trunk: merged the Presentation back

File size: 3.1 KB
Line 
1
2/*!
3 * @file multiplayer_team_deathmatch.h
4 * Defines game rules for team deathmatch games
5 *
6 * currently there are only two teams supported
7 */
8
9#ifndef _MULTIPLAYER_TEAM_DEATHMATCH_H
10#define _MULTIPLAYER_TEAM_DEATHMATCH_H
11
12#include "network_game_rules.h"
13
14#include "glgui.h"
15#include "specials/glgui_notifier.h"
16
17class TiXmlElement;
18class ObjectManager;
19class Player;
20class ImagePlane;
21
22enum
23{
24  GAMESTATE_PRE_GAME = 0,
25  GAMESTATE_GAME,
26  GAMESTATE_POST_GAME
27};
28
29
30class MultiplayerTeamDeathmatch : public NetworkGameRules, public EventListener
31{
32
33  public:
34    MultiplayerTeamDeathmatch(const TiXmlElement* root = NULL);
35    virtual ~MultiplayerTeamDeathmatch();
36
37    virtual void loadParams(const TiXmlElement* root);
38
39    virtual int getTeamForNewUser();
40    virtual ClassID getPlayableClassId( int userId, int team );
41    virtual std::string getPlayableModelTextureFileName( int userId, int team, ClassID classId );
42    virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId );
43
44    virtual void registerSpawn( WorldEntity * we );
45
46    virtual void tick(float dt);
47    void draw();
48
49    inline void setDeathPenaltyTimeout(float time) { this->deathTimeout = time; }
50    inline void setMaxKills(int kills) { this->maxKills = kills; }
51   
52    inline void setNumTeams( int numTeams ){ this->numTeams = numTeams; }
53    inline int getNumTeams(){ return this->numTeams; }
54   
55    int getRandomTeam();
56   
57    virtual void process(const Event &event);
58   
59    void onKill( WorldEntity * victim, WorldEntity * killer );
60    void onRespawn( int userId );
61   
62    virtual void handleChatMessage( int userId, const std::string & message, int messageType );
63   
64    void respawnPlayable( Playable * playable, int teamId, float delay );
65
66  protected:
67    virtual void checkGameRules();
68
69  private:
70    bool               bLocalPlayerDead;           //!< true if the local player is dead
71    float              deathTimeout;               //!< timeout a player cannot play if he/she dies
72    float              timeout;                    //!< time counted if player dead
73    int                maxKills;                   //!< max kills for winning condition
74
75    int                numTeams;                   //!< number of teams
76
77    std::map<int,int>  teamScore;                  //!< team score
78
79    int                currentGameState;           //!< game state
80    float              gameStateTimer;             //!< if less than 0 -> change game state
81
82    bool               bShowTeamChange;            //!< if true -> show team change dialog
83
84    OrxGui::GLGuiBox* box;
85   
86    OrxGui::GLGuiInputLine* input;
87   
88    void calculateTeamScore();
89    void nextGameState();
90    void handleTeamChanges();
91    void teamChange( int userId );
92    void assignPlayable();
93   
94    void onButtonSpectator();
95    void onButtonRandom();
96    void onButtonTeam0();
97    void onButtonTeam1();
98    void onButtonCancel();
99    void onButtonExit();
100   
101    void onInputEnter( const std::string & text );
102   
103    OrxGui::GLGuiBox* statsBox;
104    OrxGui::GLGuiTable* table;
105    void tickStatsTable();
106   
107    void showStats();
108    void hideStats();
109};
110
111
112#endif /* _MULTIPLAYER_TEAM_DEATHMATCH_H */
Note: See TracBrowser for help on using the repository browser.