- Timestamp:
- Feb 6, 2006, 12:47:01 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/game_world_data.cc
r7036 r7039 376 376 { 377 377 this->gameRule = dynamic_cast<GameRules*>(created); 378 State::setGameRules(this->gameRule); 378 379 } 379 380 else -
trunk/src/util/multiplayer_team_deathmatch.cc
r7037 r7039 20 20 #include "factory.h" 21 21 22 #include "render2D/billboard.h" 23 #include "state.h" 24 22 25 23 26 using namespace std; … … 37 40 this->bLocalPlayerDead = false; 38 41 this->deathTimeout = 10.0f; // 5 seconds 42 this->deathScreen = new Billboard(); 43 this->deathScreen->setSize(State::getResX(), State::getResY()); 39 44 40 45 if( root != NULL) … … 59 64 LoadParam(root, "max-kills", this, MultiplayerTeamDeathmatch, setMaxKills) 60 65 .describe("sets the maximal kills for winning condition"); 66 67 LoadParam(root, "death-screen-image", this, MultiplayerTeamDeathmatch, setDeathScreen) 68 .describe("sets the death screen image"); 69 61 70 } 71 72 73 74 void MultiplayerTeamDeathmatch::setDeathScreen(const char* imageName) 75 { 76 if( this->deathScreen) 77 this->deathScreen->setTexture(imageName); 78 } 79 62 80 63 81 … … 67 85 */ 68 86 void MultiplayerTeamDeathmatch::onPlayerSpawn(Player* player) 69 {} 87 { 88 this->bLocalPlayerDead = true; 89 } 70 90 71 91 … … 75 95 */ 76 96 void MultiplayerTeamDeathmatch::onPlayerDeath(Player* player) 77 {} 97 { 98 this->localPlayer = player; 99 this->bLocalPlayerDead = true; 100 } 78 101 79 102 … … 84 107 void MultiplayerTeamDeathmatch::tick(float dt) 85 108 { 109 this->checkGameRules(); 86 110 111 // is the local player dead and inactive 112 if( unlikely(this->bLocalPlayerDead)) 113 { 114 this->timeout += dt; 115 116 // long enough dead? 117 if( dt >= this->deathTimeout) 118 { 119 this->timeout = 0.0f; 120 121 // respawn 122 } 123 } 87 124 } 88 125 … … 92 129 */ 93 130 void MultiplayerTeamDeathmatch::draw() 94 {} 131 { 132 if( unlikely( this->bLocalPlayerDead)) 133 { 134 135 } 136 } 95 137 96 138 … … 99 141 */ 100 142 void MultiplayerTeamDeathmatch::checkGameRules() 101 {} 143 { 144 // 145 // check for max killing count 146 if( this->teamAKills >= this->maxKills) 147 { 148 // team A winns 149 } 150 else if( this->teamBKills >= this->maxKills) 151 { 152 // team B winns 153 } 154 } 102 155 103 156 -
trunk/src/util/multiplayer_team_deathmatch.h
r7037 r7039 16 16 class ObjectManager; 17 17 class Player; 18 class Billboard; 18 19 19 20 … … 37 38 inline void setDeathPenaltyTimeout(float time) { this->deathTimeout = time; } 38 39 inline void setMaxKills(int kills) { this->maxKills = kills; } 40 void setDeathScreen(const char* imageName); 39 41 40 42 protected: … … 44 46 bool bLocalPlayerDead; //!< true if the local player is dead 45 47 float deathTimeout; //!< timeout a player cannot play if he/she dies 48 float timeout; //!< time counted if player dead 46 49 int maxKills; //!< max kills for winning condition 47 50 48 51 int teamAKills; //!< kills of team A 49 52 int teamBKills; //!< kills of team B 53 54 Billboard* deathScreen; //!< the death screen 50 55 }; 51 56 -
trunk/src/util/state.cc
r7032 r7039 44 44 45 45 StoryEntity* State::storyEntity = NULL; 46 GameRules* State::gameRules = NULL; 46 47 47 48 Player* State::player = NULL; -
trunk/src/util/state.h
r7032 r7039 17 17 class StoryEntity; 18 18 class ObjectManager; 19 class GameRules; 19 20 20 21 … … 68 69 static inline StoryEntity* getCurrentStoryEntity() { return State::storyEntity; }; 69 70 71 /** @param gameRules sets the current GameRules */ 72 static inline void setGameRules(GameRules* gameRules) { State::gameRules = gameRules; } 73 /** @returns the GameRules reference*/ 74 static inline GameRules* getGameRules() { return State::gameRules; } 75 70 76 ////////////// 71 77 /// PLAYER /// … … 106 112 static ObjectManager* objectManager; //!< A reference to the current ObjectManager 107 113 static StoryEntity* storyEntity; //!< A reference to the current StoryEntity played 114 static GameRules* gameRules; //!< A reference to the GameRules 108 115 static Player* player; //!< A reference to the Player 109 116
Note: See TracChangeset
for help on using the changeset viewer.