Changeset 2852 for code/branches/weaponsystem/src
- Timestamp:
- Mar 26, 2009, 2:56:39 PM (16 years ago)
- Location:
- code/branches/weaponsystem/src/orxonox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weaponsystem/src/orxonox/OrxonoxPrereqs.h
r2710 r2852 175 175 class LaserGun; 176 176 class LaserGunMunition; 177 class FusionMunition; 177 178 178 179 class EventListener; -
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) -
code/branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.h
r2804 r2852 69 69 virtual void setMagazineLoadingTime(float loadingTime); 70 70 virtual const float getMagazineLoadingTime(); 71 virtual void setSharedMunition(bool bSharedMunition);72 virtual const bool getSharedMunition();73 71 virtual void setBulletAmount(unsigned int amount); 74 72 virtual const unsigned int getBulletAmount(); … … 106 104 bool bulletReadyToShoot_; 107 105 bool magazineReadyToShoot_; 108 bool bSharedMunition_;109 106 bool unlimitedMunition_; 110 107 float bulletLoadingTime_; -
code/branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2804 r2852 82 82 } 83 83 84 void WeaponSystem::setNewSharedMunition(std::string munitionType, Munition * munitionToAdd)85 {86 this->munitionSharedSet_[munitionType] = munitionToAdd;87 }88 84 89 85 //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition 90 86 Munition * WeaponSystem::getMunitionType(std::string munitionType) 91 87 { 92 std::map<std::string, Munition *>::const_iterator it = this->munitionS haredSet_.find(munitionType);93 if (it != this->munitionS haredSet_.end())88 std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType); 89 if (it != this->munitionSet_.end()) 94 90 return it->second; 95 91 else 96 92 return 0; 97 93 } 98 99 100 101 94 102 95 -
code/branches/weaponsystem/src/orxonox/objects/weaponSystem/WeaponSystem.h
r2804 r2852 73 73 std::vector<WeaponSlot *> weaponSlots_; 74 74 std::vector<WeaponPack *> weaponPacks_; 75 std::map<std::string, Munition *> munitionSharedSet_;76 75 std::map<std::string, Munition *> munitionSet_; 77 76 Pawn *parentPawn_; -
code/branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
r2710 r2852 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 LaserGunMunition.cc 3 FusionMunition.cc 3 4 ) -
code/branches/weaponsystem/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
r2662 r2852 43 43 RegisterObject(LaserGunMunition); 44 44 45 //default if not defined in XML 45 46 this->maxBullets_ = 40; 46 47 this->maxMagazines_ = 100;
Note: See TracChangeset
for help on using the changeset viewer.