Changeset 9805 in orxonox.OLD for branches/new_class_id/src/world_entities/weapons
- Timestamp:
- Sep 24, 2006, 3:21:12 PM (18 years ago)
- Location:
- branches/new_class_id/src/world_entities/weapons
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/world_entities/weapons/weapon.cc
r9757 r9805 24 24 #include "world_entities/projectiles/projectile.h" 25 25 26 #include "util/loading/resource_manager.h"27 26 #include "util/loading/factory.h" 28 27 #include "util/loading/load_param.h" … … 32 31 #include "sound_source.h" 33 32 #include "sound_buffer.h" 33 #include "resource_sound_buffer.h" 34 34 35 35 #include "elements/glgui_energywidget.h" … … 59 59 if (this->animation[i] && Animation::objectList().exists(animation[i])) //!< @todo this should check animation3D 60 60 delete this->animation[i]; 61 for (int i = 0; i < WA_ACTION_COUNT; i++)62 if (this->soundBuffers[i] != NULL && OrxSound::SoundBuffer::objectList().exists(this->soundBuffers[i]))63 ResourceManager::getInstance()->unload(this->soundBuffers[i]);64 61 65 62 if (OrxSound::SoundSource::objectList().exists(this->soundSource)) … … 121 118 this->animation[i] = NULL; //< No animation 122 119 } 123 for (int i = 0; i < WA_ACTION_COUNT; i++)124 this->soundBuffers[i] = NULL; //< No Sounds125 120 126 121 this->soundSource = new OrxSound::SoundSource(this); //< Every Weapon has exacty one SoundSource. … … 273 268 if (action >= WA_ACTION_COUNT) 274 269 return; 275 if (this->soundBuffers[action] != NULL)276 ResourceManager::getInstance()->unload(this->soundBuffers[action]);277 270 278 271 else if (!soundFile.empty()) 279 272 { 280 this->soundBuffers[action] = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(soundFile, WAV);281 if (this->soundBuffers[action] != NULL)273 this->soundBuffers[action] = OrxSound::ResourceSoundBuffer(soundFile); 274 if (this->soundBuffers[action].loaded()) 282 275 { 283 276 PRINTF(4)("Loaded sound %s to action %s.\n", soundFile.c_str(), actionToChar(action)); … … 289 282 } 290 283 else 291 this->soundBuffers[action] = NULL;284 this->soundBuffers[action] = OrxSound::SoundBuffer(); 292 285 } 293 286 … … 423 416 { 424 417 case WA_SHOOT: 425 426 418 return this->fireW(); 419 break; 427 420 case WA_CHARGE: 428 429 421 return this->chargeW(); 422 break; 430 423 case WA_RELOAD: 431 432 424 return this->reloadW(); 425 break; 433 426 case WA_DEACTIVATE: 434 435 427 return this->deactivateW(); 428 break; 436 429 case WA_ACTIVATE: 437 438 430 return this->activateW(); 431 break; 439 432 default: 440 441 433 PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action)); 434 return false; 442 435 } 443 436 } … … 452 445 { 453 446 // play Sound 454 if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))447 if (likely(this->soundBuffers[WA_ACTIVATE].loaded())) 455 448 this->soundSource->play(this->soundBuffers[WA_ACTIVATE]); 456 449 this->updateWidgets(); … … 474 467 PRINTF(4)("Deactivating the Weapon %s\n", this->getCName()); 475 468 // play Sound 476 if (this->soundBuffers[WA_DEACTIVATE] != NULL)469 if (this->soundBuffers[WA_DEACTIVATE].loaded()) 477 470 this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]); 478 471 // deactivate … … 493 486 { 494 487 // playing Sound 495 if (this->soundBuffers[WA_CHARGE] != NULL)488 if (this->soundBuffers[WA_CHARGE].loaded()) 496 489 this->soundSource->play(this->soundBuffers[WA_CHARGE]); 497 490 … … 518 511 { 519 512 // playing Sound 520 if (this->soundBuffers[WA_SHOOT] != NULL)513 if (this->soundBuffers[WA_SHOOT].loaded()) 521 514 this->soundSource->play(this->soundBuffers[WA_SHOOT]); 522 515 this->updateWidgets(); … … 551 544 552 545 553 if (this->soundBuffers[WA_RELOAD] != NULL)546 if (this->soundBuffers[WA_RELOAD].loaded()) 554 547 this->soundSource->play(this->soundBuffers[WA_RELOAD]); 555 548 … … 694 687 { 695 688 case WA_SHOOT: 696 697 689 return "shoot"; 690 break; 698 691 case WA_CHARGE: 699 700 692 return "charge"; 693 break; 701 694 case WA_RELOAD: 702 703 695 return "reload"; 696 break; 704 697 case WA_ACTIVATE: 705 706 698 return "activate"; 699 break; 707 700 case WA_DEACTIVATE: 708 709 701 return "deactivate"; 702 break; 710 703 case WA_SPECIAL1: 711 712 704 return "special1"; 705 break; 713 706 default: 714 715 707 return "none"; 708 break; 716 709 } 717 710 } … … 757 750 { 758 751 case WS_SHOOTING: 759 760 752 return "shooting"; 753 break; 761 754 case WS_CHARGING: 762 763 755 return "charging"; 756 break; 764 757 case WS_RELOADING: 765 766 758 return "reloading"; 759 break; 767 760 case WS_ACTIVATING: 768 769 761 return "activating"; 762 break; 770 763 case WS_DEACTIVATING: 771 772 764 return "deactivating"; 765 break; 773 766 case WS_IDLE: 774 775 767 return "idle"; 768 break; 776 769 case WS_INACTIVE: 777 778 770 return "inactive"; 771 break; 779 772 default: 780 781 782 } 783 } 773 return "none"; 774 break; 775 } 776 } -
branches/new_class_id/src/world_entities/weapons/weapon.h
r9715 r9805 18 18 #include "count_pointer.h" 19 19 #include "ammo_container.h" 20 21 #include "sound_buffer.h" 20 22 21 23 // FORWARD DECLARATION … … 219 221 // PHASES // 220 222 //////////// 221 OrxSound::SoundSource* soundSource; 222 223 WeaponState currentState; 224 WeaponAction requestedAction; 225 float stateDuration; 226 float times[WS_STATE_COUNT]; 227 Animation3D* animation[WS_STATE_COUNT]; 228 OrxSound::SoundBuffer * soundBuffers[WA_ACTION_COUNT];//!< SoundBuffers for all actions @see WeaponAction.223 OrxSound::SoundSource* soundSource; //!< A SoundSource to play sound from (this is connected to the PNode of the Weapon) 224 225 WeaponState currentState; //!< The State the weapon is in. 226 WeaponAction requestedAction; //!< An action to try to Engage after the currentState ends. 227 float stateDuration; //!< how long the state has taken until now. 228 float times[WS_STATE_COUNT]; //!< Times to stay in the different States @see WeaponState. 229 Animation3D* animation[WS_STATE_COUNT]; //!< Animations for all the States (you can say yourself on what part of the gun this animation acts). 230 OrxSound::SoundBuffer soundBuffers[WA_ACTION_COUNT]; //!< SoundBuffers for all actions @see WeaponAction. 229 231 230 232 PNode emissionPoint; //!< The point, where the projectiles are emitted. (this is coppled with the Weapon by default)
Note: See TracChangeset
for help on using the changeset viewer.