Changeset 2288 for code/branches/weapon2/src/orxonox/objects
- Timestamp:
- Nov 26, 2008, 7:42:29 PM (16 years ago)
- Location:
- code/branches/weapon2/src/orxonox/objects
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2232 r2288 96 96 */ 97 97 void Weapon::setParentWeaponSystem() 98 { this->parentWeaponSystem_ = this->parentWeaponSlot_->getParentWeaponS et()->getParentWeaponSystem(); }98 { this->parentWeaponSystem_ = this->parentWeaponSlot_->getParentWeaponSystem(); } 99 99 100 100 Munition * Weapon::getAttachedMunition() -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2232 r2288 35 35 36 36 #include "WeaponSet.h" 37 #include "WeaponPack.h" 37 38 38 39 namespace orxonox … … 44 45 this->parentWeaponSystem_ = 0; 45 46 46 /* will be made with XML47 for (int i=0;i<k;i++)48 {49 attachWeaponSlot(new WeaponSlot(this));50 }51 */52 47 } 53 48 … … 56 51 } 57 52 58 void WeaponSet::attachWeapon Slot(WeaponSlot *wSlot)53 void WeaponSet::attachWeaponPack(WeaponPack *wPack) 59 54 { 60 this->weaponSlots_.push_back(wSlot); 55 if (this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) ) 56 { 57 //should be possible to choose which slot to use 58 for ( int i=0; i < wPack->getSize() ; i++ ) 59 { 60 this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(i) ); 61 } 62 } 61 63 } 62 64 65 /* this function will be in WeaponPack 63 66 void WeaponSet::fire() 64 67 { 65 68 for (int i=0; i < (int) this->weaponSlots_.size(); i++) 66 69 { 70 COUT(0) << "WeaponSlot::fire"<< i << std::endl; 67 71 this->weaponSlots_[i]->fire(); 68 72 } 69 73 } 70 71 WeaponSlot * WeaponSet::getWeaponSlotPointer(unsigned int n) 72 { 73 if (n < this->weaponSlots_.size()) 74 return this->weaponSlots_[n]; 75 else 76 return 0; 77 } 78 74 */ 79 75 80 76 void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode) -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.h
r2106 r2288 48 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 49 50 void attachWeapon Slot(WeaponSlot *wSlot);50 void attachWeaponPack(WeaponPack *wPack); 51 51 void fire(); 52 WeaponSlot * getWeaponSlotPointer(unsigned int n);53 52 54 53 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) … … 58 57 59 58 private: 60 std::vector<WeaponSlot *> weaponSlots_;61 59 WeaponSystem *parentWeaponSystem_; 62 60 }; -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2232 r2288 44 44 this->unlimitedAmmo_ = false; 45 45 this->attachedWeapon_ = 0; 46 this->parentWeaponSet_ = 0;47 46 this->setObjectMode(0x0); 48 47 } … … 65 64 void WeaponSlot::fire() 66 65 { 66 COUT(0) << "WeaponSlot::fire" << std::endl; 67 67 this->attachedWeapon_->fire(); 68 68 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.h
r2232 r2288 50 50 void fire(); 51 51 52 inline void setParentWeaponS et(WeaponSet *parentWeaponSet)53 { parentWeaponS et_=parentWeaponSet; }54 inline WeaponS et * getParentWeaponSet()55 { return parentWeaponS et_; }52 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) 53 { parentWeaponSystem_=parentWeaponSystem; } 54 inline WeaponSystem * getParentWeaponSystem() 55 { return parentWeaponSystem_; } 56 56 57 57 … … 60 60 bool unlimitedAmmo_; 61 61 62 WeaponS et *parentWeaponSet_;62 WeaponSystem *parentWeaponSystem_; 63 63 }; 64 64 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2272 r2288 36 36 37 37 #include "WeaponSystem.h" 38 #include "WeaponPack.h" 38 39 39 40 /* WEAPONSYSTEM … … 56 57 WeaponSystem::~WeaponSystem() 57 58 { 59 } 60 61 void WeaponSystem::attachWeaponPack(WeaponPack *wPack, int setNumber) 62 { 63 this->weaponSets_[setNumber]->attachWeaponPack(wPack); 64 } 65 66 void WeaponSystem::attachWeaponSlot(WeaponSlot *wSlot) 67 { 68 this->weaponSlots_.push_back(wSlot); 69 wSlot->setParentWeaponSystem(this); 58 70 } 59 71 … … 90 102 void WeaponSystem::fire(WeaponMode::Enum n) 91 103 { 104 COUT(0) << "WeaponSystem::fire" << std::endl; 92 105 if (n < (int)this->weaponSets_.size()) 93 this->weaponSets_[n]->fire(); 106 COUT(0) << "WeaponSystem::fire - after if" << std::endl; 107 //this->weaponSets_[n]->fire(); 94 108 } 95 109 … … 103 117 } 104 118 119 WeaponSlot * WeaponSystem::getWeaponSlotPointer(unsigned int n) 120 { 121 if (n < this->weaponSlots_.size()) 122 return this->weaponSlots_[n]; 123 else 124 return 0; 125 } 126 105 127 void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 106 128 { -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.h
r2203 r2288 48 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 49 50 void attachWeaponSlot(WeaponSlot *wSlot); 50 51 void attachWeaponSet(WeaponSet *wSet); 51 void fire();52 //void fire(); 52 53 void fire(WeaponMode::Enum fireMode); 53 54 //void setActiveWeaponSet(unsigned int n); 55 void attachWeaponPack(WeaponPack * wPack, int setNumber); 54 56 WeaponSet * getWeaponSetPointer(unsigned int n); 57 WeaponSlot * getWeaponSlotPointer(unsigned int n); 55 58 56 59 void setNewMunition(std::string munitionType, Munition * munitionToAdd); … … 62 65 { return parentSpaceShip_; } 63 66 67 inline int getWeaponSlotSize() 68 { return this->weaponSlots_.size(); } 64 69 65 70 private: 66 71 std::vector<WeaponSet *> weaponSets_; 72 std::vector<WeaponSlot *> weaponSlots_; 67 73 std::map<std::string, Munition *> munitionSet_; 68 74 WeaponSet *activeWeaponSet_; -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2272 r2288 56 56 void LaserGun::fire() 57 57 { 58 COUT(0) << "LaserGun::fire" << std::endl; 58 59 if ( this->getBulletReadyToShoot() && this->getMagazineReadyToShoot() ) 59 60 { -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2273 r2288 52 52 53 53 this->lastHitOriginator_ = 0; 54 this->weaponSystem_ = 0;55 54 56 55 //WeaponSystem … … 58 57 WeaponSet * weaponSet1 = new WeaponSet(this,1); 59 58 this->weaponSystem_->attachWeaponSet(weaponSet1); 59 //totally bad solution... 60 weaponSet1->setParentWeaponSystem(weaponSystem_); 60 61 61 62 … … 74 75 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 75 76 XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); 76 } 77 78 XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode); 79 //XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode); 80 81 } 77 82 78 83 void Pawn::registerVariables() … … 137 142 void Pawn::fire(WeaponMode::Enum fireMode) 138 143 { 144 COUT(0) << "Pawn::fire" << std::endl; 139 145 if (this->weaponSystem_) 140 146 this->weaponSystem_->fire(fireMode); … … 146 152 this->spawn(); 147 153 } 154 155 void Pawn::setWeaponSlot(WeaponSlot * wSlot) 156 { 157 this->weaponSystem_->attachWeaponSlot(wSlot); 158 } 159 160 WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const 161 { 162 return this->weaponSystem_->getWeaponSlotPointer(index); 163 } 164 148 165 } -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.h
r2145 r2288 79 79 virtual void postSpawn(); 80 80 81 void setWeaponSlot(WeaponSlot * wSlot); 82 WeaponSlot * getWeaponSlot(unsigned int index) const; 83 81 84 protected: 82 85 virtual void spawn(); -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2087 r2288 169 169 } 170 170 171 void Spectator::fire( )171 void Spectator::fire(WeaponMode::Enum fireMode) 172 172 { 173 173 if (this->getPlayer()) -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Spectator.h
r2087 r2288 56 56 virtual void rotateRoll(const Vector2& value); 57 57 58 virtual void fire( );58 virtual void fire(WeaponMode::Enum fireMode); 59 59 virtual void greet(); 60 60
Note: See TracChangeset
for help on using the changeset viewer.