Changeset 4926 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Jul 21, 2005, 4:59:16 PM (19 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/player.cc
r4910 r4926 105 105 106 106 107 this->weaponMan = new WeaponManager( );107 this->weaponMan = new WeaponManager(2); 108 108 } 109 109 -
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4910 r4926 77 77 this->soundBuffers[i] = NULL; 78 78 79 this->requestedAction = WA_NONE;80 79 this->soundSource = new SoundSource(this); 81 80 this->emissionPoint.setParent(this); … … 183 182 { 184 183 this->currentState = WS_ACTIVATING; 185 this->requestAction(WA_ACTIVATE); 186 } 187 } 188 184 this->requestedAction = WA_ACTIVATE; 185 } 186 } 189 187 190 188 /** … … 227 225 #endif 228 226 229 switch (this->requestedAction) 227 WeaponAction action = this->requestedAction; 228 this->requestedAction = WA_NONE; 229 230 switch (action) 230 231 { 231 232 case WA_SHOOT: … … 254 255 bool Weapon::activateW() 255 256 { 256 if (this->currentState == WS_INACTIVE)257 // if (this->currentState == WS_INACTIVE) 257 258 { 258 259 // play Sound 259 260 if (likely(this->soundBuffers[WA_ACTIVATE] != NULL)) 260 261 this->soundSource->play(this->soundBuffers[WA_ACTIVATE]); 261 if (likely(this->animation[WS_ACTIVATING] != NULL))262 this->animation[WS_ACTIVATING]->replay();263 262 // activate 264 263 PRINTF(4)("Activating the Weapon %s\n", this->getName()); 265 264 this->activate(); 266 265 // setting up for next action 267 this->currentState = WS_ACTIVATING; 268 this->stateDuration = this->times[WS_ACTIVATING] + this->stateDuration; 269 } 270 this->requestedAction = WA_NONE; 266 this->enterState(WS_ACTIVATING); 267 } 271 268 } 272 269 … … 284 281 if (this->soundBuffers[WA_DEACTIVATE] != NULL) 285 282 this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]); 286 if (likely(this->animation[WS_DEACTIVATING] != NULL)) 287 this->animation[WS_DEACTIVATING]->replay(); 288 // deactivate 283 // deactivate 289 284 this->deactivate(); 290 // setting up for next action 291 this->currentState = WS_DEACTIVATING; 292 this->stateDuration = this->times[WS_DEACTIVATING] + this->stateDuration; 293 } 294 this->requestedAction = WA_NONE; 285 this->enterState(WS_DEACTIVATING); 286 } 295 287 } 296 288 … … 306 298 if (this->soundBuffers[WA_CHARGE] != NULL) 307 299 this->soundSource->play(this->soundBuffers[WA_CHARGE]); 308 if (likely(this->animation[WS_CHARGING] != NULL))309 this->animation[WS_CHARGING]->replay();310 300 311 301 // charge 312 302 this->charge(); 313 303 // setting up for the next state 314 this->requestedAction = WA_NONE; 315 this->currentState = WS_CHARGING; 316 this->stateDuration = this->times[WS_CHARGING] + this->stateDuration; 304 this->enterState(WS_CHARGING); 317 305 } 318 306 else // deactivate the Weapon if we do not have enough energy 319 307 { 320 this->requestedAction = WA_NONE;321 308 this->requestAction(WA_RELOAD); 322 309 } … … 336 323 if (this->soundBuffers[WA_SHOOT] != NULL) 337 324 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 338 if (likely(this->animation[WS_SHOOTING] != NULL))339 this->animation[WS_SHOOTING]->replay();340 325 // fire 341 326 this->fire(); 342 327 this->energyLoaded -= this->minCharge; 343 328 // setting up for the next state 344 this->stateDuration = this->times[WS_SHOOTING] + this->stateDuration; 345 this->currentState = WS_SHOOTING; 346 this->requestedAction = WA_NONE; 329 this->enterState(WS_SHOOTING); 347 330 } 348 331 else // reload if we still have the charge 349 332 { 350 this->requestedAction = WA_NONE;351 333 this->requestAction(WA_RELOAD); 352 334 } … … 371 353 if (this->soundBuffers[WA_RELOAD] != NULL) 372 354 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 373 if (likely(this->animation[WS_RELOADING] != NULL))374 this->animation[WS_RELOADING]->replay();375 355 376 356 if (chargeSize > this->energy) … … 387 367 } 388 368 this->reload(); 389 390 this->requestedAction = WA_NONE; 391 this->currentState = WS_RELOADING; 392 this->stateDuration = this->times[WS_RELOADING] + this->stateDuration; 393 369 this->enterState(WS_RELOADING); 370 } 371 372 373 /** 374 * enters the requested State, plays back animations updates the timing. 375 * @param state the state to enter. 376 */ 377 inline void Weapon::enterState(WeaponState state) 378 { 379 // playing animation if availiable 380 if (likely(this->animation[state] != NULL)) 381 this->animation[state]->replay(); 382 383 this->stateDuration = this->times[state] + this->stateDuration; 384 this->currentState = state; 394 385 } 395 386 -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4910 r4926 155 155 bool reloadW(); 156 156 157 inline void enterState(WeaponState state); 158 157 159 158 160 protected: -
orxonox/trunk/src/world_entities/weapons/weapon_manager.cc
r4909 r4926 34 34 * @param number of weapon slots of the model/ship <= 8 (limitied) 35 35 */ 36 WeaponManager::WeaponManager(int nrOfSlots)36 WeaponManager::WeaponManager(int slotCount) 37 37 { 38 38 this->init(); 39 this-> nrOfSlots = nrOfSlots;39 this->slotCount = slotCount; 40 40 } 41 41 … … 127 127 /** 128 128 * sets the number of Slots the WeaponManager has 129 * @param nrOfSlotsthe number of slots130 */ 131 void WeaponManager::setSlotCount(int nrOfSlots)132 { 133 this-> nrOfSlots = nrOfSlots;129 * @param slotCount the number of slots 130 */ 131 void WeaponManager::setSlotCount(int slotCount) 132 { 133 this->slotCount = slotCount; 134 134 } 135 135 … … 150 150 { 151 151 int freeSlot = this->getNextFreeSlot( configID); 152 if( freeSlot < 0 || freeSlot >= this-> nrOfSlots)152 if( freeSlot < 0 || freeSlot >= this->slotCount) 153 153 { 154 154 PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n"); … … 262 262 { 263 263 w = this->configs[j].slots[i]; 264 if( w != NULL )//&& w->isVisible())264 if( w != NULL && w->isVisible()) 265 265 w->draw(); 266 266 } -
orxonox/trunk/src/world_entities/weapons/weapon_manager.h
r4906 r4926 76 76 class WeaponManager : public BaseObject { 77 77 public: 78 WeaponManager(int nrOfSlots = 2);78 WeaponManager(int slotCount); 79 79 WeaponManager(const TiXmlElement* root); 80 80 ~WeaponManager(); … … 84 84 void loadWeapons(const TiXmlElement* root); 85 85 86 void setSlotCount(int nrOfSlots);86 void setSlotCount(int slotCount); 87 87 88 88 void addWeapon(Weapon* weapon, int configID = WM_CONFIG0, int slotID = WM_FREE_SLOT); … … 101 101 tAnimation<Crosshair>* crossHairSizeAnim; 102 102 103 int nrOfSlots; //<! number of weapon slots a ship has103 int slotCount; //<! number of weapon slots a ship has 104 104 int currConfID; //<! the currently selected config 105 105 weaponConfig configs[4]; //<! a list of four configurations
Note: See TracChangeset
for help on using the changeset viewer.