[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 | |
---|
[8623] | 14 | #include "glgui.h" |
---|
[7034] | 15 | |
---|
| 16 | class TiXmlElement; |
---|
| 17 | class ObjectManager; |
---|
| 18 | class Player; |
---|
[7810] | 19 | class ImagePlane; |
---|
[7034] | 20 | |
---|
[8068] | 21 | enum |
---|
| 22 | { |
---|
| 23 | GAMESTATE_PRE_GAME = 0, |
---|
| 24 | GAMESTATE_GAME, |
---|
| 25 | GAMESTATE_POST_GAME |
---|
| 26 | }; |
---|
[7034] | 27 | |
---|
[8068] | 28 | |
---|
[8623] | 29 | class MultiplayerTeamDeathmatch : public NetworkGameRules, public EventListener |
---|
[7034] | 30 | { |
---|
| 31 | |
---|
| 32 | public: |
---|
[7035] | 33 | MultiplayerTeamDeathmatch(const TiXmlElement* root = NULL); |
---|
[7034] | 34 | virtual ~MultiplayerTeamDeathmatch(); |
---|
| 35 | |
---|
| 36 | virtual void loadParams(const TiXmlElement* root); |
---|
| 37 | |
---|
[8068] | 38 | virtual int getTeamForNewUser(); |
---|
[8147] | 39 | virtual ClassID getPlayableClassId( int userId, int team ); |
---|
| 40 | virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId ); |
---|
[7034] | 41 | |
---|
[7044] | 42 | virtual void onPlayerSpawn(); |
---|
| 43 | virtual void onPlayerDeath(); |
---|
[7034] | 44 | |
---|
| 45 | |
---|
| 46 | virtual void tick(float dt); |
---|
| 47 | void draw(); |
---|
| 48 | |
---|
[7037] | 49 | inline void setDeathPenaltyTimeout(float time) { this->deathTimeout = time; } |
---|
| 50 | inline void setMaxKills(int kills) { this->maxKills = kills; } |
---|
[7221] | 51 | void setDeathScreen(const std::string& imageName); |
---|
[8068] | 52 | |
---|
| 53 | inline void setNumTeams( int numTeams ){ this->numTeams = numTeams; } |
---|
| 54 | inline int getNumTeams(){ return this->numTeams; } |
---|
| 55 | |
---|
| 56 | int getRandomTeam(); |
---|
[8623] | 57 | |
---|
| 58 | virtual void process(const Event &event); |
---|
| 59 | |
---|
| 60 | virtual void handleChatMessage( int userId, const std::string & message, int messageType ); |
---|
[7034] | 61 | |
---|
| 62 | protected: |
---|
[7035] | 63 | virtual void checkGameRules(); |
---|
[7037] | 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 |
---|
[7039] | 68 | float timeout; //!< time counted if player dead |
---|
[7037] | 69 | int maxKills; //!< max kills for winning condition |
---|
| 70 | |
---|
[8068] | 71 | int numTeams; //!< number of teams |
---|
[7039] | 72 | |
---|
[8068] | 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 | |
---|
[8623] | 80 | bool bShowTeamChange; //!< if true -> show team change dialog |
---|
| 81 | |
---|
[8147] | 82 | OrxGui::GLGuiBox* box; |
---|
[8623] | 83 | |
---|
[8068] | 84 | void calculateTeamScore(); |
---|
| 85 | void nextGameState(); |
---|
| 86 | void handleTeamChanges(); |
---|
| 87 | void teamChange( int userId ); |
---|
[8147] | 88 | void assignPlayable(); |
---|
| 89 | |
---|
| 90 | void onButtonSpectator(); |
---|
| 91 | void onButtonRandom(); |
---|
| 92 | void onButtonTeam0(); |
---|
| 93 | void onButtonTeam1(); |
---|
[8623] | 94 | void onButtonCancel(); |
---|
[8147] | 95 | void onButtonExit(); |
---|
[7034] | 96 | }; |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | #endif /* _MULTIPLAYER_TEAM_DEATHMATCH_H */ |
---|