- Timestamp:
- Dec 10, 2008, 5:30:39 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2379 r2391 39 39 CreateFactory(Weapon); 40 40 41 Weapon::Weapon(BaseObject* creator) : BaseObject(creator)41 Weapon::Weapon(BaseObject* creator) : PositionableEntity(creator) 42 42 { 43 43 RegisterObject(Weapon); … … 47 47 this->parentWeaponSlot_ = 0; 48 48 this->munition_ = 0; 49 this->bulletLoadingTime_ = 0; 50 this->magazineLoadingTime_ = 0; 51 this->bReloading_ = false; 49 52 } 50 53 … … 62 65 void Weapon::setWeapon() 63 66 { 67 COUT(0) << "LaserGun::setWeapon" << std::endl; 64 68 this->bulletLoadingTime_ = 0.5; 65 69 this->magazineLoadingTime_ = 3.0; 66 70 this->munition_->setMaxMagazines(100); 67 this->munition_->setMaxBullets( 30);71 this->munition_->setMaxBullets(6); 68 72 this->munition_->fillBullets(); 69 73 this->munition_->fillMagazines(); … … 74 78 { 75 79 COUT(0) << "LaserGun::fire, this=" << this << std::endl; 76 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ )80 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_) 77 81 { 78 82 COUT(0) << "LaserGun::fire - ready to shoot" << std::endl; 79 83 COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl; 80 84 this->bulletReadyToShoot_ = false; 81 if ( this->munition_->bullets() )85 if ( this->munition_->bullets() > 0) 82 86 { 83 87 //shoot … … 86 90 } 87 91 //if there are no bullets, but magazines 88 else if ( this->munition_->magazines() && !this->munition_->bullets() ) 89 { 92 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 ) 93 { 94 COUT(0) << "LaserGun::fire - no bullets" << std::endl; 90 95 this->takeMagazines(); 96 } 97 else 98 { 99 COUT(0) << "LaserGun::fire - no magazines" << std::endl; 100 //actions 91 101 } 92 102 } … … 94 104 { 95 105 COUT(0) << "LaserGun::fire - weapon not reloaded" << std::endl; 106 //actions 96 107 } 97 108 … … 102 113 { 103 114 COUT(0) << "Weapon::bulletTimer started" << std::endl; 115 this->bReloading_ = true; 104 116 this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded))); 105 117 } … … 107 119 { 108 120 COUT(0) << "Weapon::magazineTimer started" << std::endl; 121 this->bReloading_ = true; 109 122 this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded))); 110 123 } 111 124 112 125 void Weapon::bulletReloaded() 113 { this->bulletReadyToShoot_ = true; } 126 { 127 this->bReloading_ = false; 128 this->bulletReadyToShoot_ = true; 129 } 114 130 115 131 void Weapon::magazineReloaded() 116 { 132 { 133 this->bReloading_ = false; 117 134 this->munition_->fillBullets(); 118 135 this->magazineReadyToShoot_ = true;
Note: See TracChangeset
for help on using the changeset viewer.