Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/util/multiplayer_team_deathmatch.h @ 10768

Last change on this file since 10768 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 3.2 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  ObjectListDeclaration(MultiplayerTeamDeathmatch);
33
34  public:
35    MultiplayerTeamDeathmatch(const TiXmlElement* root = NULL);
36    virtual ~MultiplayerTeamDeathmatch();
37
38    virtual void loadParams(const TiXmlElement* root);
39
40    virtual int getTeamForNewUser();
41    virtual ClassID getPlayableClassId( int userId, int team );
42    virtual std::string getPlayableModelTextureFileName( int userId, int team, const ClassID& classId );
43    virtual std::string getPlayableModelFileName( int userId, int team, const ClassID& classId );
44    virtual float getPlayableScale( int userId, int team, const ClassID& classId );
45
46    virtual void registerSpawn( WorldEntity * we );
47
48    virtual void tick(float dt);
49    void draw();
50
51    inline void setDeathPenaltyTimeout(float time) { this->deathTimeout = time; }
52    inline void setMaxKills(int kills) { this->maxKills = kills; }
53
54    inline void setNumTeams( int numTeams ){ this->numTeams = numTeams; }
55    inline int getNumTeams(){ return this->numTeams; }
56
57    int getRandomTeam();
58
59    virtual void process(const Event &event);
60
61    void onKill( WorldEntity * victim, WorldEntity * killer );
62    void onRespawn( int userId );
63
64    virtual void handleChatMessage( int userId, const std::string & message, int messageType );
65
66    void respawnPlayable( Playable * playable, int teamId, float delay );
67
68  protected:
69    virtual void checkGameRules();
70
71  private:
72    bool               bLocalPlayerDead;           //!< true if the local player is dead
73    float              deathTimeout;               //!< timeout a player cannot play if he/she dies
74    float              timeout;                    //!< time counted if player dead
75    int                maxKills;                   //!< max kills for winning condition
76
77    int                numTeams;                   //!< number of teams
78
79    std::map<int,int>  teamScore;                  //!< team score
80
81    int                currentGameState;           //!< game state
82    float              gameStateTimer;             //!< if less than 0 -> change game state
83
84    bool               bShowTeamChange;            //!< if true -> show team change dialog
85
86    OrxGui::GLGuiBox* box;
87
88    OrxGui::GLGuiInputLine* input;
89
90    void calculateTeamScore();
91    void nextGameState();
92    void handleTeamChanges();
93    void teamChange( int userId );
94    void assignPlayable();
95
96    void onButtonSpectator();
97    void onButtonRandom();
98    void onButtonTeam0();
99    void onButtonTeam1();
100    void onButtonCancel();
101    void onButtonExit();
102
103    void onInputEnter( const std::string & text );
104
105    OrxGui::GLGuiBox* statsBox;
106    OrxGui::GLGuiTable* table;
107    void tickStatsTable();
108
109    void showStats();
110    void hideStats();
111};
112
113
114#endif /* _MULTIPLAYER_TEAM_DEATHMATCH_H */
Note: See TracBrowser for help on using the repository browser.