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 | #include "specials/glgui_notifier.h" |
---|
16 | |
---|
17 | class TiXmlElement; |
---|
18 | class ObjectManager; |
---|
19 | class Player; |
---|
20 | class ImagePlane; |
---|
21 | |
---|
22 | enum |
---|
23 | { |
---|
24 | GAMESTATE_PRE_GAME = 0, |
---|
25 | GAMESTATE_GAME, |
---|
26 | GAMESTATE_POST_GAME |
---|
27 | }; |
---|
28 | |
---|
29 | |
---|
30 | class MultiplayerTeamDeathmatch : public NetworkGameRules, public EventListener |
---|
31 | { |
---|
32 | |
---|
33 | public: |
---|
34 | MultiplayerTeamDeathmatch(const TiXmlElement* root = NULL); |
---|
35 | virtual ~MultiplayerTeamDeathmatch(); |
---|
36 | |
---|
37 | virtual void loadParams(const TiXmlElement* root); |
---|
38 | |
---|
39 | virtual int getTeamForNewUser(); |
---|
40 | virtual ClassID getPlayableClassId( int userId, int team ); |
---|
41 | virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId ); |
---|
42 | |
---|
43 | virtual void registerSpawn( WorldEntity * we ); |
---|
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 | |
---|
51 | inline void setNumTeams( int numTeams ){ this->numTeams = numTeams; } |
---|
52 | inline int getNumTeams(){ return this->numTeams; } |
---|
53 | |
---|
54 | int getRandomTeam(); |
---|
55 | |
---|
56 | virtual void process(const Event &event); |
---|
57 | |
---|
58 | void onKill( WorldEntity * victim, WorldEntity * killer ); |
---|
59 | void onRespawn( int userId ); |
---|
60 | |
---|
61 | virtual void handleChatMessage( int userId, const std::string & message, int messageType ); |
---|
62 | |
---|
63 | void respawnPlayable( Playable * playable, int teamId, float delay ); |
---|
64 | |
---|
65 | protected: |
---|
66 | virtual void checkGameRules(); |
---|
67 | |
---|
68 | private: |
---|
69 | bool bLocalPlayerDead; //!< true if the local player is dead |
---|
70 | float deathTimeout; //!< timeout a player cannot play if he/she dies |
---|
71 | float timeout; //!< time counted if player dead |
---|
72 | int maxKills; //!< max kills for winning condition |
---|
73 | |
---|
74 | int numTeams; //!< number of teams |
---|
75 | |
---|
76 | std::map<int,int> teamScore; //!< team score |
---|
77 | |
---|
78 | int currentGameState; //!< game state |
---|
79 | float gameStateTimer; //!< if less than 0 -> change game state |
---|
80 | |
---|
81 | bool bShowTeamChange; //!< if true -> show team change dialog |
---|
82 | |
---|
83 | OrxGui::GLGuiBox* box; |
---|
84 | |
---|
85 | OrxGui::GLGuiInputLine* input; |
---|
86 | |
---|
87 | void calculateTeamScore(); |
---|
88 | void nextGameState(); |
---|
89 | void handleTeamChanges(); |
---|
90 | void teamChange( int userId ); |
---|
91 | void assignPlayable(); |
---|
92 | |
---|
93 | void onButtonSpectator(); |
---|
94 | void onButtonRandom(); |
---|
95 | void onButtonTeam0(); |
---|
96 | void onButtonTeam1(); |
---|
97 | void onButtonCancel(); |
---|
98 | void onButtonExit(); |
---|
99 | |
---|
100 | void onInputEnter( const std::string & text ); |
---|
101 | |
---|
102 | OrxGui::GLGuiBox* statsBox; |
---|
103 | OrxGui::GLGuiTable* table; |
---|
104 | void tickStatsTable(); |
---|
105 | |
---|
106 | void showStats(); |
---|
107 | void hideStats(); |
---|
108 | }; |
---|
109 | |
---|
110 | |
---|
111 | #endif /* _MULTIPLAYER_TEAM_DEATHMATCH_H */ |
---|