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 | |
---|
15 | class TiXmlElement; |
---|
16 | class ObjectManager; |
---|
17 | class Player; |
---|
18 | class ImagePlane; |
---|
19 | |
---|
20 | enum |
---|
21 | { |
---|
22 | GAMESTATE_PRE_GAME = 0, |
---|
23 | GAMESTATE_GAME, |
---|
24 | GAMESTATE_POST_GAME |
---|
25 | }; |
---|
26 | |
---|
27 | |
---|
28 | class MultiplayerTeamDeathmatch : public NetworkGameRules |
---|
29 | { |
---|
30 | |
---|
31 | public: |
---|
32 | MultiplayerTeamDeathmatch(const TiXmlElement* root = NULL); |
---|
33 | virtual ~MultiplayerTeamDeathmatch(); |
---|
34 | |
---|
35 | virtual void loadParams(const TiXmlElement* root); |
---|
36 | |
---|
37 | virtual int getTeamForNewUser(); |
---|
38 | virtual ClassID getPlayableClassId( int team ); |
---|
39 | virtual std::string getPlayableModelFileName( int team, ClassID classId ); |
---|
40 | |
---|
41 | virtual void onPlayerSpawn(); |
---|
42 | virtual void onPlayerDeath(); |
---|
43 | |
---|
44 | |
---|
45 | virtual void tick(float dt); |
---|
46 | void draw(); |
---|
47 | |
---|
48 | inline void setDeathPenaltyTimeout(float time) { this->deathTimeout = time; } |
---|
49 | inline void setMaxKills(int kills) { this->maxKills = kills; } |
---|
50 | void setDeathScreen(const std::string& imageName); |
---|
51 | |
---|
52 | inline void setNumTeams( int numTeams ){ this->numTeams = numTeams; } |
---|
53 | inline int getNumTeams(){ return this->numTeams; } |
---|
54 | |
---|
55 | int getRandomTeam(); |
---|
56 | |
---|
57 | protected: |
---|
58 | virtual void checkGameRules(); |
---|
59 | |
---|
60 | private: |
---|
61 | bool bLocalPlayerDead; //!< true if the local player is dead |
---|
62 | float deathTimeout; //!< timeout a player cannot play if he/she dies |
---|
63 | float timeout; //!< time counted if player dead |
---|
64 | int maxKills; //!< max kills for winning condition |
---|
65 | |
---|
66 | int numTeams; //!< number of teams |
---|
67 | |
---|
68 | std::map<int,int> teamScore; //!< team score |
---|
69 | |
---|
70 | ImagePlane* deathScreen; //!< the death screen |
---|
71 | |
---|
72 | int currentGameState; //!< game state |
---|
73 | float gameStateTimer; //!< if less than 0 -> change game state |
---|
74 | |
---|
75 | void calculateTeamScore(); |
---|
76 | void nextGameState(); |
---|
77 | void handleTeamChanges(); |
---|
78 | void teamChange( int userId ); |
---|
79 | }; |
---|
80 | |
---|
81 | |
---|
82 | #endif /* _MULTIPLAYER_TEAM_DEATHMATCH_H */ |
---|