- Timestamp:
- Apr 19, 2006, 1:25:07 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/game_world.cc
r7330 r7338 280 280 281 281 282 void GameWorld::setPlaymode(Playable::Playmode playmode) 283 { 284 if (this->dataTank->localPlayer && 285 this->dataTank->localPlayer->getPlayable() && 286 this->dataTank->localPlayer->getPlayable()->setPlayMode(playmode)) 287 { 288 PRINTF(3)("Set Playmode to %d\n", playmode); 289 } 290 } 291 292 282 293 /** 283 294 * synchronize local data with remote data -
trunk/src/story_entities/game_world.h
r7304 r7338 10 10 #include "story_entity.h" 11 11 #include "game_world_data.h" 12 #include "playable.h" 12 13 13 14 class Shell; … … 45 46 virtual void run(); 46 47 48 void setPlaymode(Playable::Playmode playmode); 47 49 /** this returns the current game time @returns elapsed game time */ 48 50 inline double getGameTime() { return this->gameTime; } -
trunk/src/world_entities/playable.cc
r7337 r7338 39 39 40 40 Playable::Playable() 41 : weaponMan(this) 41 : weaponMan(this), 42 supportedPlaymodes(Playable::Full3D), 43 playmode(Playable::Full3D) 42 44 { 43 45 this->setClassID(CL_PLAYABLE, "Playable"); … … 90 92 this->weaponMan.removeWeapon(weapon); 91 93 92 94 this->weaponConfigChanged(); 93 95 } 94 96 … … 97 99 { 98 100 this->weaponMan.nextWeaponConfig(); 99 101 this->weaponConfigChanged(); 100 102 } 101 103 … … 104 106 { 105 107 this->weaponMan.previousWeaponConfig(); 106 108 this->weaponConfigChanged(); 107 109 } 108 110 … … 119 121 */ 120 122 void Playable::setCameraMode(unsigned int cameraMode) 121 { 122 123 {} 124 125 /** 126 * @brief sets the Playmode 127 * @param playmode the Playmode 128 * @returns true on success, false otherwise 129 */ 130 bool Playable::setPlayMode(Playable::Playmode playmode) 131 { 132 if (!this->playmodeSupported(playmode)) 133 return false; 134 else 135 this->playmode = playmode; 123 136 } 124 137 … … 155 168 if( this->getOwner() % 2 == 0) 156 169 { 157 // this->toList(OM_GROUP_00);170 // this->toList(OM_GROUP_00); 158 171 this->setAbsCoor(213.37, 57.71, -47.98); 159 172 this->setAbsDir(0, 0, 1, 0); … … 161 174 else 162 175 { // red team 163 // this->toList(OM_GROUP_01);176 // this->toList(OM_GROUP_01); 164 177 this->setAbsCoor(-314.450, 40.701, 83.554); 165 178 this->setAbsDir(1.0, -0.015, -0.012, 0.011); … … 179 192 { 180 193 PRINTF(0)("Playable dies\n"); 181 // only if this is the spaceship of the player194 // only if this is the spaceship of the player 182 195 if (State::isOnline()) 183 196 { … … 185 198 State::getGameRules()->onPlayerDeath(); 186 199 187 // this->toList(OM_GROUP_05);188 //HACK: moves the entity to an unknown place far far away: in the future, GameRules will look for that200 // this->toList(OM_GROUP_05); 201 //HACK: moves the entity to an unknown place far far away: in the future, GameRules will look for that 189 202 this->setAbsCoor(-2000.0, -2000.0, -2000.0); 190 203 191 //explosion hack204 //explosion hack 192 205 193 206 } … … 216 229 // unsubscibe all events. 217 230 EventHandler* evh = EventHandler::getInstance(); 218 std:: list<int>::iterator ev;231 std::vector<int>::iterator ev; 219 232 for (ev = this->events.begin(); ev != events.end(); ev++) 220 233 evh->unsubscribe( ES_GAME, (*ev)); … … 242 255 /*EventHandler*/ 243 256 EventHandler* evh = EventHandler::getInstance(); 244 std:: list<int>::iterator ev;257 std::vector<int>::iterator ev; 245 258 for (ev = this->events.begin(); ev != events.end(); ev++) 246 259 evh->subscribe(player, ES_GAME, (*ev)); … … 256 269 bool Playable::pickup(PowerUp* powerUp) 257 270 { 258 if(powerUp->isA(CL_WEAPON_POWER_UP)) { 271 if(powerUp->isA(CL_WEAPON_POWER_UP)) 272 { 259 273 return dynamic_cast<WeaponPowerUp*>(powerUp)->process(&this->getWeaponManager()); 260 274 } 261 else if(powerUp->isA(CL_PARAM_POWER_UP)) { 275 else if(powerUp->isA(CL_PARAM_POWER_UP)) 276 { 262 277 ParamPowerUp* ppu = dynamic_cast<ParamPowerUp*>(powerUp); 263 switch(ppu->getType()) { 278 switch(ppu->getType()) 279 { 264 280 case POWERUP_PARAM_HEALTH: 265 281 this->increaseHealth(ppu->getValue()); … … 291 307 void Playable::unregisterEvent(int eventType) 292 308 { 293 this->events.remove(eventType); 309 std::vector<int>::iterator rmEvent = std::find(this->events.begin(), this->events.end(), eventType); 310 this->events.erase(rmEvent); 294 311 295 312 if (this->currentPlayer != NULL) … … 338 355 339 356 void Playable::detachCamera() 340 { 341 } 357 {} 342 358 343 359 #define DATA_FLAGS 1 -
trunk/src/world_entities/playable.h
r7337 r7338 10 10 #include "extendable.h" 11 11 #include "event.h" 12 #include < list>12 #include <vector> 13 13 14 14 #include "world_entities/weapons/weapon_manager.h" … … 26 26 class Playable : public WorldEntity, public Extendable 27 27 { 28 public: 29 virtual ~Playable(); 30 31 virtual void loadParams(const TiXmlElement* root); 32 33 virtual void die(); 34 virtual void respawn(); 35 36 virtual bool pickup(PowerUp* powerUp); 37 38 void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1); 39 void removeWeapon(Weapon* weapon); 40 void nextWeaponConfig(); 41 void previousWeaponConfig(); 42 43 inline WeaponManager& getWeaponManager() { return this->weaponMan; }; 44 void weaponConfigChanged(); 28 public: 29 typedef enum { 30 Vertical = 1, 31 Horizontal = 2, 32 FromBehind = 4, 33 Full3D = 8, 34 } Playmode; 45 35 46 36 47 bool setPlayer(Player* player); 48 Player* getCurrentPlayer() const { return this->currentPlayer; };37 public: 38 virtual ~Playable(); 49 39 50 void attachCamera(); 51 void detachCamera(); 52 virtual void setCameraMode(unsigned int cameraMode = 0); 40 virtual void loadParams(const TiXmlElement* root); 53 41 54 virtual void collidesWith(WorldEntity* entity, const Vector& location);55 virtual void process(const Event &event);42 virtual void die(); 43 virtual void respawn(); 56 44 57 virtual void tick(float dt);45 virtual bool pickup(PowerUp* powerUp); 58 46 59 /** @return a List of Events in PEV_* sytle */ 60 inline const std::list<int>& getEventList() { return this->events; }; 47 void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1); 48 void removeWeapon(Weapon* weapon); 49 void nextWeaponConfig(); 50 void previousWeaponConfig(); 61 51 62 int writeSync(const byte* data, int length, int sender); 63 int readSync(byte* data, int maxLength ); 64 bool needsReadSync(); 52 inline WeaponManager& getWeaponManager() { return this->weaponMan; }; 53 void weaponConfigChanged(); 65 54 66 55 67 // 68 virtual void setStartDirection(const Quaternion& rot) = 0; 69 void setStartDirection(float angle, float dirX, float dirY, float dirZ) { this->setStartDirection(Quaternion(angle, Vector(dirX, dirY, dirZ))); } 56 bool setPlayer(Player* player); 57 Player* getCurrentPlayer() const { return this->currentPlayer; }; 70 58 71 inline void setScore( int score ) { this->score = score; } 72 inline int getScore() { return this->score; } 59 void attachCamera(); 60 void detachCamera(); 61 virtual void setCameraMode(unsigned int cameraMode = 0); 62 bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; }; 63 bool setPlayMode(Playable::Playmode playmode); 73 64 74 protected:75 Playable();65 virtual void collidesWith(WorldEntity* entity, const Vector& location); 66 virtual void process(const Event &event); 76 67 77 virtual void enter() = 0; 78 virtual void leave() = 0; 68 virtual void tick(float dt); 79 69 80 void registerEvent(int eventType);81 void unregisterEvent(int eventType);70 /** @return a List of Events in PEV_* sytle */ 71 inline const std::vector<int>& getEventList() { return this->events; }; 82 72 83 private: 84 WeaponManager weaponMan; //!< the weapon manager: managing a list of weapon to wepaon-slot mapping 85 std::list<int> events; //!< A list of Events, that are captured for this playable 86 87 Player* currentPlayer; //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL 88 89 bool bFire; //!< If the Ship is firing. 90 int oldFlags; //!< Used for synchronisation 91 92 int score; 93 int oldScore; 94 95 bool bDead; 96 97 //TODO HACK: explosion emitter 73 int writeSync(const byte* data, int length, int sender); 74 int readSync(byte* data, int maxLength ); 75 bool needsReadSync(); 98 76 99 77 100 WorldEntity* collider; 78 // 79 virtual void setStartDirection(const Quaternion& rot) = 0; 80 void setStartDirection(float angle, float dirX, float dirY, float dirZ) { this->setStartDirection(Quaternion(angle, Vector(dirX, dirY, dirZ))); } 81 82 inline void setScore( int score ) { this->score = score; } 83 inline int getScore() { return this->score; } 84 85 protected: 86 Playable(); 87 88 virtual void enter() = 0; 89 virtual void leave() = 0; 90 91 void setSupportedPlaymodes(short playmodes) { this->supportedPlaymodes = playmodes; }; 92 93 void registerEvent(int eventType); 94 void unregisterEvent(int eventType); 95 96 private: 97 WeaponManager weaponMan; //!< the weapon manager: managing a list of weapon to wepaon-slot mapping 98 std::vector<int> events; //!< A list of Events, that are captured for this playable 99 100 Player* currentPlayer; //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL 101 102 bool bFire; //!< If the Ship is firing. 103 int oldFlags; //!< Used for synchronisation 104 105 int score; 106 int oldScore; 107 108 bool bDead; 109 short supportedPlaymodes; //!< What Playmodes are Supported in this Playable. 110 Playable::Playmode playmode; //!< The current playmode. 111 112 WorldEntity* collider; 101 113 }; 102 114
Note: See TracChangeset
for help on using the changeset viewer.