Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8697 was 8623, checked in by bensch, 18 years ago

orxonox/trunk: merged the network branche back here
merged with command:
svn merge -r8230:HEAD https://svn.orxonox.net/orxonox/branches/network .
conflicts resolved in favour of the network branche (conflicts were in network)

File size: 2.7 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
16class TiXmlElement;
17class ObjectManager;
18class Player;
19class ImagePlane;
20
21enum
22{
23  GAMESTATE_PRE_GAME = 0,
24  GAMESTATE_GAME,
25  GAMESTATE_POST_GAME
26};
27
28
29class MultiplayerTeamDeathmatch : public NetworkGameRules, public EventListener
30{
31
32  public:
33    MultiplayerTeamDeathmatch(const TiXmlElement* root = NULL);
34    virtual ~MultiplayerTeamDeathmatch();
35
36    virtual void loadParams(const TiXmlElement* root);
37
38    virtual int getTeamForNewUser();
39    virtual ClassID getPlayableClassId( int userId, int team );
40    virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId );
41
42    virtual void onPlayerSpawn();
43    virtual void onPlayerDeath();
44
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    void setDeathScreen(const std::string& imageName);
52   
53    inline void setNumTeams( int numTeams ){ this->numTeams = numTeams; }
54    inline int getNumTeams(){ return this->numTeams; }
55   
56    int getRandomTeam();
57   
58    virtual void process(const Event &event);
59   
60    virtual void handleChatMessage( int userId, const std::string & message, int messageType );
61
62  protected:
63    virtual void checkGameRules();
64
65  private:
66    bool               bLocalPlayerDead;           //!< true if the local player is dead
67    float              deathTimeout;               //!< timeout a player cannot play if he/she dies
68    float              timeout;                    //!< time counted if player dead
69    int                maxKills;                   //!< max kills for winning condition
70
71    int                numTeams;                   //!< number of teams
72
73    std::map<int,int>  teamScore;                  //!< team score
74
75    ImagePlane*        deathScreen;                //!< the death screen
76
77    int                currentGameState;           //!< game state
78    float              gameStateTimer;             //!< if less than 0 -> change game state
79
80    bool               bShowTeamChange;            //!< if true -> show team change dialog
81
82    OrxGui::GLGuiBox* box;
83   
84    void calculateTeamScore();
85    void nextGameState();
86    void handleTeamChanges();
87    void teamChange( int userId );
88    void assignPlayable();
89   
90    void onButtonSpectator();
91    void onButtonRandom();
92    void onButtonTeam0();
93    void onButtonTeam1();
94    void onButtonCancel();
95    void onButtonExit();
96};
97
98
99#endif /* _MULTIPLAYER_TEAM_DEATHMATCH_H */
Note: See TracBrowser for help on using the repository browser.