Changeset 2366 for code/branches/weapon2
- Timestamp:
- Dec 9, 2008, 5:44:34 PM (16 years ago)
- Location:
- code/branches/weapon2/src/orxonox/objects
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2354 r2366 84 84 void Weapon::attachNeededMunition(std::string munitionName) 85 85 { 86 COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl; 86 87 //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 87 88 if (this->parentWeaponSystem_) 88 89 { 90 COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl; 89 91 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 90 92 if ( munition ) -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h
r2354 r2366 70 70 Timer<Weapon> *getMagazineTimer(); 71 71 72 v oid setMunitionType(std::string munitionType);73 const std::string getMunitionType();72 virtual void setMunitionType(std::string munitionType); 73 virtual const std::string getMunitionType(); 74 74 75 75 inline void setParentWeaponSlot(WeaponSlot *parentWeaponSlot) -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.cc
r2354 r2366 92 92 void WeaponPack::addWeapon(Weapon * weapon) 93 93 { 94 weapon->setParentWeaponSystem(this->parentWeaponSystem_); 95 COUT(0) << "WeaponPack::addWeapon " << weapon << " munition " << weapon->getMunitionType() << std::endl; 94 COUT(0) << "WeaponPack::addWeapon:" << weapon << " munition " << weapon->getMunitionType() << std::endl; 96 95 this->weapons_.push_back(weapon); 97 96 } … … 102 101 } 103 102 104 void WeaponPack::set WeaponSystemToAllWeapons(WeaponSystem * weaponSystem)103 void WeaponPack::setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem) 105 104 { 106 105 for (int i=0; i < (int) this->weapons_.size(); i++) … … 110 109 111 110 } 111 112 void WeaponPack::attachNeededMunitionToAllWeapons() 113 { 114 for (int i=0; i < (int) this->weapons_.size(); i++) 115 { 116 this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType()); 117 } 118 119 } 120 112 121 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.h
r2354 r2366 59 59 const Weapon * getWeapon(unsigned int index); 60 60 61 void setWeaponSystemToAllWeapons(WeaponSystem * weaponSystem); 61 //functions needed for creating Pointer to the right objects (-->Pawn.cc) 62 void setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem); 63 void attachNeededMunitionToAllWeapons(); 62 64 63 65 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2337 r2366 56 56 { 57 57 COUT(0) << "WeaponSet::attachWeaponPack" << std::endl; 58 COUT(0) << "........ parentWeaponSystem_=" << this->parentWeaponSystem_ << std::endl; 59 COUT(0) << "........ this->parentWeaponSystem_->getWeaponSlotSize()" << this->parentWeaponSystem_->getWeaponSlotSize() << std::endl; 60 COUT(0) << "........ wPack->getSize()" << wPack->getSize() << std::endl; 58 61 if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) ) 59 62 { 63 COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl; 60 64 this->attachedWeaponPack_ = wPack; 61 65 int wPackWeapon = 0; //WeaponCounter for Attaching … … 78 82 { 79 83 //fires all WeaponSlots available for this weaponSet attached from the WeaponPack 80 COUT(0) << "WeaponSet::fire "<< std::endl;84 COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl; 81 85 this->attachedWeaponPack_->fire(); 82 86 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2337 r2366 62 62 void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int firemode) 63 63 { 64 wPack->setParentWeaponSystem(this);65 64 if (firemode < this->weaponSets_.size()) 66 65 this->weaponSets_[firemode]->attachWeaponPack(wPack); … … 88 87 Munition * WeaponSystem::getMunitionType(std::string munitionType) 89 88 { 89 COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl; 90 90 std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType); 91 91 if (it != this->munitionSet_.end()) -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2354 r2366 44 44 { 45 45 RegisterObject(LaserGun); 46 47 //set weapon properties here48 //this->setLoadingTime(0.5);49 50 COUT(0) << "LaserGun::LaserGun" << std::endl;51 this->attachNeededMunition(this->getMunitionType());52 46 } 53 47 … … 58 52 void LaserGun::fire() 59 53 { 60 COUT(0) << "LaserGun::fire "<< std::endl;54 COUT(0) << "LaserGun::fire, this=" << this << std::endl; 61 55 if ( this->getBulletReadyToShoot() && this->getMagazineReadyToShoot() ) 62 56 { … … 81 75 } 82 76 83 void LaserGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)84 {85 SUPER(LaserGun, XMLPort, xmlelement, mode);86 XMLPortParam(LaserGun, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);87 }88 89 void LaserGun::setMunitionType(std::string munitionType)90 {91 COUT(0) << "LaserGun::setMunitionType (XMLPort) "<< munitionType << std::endl;92 this->munitionType_ = munitionType; }93 94 const std::string LaserGun::getMunitionType()95 { return this->munitionType_; }96 97 77 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
r2354 r2366 48 48 virtual ~LaserGun(); 49 49 50 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);51 52 50 void fire(); 53 54 void setMunitionType(std::string munitionType);55 const std::string getMunitionType();56 51 57 52 private: -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2337 r2366 167 167 { 168 168 COUT(0) << "Pawn::setWeaponPack" << std::endl; 169 wPack->setParentWeaponSystem(this->weaponSystem_); 170 wPack->setParentWeaponSystemToAllWeapons(this->weaponSystem_); 169 171 this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() ); 170 wPack->setParentWeaponSystem(this->weaponSystem_); 171 wPack->setWeaponSystemToAllWeapons(this->weaponSystem_); 172 wPack->attachNeededMunitionToAllWeapons(); 172 173 } 173 174
Note: See TracChangeset
for help on using the changeset viewer.