[7034] | 1 | |
---|
| 2 | /*! |
---|
[7035] | 3 | * @file multiplayer_team_deathmatch.h |
---|
[7037] | 4 | * Defines game rules for team deathmatch games |
---|
| 5 | * |
---|
| 6 | * currently there are only two teams supported |
---|
[7034] | 7 | */ |
---|
| 8 | |
---|
| 9 | #ifndef _MULTIPLAYER_TEAM_DEATHMATCH_H |
---|
| 10 | #define _MULTIPLAYER_TEAM_DEATHMATCH_H |
---|
| 11 | |
---|
[8068] | 12 | #include "network_game_rules.h" |
---|
[7034] | 13 | |
---|
| 14 | |
---|
| 15 | class TiXmlElement; |
---|
| 16 | class ObjectManager; |
---|
| 17 | class Player; |
---|
[7810] | 18 | class ImagePlane; |
---|
[7034] | 19 | |
---|
[8068] | 20 | enum |
---|
| 21 | { |
---|
| 22 | GAMESTATE_PRE_GAME = 0, |
---|
| 23 | GAMESTATE_GAME, |
---|
| 24 | GAMESTATE_POST_GAME |
---|
| 25 | }; |
---|
[7034] | 26 | |
---|
[8068] | 27 | |
---|
| 28 | class MultiplayerTeamDeathmatch : public NetworkGameRules |
---|
[7034] | 29 | { |
---|
| 30 | |
---|
| 31 | public: |
---|
[7035] | 32 | MultiplayerTeamDeathmatch(const TiXmlElement* root = NULL); |
---|
[7034] | 33 | virtual ~MultiplayerTeamDeathmatch(); |
---|
| 34 | |
---|
| 35 | virtual void loadParams(const TiXmlElement* root); |
---|
| 36 | |
---|
[8068] | 37 | virtual int getTeamForNewUser(); |
---|
| 38 | virtual ClassID getPlayableClassId( int team ); |
---|
| 39 | virtual std::string getPlayableModelFileName( int team, ClassID classId ); |
---|
[7034] | 40 | |
---|
[7044] | 41 | virtual void onPlayerSpawn(); |
---|
| 42 | virtual void onPlayerDeath(); |
---|
[7034] | 43 | |
---|
| 44 | |
---|
| 45 | virtual void tick(float dt); |
---|
| 46 | void draw(); |
---|
| 47 | |
---|
[7037] | 48 | inline void setDeathPenaltyTimeout(float time) { this->deathTimeout = time; } |
---|
| 49 | inline void setMaxKills(int kills) { this->maxKills = kills; } |
---|
[7221] | 50 | void setDeathScreen(const std::string& imageName); |
---|
[8068] | 51 | |
---|
| 52 | inline void setNumTeams( int numTeams ){ this->numTeams = numTeams; } |
---|
| 53 | inline int getNumTeams(){ return this->numTeams; } |
---|
| 54 | |
---|
| 55 | int getRandomTeam(); |
---|
[7034] | 56 | |
---|
| 57 | protected: |
---|
[7035] | 58 | virtual void checkGameRules(); |
---|
[7037] | 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 |
---|
[7039] | 63 | float timeout; //!< time counted if player dead |
---|
[7037] | 64 | int maxKills; //!< max kills for winning condition |
---|
| 65 | |
---|
[8068] | 66 | int numTeams; //!< number of teams |
---|
[7039] | 67 | |
---|
[8068] | 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 ); |
---|
[7034] | 79 | }; |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | #endif /* _MULTIPLAYER_TEAM_DEATHMATCH_H */ |
---|