Changeset 2319 for code/branches/weapon2
- Timestamp:
- Dec 3, 2008, 3:11:48 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/WeaponPack.cc
r2288 r2319 35 35 36 36 #include "WeaponPack.h" 37 #include "objects/worldentities/pawns/Pawn.h" 37 38 38 39 namespace orxonox … … 43 44 44 45 this->parentWeaponSystem_ = 0; 46 this->firemode_ = 1; 45 47 46 48 } … … 76 78 void WeaponPack::XMLPort(Element& xmlelement, XMLPort::Mode mode) 77 79 { 78 80 XMLPortObject(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode); 81 XMLPortParam(WeaponPack, "firemode", setFireMode, getFireMode, xmlelement, mode); 79 82 } 80 83 84 void WeaponPack::setFireMode(unsigned int firemode) 85 { 86 this->firemode_ = firemode; 87 } 88 89 unsigned int WeaponPack::getFireMode() 90 { 91 return this->firemode_; 92 } 93 94 void WeaponPack::addWeapon(Weapon * weapon) 95 { 96 this->weapons_.push_back(weapon); 97 } 98 99 Weapon * WeaponPack::getWeapon(unsigned int index) 100 { 101 return weapons_[index]; 102 } 81 103 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.h
r2288 r2319 54 54 void attachWeapon(Weapon *weapon); 55 55 56 void setFireMode(unsigned int firemode); 57 unsigned int getFireMode(); 58 59 void addWeapon(Weapon * weapon); 60 Weapon * getWeapon(unsigned int index); 61 56 62 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) 57 63 { parentWeaponSystem_=parentWeaponSystem; } … … 62 68 std::vector<Weapon *> weapons_; 63 69 WeaponSystem *parentWeaponSystem_; 70 unsigned int firemode_; 64 71 }; 65 72 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2308 r2319 53 53 void WeaponSet::attachWeaponPack(WeaponPack *wPack) 54 54 { 55 if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )55 if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) ) 56 56 { 57 57 this->attachedWeaponPack_ = wPack; 58 int wPackWeapon = 0; //WeaponCounter for Attaching 58 59 //should be possible to choose which slot to use 59 60 for ( int i=0; i < wPack->getSize() ; i++ ) 60 61 { 61 62 //at the moment this function only works for one weaponPack in the entire WeaponSystem... 62 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) ); 63 this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(i) ); 63 if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() != 0 ) //if slot not full 64 { 65 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) ); 66 this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); 67 wPackWeapon++; 68 } 64 69 } 65 70 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2308 r2319 69 69 70 70 71 //XMLPort functions72 71 void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode) 73 72 { … … 78 77 { this->attachedWeapon_ = weaponPointer; } 79 78 80 Weapon * WeaponSlot::getAttachedWeapon( unsigned int index) const79 Weapon * WeaponSlot::getAttachedWeapon() const 81 80 { return this->attachedWeapon_; } 82 81 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.h
r2288 r2319 46 46 47 47 void attachWeapon(Weapon *weaponPointer); 48 Weapon * getAttachedWeapon( unsigned int index) const;48 Weapon * getAttachedWeapon() const; 49 49 void setAmmoType(bool isUnlimited); 50 50 void fire(); -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2308 r2319 36 36 37 37 #include "WeaponSystem.h" 38 #include "WeaponPack.h" 38 39 39 40 40 /* WEAPONSYSTEM … … 52 52 53 53 this->activeWeaponSet_ = 0; 54 this->parent SpaceShip_ = 0;54 this->parentPawn_ = 0; 55 55 } 56 56 … … 59 59 } 60 60 61 void WeaponSystem::attachWeaponPack(WeaponPack *wPack, int setNumber)61 void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int firemode) 62 62 { 63 this->weaponSets_[setNumber]->attachWeaponPack(wPack); 63 this->weaponSets_[firemode]->attachWeaponPack(wPack); 64 this->weaponPacks_[firemode] = wPack; 65 wPack->setParentWeaponSystem(this); 64 66 } 65 67 … … 125 127 } 126 128 129 WeaponPack * WeaponSystem::getWeaponPackPointer(unsigned int n) 130 { 131 if (n < this->weaponPacks_.size()) 132 return this->weaponPacks_[n]; 133 else 134 return 0; 135 } 136 127 137 void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 128 138 { -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.h
r2288 r2319 36 36 37 37 #include "WeaponSet.h" 38 #include "WeaponPack.h" 38 39 39 40 namespace orxonox … … 53 54 void fire(WeaponMode::Enum fireMode); 54 55 //void setActiveWeaponSet(unsigned int n); 55 void attachWeaponPack(WeaponPack * wPack, int setNumber);56 void attachWeaponPack(WeaponPack * wPack, unsigned int firemode); 56 57 WeaponSet * getWeaponSetPointer(unsigned int n); 57 58 WeaponSlot * getWeaponSlotPointer(unsigned int n); 58 59 WeaponPack * getWeaponPackPointer(unsigned int n); 59 60 void setNewMunition(std::string munitionType, Munition * munitionToAdd); 60 61 Munition * getMunitionType(std::string munitionType); 61 62 62 inline void setParent SpaceShip(SpaceShip *parentSpaceShip)63 { parent SpaceShip_=parentSpaceShip; }64 inline SpaceShip * getParentSpaceShip()65 { return parent SpaceShip_; }63 inline void setParentPawn(Pawn *parentPawn) 64 { parentPawn_=parentPawn; } 65 inline Pawn * getParentPawn() 66 { return parentPawn_; } 66 67 67 68 inline int getWeaponSlotSize() … … 71 72 std::vector<WeaponSet *> weaponSets_; 72 73 std::vector<WeaponSlot *> weaponSlots_; 74 std::vector<WeaponPack *> weaponPacks_; 73 75 std::map<std::string, Munition *> munitionSet_; 74 76 WeaponSet *activeWeaponSet_; 75 SpaceShip *parentSpaceShip_;77 Pawn *parentPawn_; 76 78 }; 77 79 } -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2308 r2319 78 78 XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode); 79 79 XMLPortObject(Pawn, WeaponSet, "weaponsets", setWeaponSet, getWeaponSet, xmlelement, mode); 80 //XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode);80 XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode); 81 81 82 82 } … … 155 155 156 156 157 157 158 void Pawn::setWeaponSlot(WeaponSlot * wSlot) 158 159 { this->weaponSystem_->attachWeaponSlot(wSlot); } 159 160 WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const 160 161 { return this->weaponSystem_->getWeaponSlotPointer(index); } 161 162 /* 162 163 163 void Pawn::setWeaponPack(WeaponPack * wPack) 164 { this->weaponSystem_->attachWeaponPack(wPack); } 165 WeaponPack * Pawn::getWeaponPack(unsigned int index) const 166 { return this->weaponSystem_->getWeaponPackPointer(index); 167 */ 168 164 { this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() ); } 165 WeaponPack * Pawn::getWeaponPack(unsigned int firemode) const 166 { return this->weaponSystem_->getWeaponPackPointer(firemode); } 167 169 168 void Pawn::setWeaponSet(WeaponSet * wSet) 170 169 { this->weaponSystem_->attachWeaponSet(wSet); } -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.h
r2308 r2319 81 81 void setWeaponSlot(WeaponSlot * wSlot); 82 82 WeaponSlot * getWeaponSlot(unsigned int index) const; 83 //void setWeaponPack(WeaponPack * wPack);84 // WeaponPack * getWeaponPack(unsigned int index) const;83 void setWeaponPack(WeaponPack * wPack); 84 WeaponPack * getWeaponPack(unsigned int firemode) const; 85 85 void setWeaponSet(WeaponSet * wSet); 86 86 WeaponSet * getWeaponSet(unsigned int index) const;
Note: See TracChangeset
for help on using the changeset viewer.