- Timestamp:
- Dec 10, 2008, 2:38:33 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2366 r2379 60 60 } 61 61 62 void Weapon::setWeapon() 63 { 64 this->bulletLoadingTime_ = 0.5; 65 this->magazineLoadingTime_ = 3.0; 66 this->munition_->setMaxMagazines(100); 67 this->munition_->setMaxBullets(30); 68 this->munition_->fillBullets(); 69 this->munition_->fillMagazines(); 70 } 71 72 62 73 void Weapon::fire() 63 74 { 75 COUT(0) << "LaserGun::fire, this=" << this << std::endl; 76 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ ) 77 { 78 COUT(0) << "LaserGun::fire - ready to shoot" << std::endl; 79 80 this->bulletReadyToShoot_ = false; 81 if ( this->munition_->bullets() ) 82 { 83 //shoot 84 this->takeBullets(); 85 this->createProjectile(); 86 } 87 //if there are no bullets, but magazines 88 else if ( this->munition_->magazines() && !this->munition_->bullets() ) 89 { 90 this->takeMagazines(); 91 } 92 } 93 else 94 { 95 COUT(0) << "LaserGun::fire - weapon not reloaded" << std::endl; 96 } 64 97 65 98 } 66 99 67 100 68 void Weapon::bulletTimer( )101 void Weapon::bulletTimer(float bulletLoadingTime) 69 102 { 70 this->bulletReloadTimer_.setTimer( this->bulletLoadingTime_ , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded))); 103 COUT(0) << "Weapon::bulletTimer started" << std::endl; 104 this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded))); 71 105 } 72 void Weapon::magazineTimer( )106 void Weapon::magazineTimer(float magazineLoadingTime) 73 107 { 74 this->magazineReloadTimer_.setTimer( this->magazineLoadingTime_ , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded))); 108 COUT(0) << "Weapon::magazineTimer started" << std::endl; 109 this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded))); 75 110 } 76 111 … … 79 114 80 115 void Weapon::magazineReloaded() 81 { this->magazineReadyToShoot_ = true; } 116 { 117 this->munition_->fillBullets(); 118 this->magazineReadyToShoot_ = true; 119 } 82 120 83 121 … … 104 142 105 143 106 /*get and set functions144 /*get and set functions 107 145 * 108 146 */ … … 123 161 return this->munition_; } 124 162 163 164 125 165 void Weapon::setBulletLoadingTime(float loadingTime) 126 166 { this->bulletLoadingTime_ = loadingTime; } … … 135 175 { return this->magazineLoadingTime_; } 136 176 137 void Weapon::setBulletReadyToShoot(bool b)138 { this->bulletReadyToShoot_ = b; }139 140 bool Weapon::getBulletReadyToShoot()141 { return this->bulletReadyToShoot_; }142 143 void Weapon::setMagazineReadyToShoot(bool b)144 { this->magazineReadyToShoot_ = b; }145 146 bool Weapon::getMagazineReadyToShoot()147 { return this->magazineReadyToShoot_; }148 177 149 178 Timer<Weapon> * Weapon::getBulletTimer() … … 152 181 Timer<Weapon> * Weapon::getMagazineTimer() 153 182 { return &this->magazineReloadTimer_; } 183 184 void Weapon::takeBullets() { }; 185 void Weapon::createProjectile() { }; 186 void Weapon::takeMagazines() { }; 187 154 188 }
Note: See TracChangeset
for help on using the changeset viewer.