Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/util/multiplayer_team_deathmatch.h @ 8468

Last change on this file since 8468 was 8331, checked in by rennerc, 18 years ago

players can change teams while playing

File size: 2.6 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_box.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  protected:
61    virtual void checkGameRules();
62
63  private:
64    bool               bLocalPlayerDead;           //!< true if the local player is dead
65    float              deathTimeout;               //!< timeout a player cannot play if he/she dies
66    float              timeout;                    //!< time counted if player dead
67    int                maxKills;                   //!< max kills for winning condition
68
69    int                numTeams;                   //!< number of teams
70
71    std::map<int,int>  teamScore;                  //!< team score
72
73    ImagePlane*        deathScreen;                //!< the death screen
74
75    int                currentGameState;           //!< game state
76    float              gameStateTimer;             //!< if less than 0 -> change game state
77
78    bool               bShowTeamChange;            //!< if true -> show team change dialog
79
80    OrxGui::GLGuiBox* box;
81
82
83    void calculateTeamScore();
84    void nextGameState();
85    void handleTeamChanges();
86    void teamChange( int userId );
87    void assignPlayable();
88   
89    void onButtonSpectator();
90    void onButtonRandom();
91    void onButtonTeam0();
92    void onButtonTeam1();
93    void onButtonCancel();
94    void onButtonExit();
95};
96
97
98#endif /* _MULTIPLAYER_TEAM_DEATHMATCH_H */
Note: See TracBrowser for help on using the repository browser.