- Timestamp:
- Mar 26, 2009, 2:56:39 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.cc
r2804 r2852 68 68 XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode); 69 69 XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode); 70 XMLPortParam(Weapon, "bSharedMunition", setSharedMunition, getSharedMunition, xmlelement, mode);71 70 XMLPortParam(Weapon, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode); 72 71 XMLPortParam(Weapon, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode); … … 88 87 void Weapon::fire() 89 88 { 90 COUT(0) << "Weapon::fire" << std::endl;91 89 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_) 92 90 { 93 COUT(0) << "Weapon::fire 2" << std::endl;94 91 this->bulletReadyToShoot_ = false; 95 92 if ( this->unlimitedMunition_== true ) 96 93 { 97 COUT(0) << "Weapon::fire 3" << std::endl;98 94 //shoot 99 95 this->reloadBullet(); … … 102 98 else 103 99 { 104 COUT(0) << "Weapon::fire 4" << std::endl;105 100 if ( this->munition_->bullets() > 0) 106 101 { 107 COUT(0) << "Weapon::fire 5" << std::endl; 108 //shoot 102 //shoot and reload 109 103 this->takeBullets(); 110 104 this->reloadBullet(); … … 114 108 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 ) 115 109 { 116 COUT(0) << "Weapon::fire 6" << std::endl; 110 //reload magazine 117 111 this->takeMagazines(); 118 112 this->reloadMagazine(); … … 126 120 else 127 121 { 128 COUT(0) << "Weapon::fire not reloaded" << std::endl;129 122 //weapon not reloaded 130 123 } … … 132 125 } 133 126 134 /* 135 * weapon reloading 136 */ 127 128 //weapon reloading 137 129 void Weapon::bulletTimer(float bulletLoadingTime) 138 130 { … … 156 148 this->bReloading_ = false; 157 149 this->munition_->fillBullets(); 158 this->magazineReadyToShoot_ = true; 159 this->bulletReadyToShoot_ = true; 160 } 150 } 151 161 152 162 153 … … 164 155 { 165 156 /* if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem 166 * if the weapon shares one munitionType put it into sharedMunitionSet else to munitionSet167 157 */ 168 158 if (this->parentWeaponSystem_) 169 159 { 170 if (this->bSharedMunition_ == false) 171 { 160 //getMunitionType returns 0 if there is no such munitionType 161 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 162 if ( munition ) 163 { 164 this->munition_ = munition; 165 this->setMunition(); 166 } 167 else 168 { 169 //create new munition with identifier because there is no such munitionType 172 170 this->munitionIdentifier_ = ClassByString(munitionName); 173 171 this->munition_ = this->munitionIdentifier_.fabricate(this); 174 172 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_); 175 } 176 else 177 { 178 //getMunitionType returns 0 if there is no such munitionType 179 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 180 if ( munition ) 181 this->munition_ = munition; 182 else 183 { 184 //create new munition with identifier because there is no such munitionType 185 this->munitionIdentifier_ = ClassByString(munitionName); 186 this->munition_ = this->munitionIdentifier_.fabricate(this); 187 this->parentWeaponSystem_->setNewSharedMunition(munitionName, this->munition_); 188 } 189 } 190 this->setMunition(); 173 this->setMunition(); 174 } 191 175 } 192 176 } … … 208 192 209 193 210 /*get and set functions 211 * 212 */ 194 //get and set functions for XMLPort 213 195 void Weapon::setMunitionType(std::string munitionType) 214 196 { this->munitionType_ = munitionType; } … … 229 211 { return this->magazineLoadingTime_; } 230 212 231 void Weapon::setSharedMunition(bool bSharedMunition)232 { this->bSharedMunition_ = bSharedMunition; }233 234 const bool Weapon::getSharedMunition()235 { return this->bSharedMunition_; }236 237 213 void Weapon::setBulletAmount(unsigned int amount) 238 214 { this->bulletAmount_ = amount; } … … 245 221 246 222 const unsigned int Weapon::getMagazineAmount() 247 { return this->magazineAmount_; }223 { return this->magazineAmount_; } 248 224 249 225 void Weapon::setUnlimitedMunition(bool unlimitedMunition)
Note: See TracChangeset
for help on using the changeset viewer.