- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/orxonox/objects/weaponSystem/Munition.cc
r2907 r2908 105 105 void Munition::fillBullets() 106 106 { 107 //COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl; 107 108 this->bullets_ = this->maxBullets_; 108 109 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.cc
r2907 r2908 42 42 { 43 43 RegisterObject(Weapon); 44 45 44 this->bulletReadyToShoot_ = true; 46 45 this->magazineReadyToShoot_ = true; 47 46 this->parentWeaponSystem_ = 0; 48 47 this->attachedToWeaponSlot_ = 0; 48 this->munition_ = 0; 49 49 this->bulletLoadingTime_ = 0; 50 50 this->magazineLoadingTime_ = 0; 51 51 this->bReloading_ = false; 52 this->bulletAmount_= 0; 53 this->magazineAmount_ = 0; 54 this->munition_ = 0; 55 this->unlimitedMunition_ = false; 52 56 53 this->setObjectMode(0x0); 57 54 } … … 68 65 XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode); 69 66 XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode); 70 XMLPortParam(Weapon, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);71 XMLPortParam(Weapon, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);72 XMLPortParam(Weapon, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);73 67 } 74 68 … … 79 73 } 80 74 81 void Weapon::setMunition()82 {83 this->munition_->setMaxBullets(this->bulletAmount_);84 this->munition_->setMaxMagazines(this->magazineAmount_);85 }86 75 87 76 void Weapon::fire() 88 77 { 78 //COUT(0) << "LaserGun::fire, this=" << this << std::endl; 89 79 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_) 90 80 { 81 //COUT(0) << "LaserGun::fire - ready to shoot" << std::endl; 82 //COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl; 91 83 this->bulletReadyToShoot_ = false; 92 if ( this-> unlimitedMunition_== true)84 if ( this->munition_->bullets() > 0) 93 85 { 94 86 //shoot 95 this-> reloadBullet();87 this->takeBullets(); 96 88 this->createProjectile(); 89 } 90 //if there are no bullets, but magazines 91 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 ) 92 { 93 //COUT(0) << "LaserGun::fire - no bullets" << std::endl; 94 this->takeMagazines(); 97 95 } 98 96 else 99 97 { 100 if ( this->munition_->bullets() > 0) 101 { 102 //shoot and reload 103 this->takeBullets(); 104 this->reloadBullet(); 105 this->createProjectile(); 106 } 107 //if there are no bullets, but magazines 108 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 ) 109 { 110 //reload magazine 111 this->takeMagazines(); 112 this->reloadMagazine(); 113 } 114 else 115 { 116 //no magazines 117 } 98 //COUT(0) << "LaserGun::fire - no magazines" << std::endl; 99 //actions 118 100 } 119 101 } 120 102 else 121 103 { 122 //weapon not reloaded 104 //COUT(0) << "LaserGun::fire - weapon not reloaded - bullets remaining:" << this->munition_->bullets() << std::endl; 105 //actions 123 106 } 124 107 … … 126 109 127 110 128 //weapon reloading129 111 void Weapon::bulletTimer(float bulletLoadingTime) 130 112 { 113 //COUT(0) << "Weapon::bulletTimer started" << std::endl; 131 114 this->bReloading_ = true; 132 115 this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded))); … … 134 117 void Weapon::magazineTimer(float magazineLoadingTime) 135 118 { 119 //COUT(0) << "Weapon::magazineTimer started" << std::endl; 136 120 this->bReloading_ = true; 137 121 this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded))); … … 148 132 this->bReloading_ = false; 149 133 this->munition_->fillBullets(); 134 this->magazineReadyToShoot_ = true; 135 this->bulletReadyToShoot_ = true; 150 136 } 151 152 137 153 138 154 139 void Weapon::attachNeededMunition(std::string munitionName) 155 140 { 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 157 */141 //COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl; 142 //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 158 143 if (this->parentWeaponSystem_) 159 144 { 160 //getMunitionType returns 0 if there is no such munitionType 145 //COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl; 161 146 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 162 147 if ( munition ) 163 {164 148 this->munition_ = munition; 165 this->setMunition();166 }167 149 else 168 150 { 169 //create new munition with identifier because there is no such munitionType 151 //create new munition with identifier 152 //COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl; 170 153 this->munitionIdentifier_ = ClassByString(munitionName); 171 154 this->munition_ = this->munitionIdentifier_.fabricate(this); 172 155 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_); 173 this->setMunition();174 156 } 175 157 } … … 177 159 178 160 179 Munition * Weapon::getAttachedMunition(std::string munitionType) 180 { 181 this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType); 182 return this->munition_; 183 } 161 /*get and set functions 162 * 163 */ 184 164 185 186 //these function are defined in the weapon classes187 void Weapon::takeBullets() { };188 void Weapon::createProjectile() { };189 void Weapon::takeMagazines() { };190 void Weapon::reloadBullet() { };191 void Weapon::reloadMagazine() { };192 193 194 //get and set functions for XMLPort195 165 void Weapon::setMunitionType(std::string munitionType) 196 166 { this->munitionType_ = munitionType; } … … 211 181 { return this->magazineLoadingTime_; } 212 182 213 void Weapon::setBulletAmount(unsigned int amount)214 { this->bulletAmount_ = amount; }215 183 216 const unsigned int Weapon::getBulletAmount() 217 { return this->bulletAmount_; } 184 Munition * Weapon::getAttachedMunition(std::string munitionType) 185 { 186 //COUT(0) << "Weapon::getAttachedMunition, parentWeaponSystem_="<< this->parentWeaponSystem_ << std::endl; 187 this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType); 188 //COUT(0) << "Weapon::getAttachedMunition, munition_="<< this->munition_ << std::endl; 189 return this->munition_; 190 } 218 191 219 void Weapon::setMagazineAmount(unsigned int amount) 220 { this->magazineAmount_ = amount; } 221 222 const unsigned int Weapon::getMagazineAmount() 223 { return this->magazineAmount_; } 224 225 void Weapon::setUnlimitedMunition(bool unlimitedMunition) 226 { this->unlimitedMunition_ = unlimitedMunition; } 227 228 const bool Weapon::getUnlimitedMunition() 229 { return this->unlimitedMunition_; } 192 void Weapon::takeBullets() { }; 193 void Weapon::createProjectile() { }; 194 void Weapon::takeMagazines() { }; 230 195 231 196 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.h
r2907 r2908 62 62 void magazineReloaded(); 63 63 64 //XMLPort functions65 64 virtual void setMunitionType(std::string munitionType); 66 65 virtual const std::string getMunitionType(); … … 69 68 virtual void setMagazineLoadingTime(float loadingTime); 70 69 virtual const float getMagazineLoadingTime(); 71 virtual void setBulletAmount(unsigned int amount);72 virtual const unsigned int getBulletAmount();73 virtual void setMagazineAmount(unsigned int amount);74 virtual const unsigned int getMagazineAmount();75 virtual void setUnlimitedMunition(bool unlimitedMunition);76 virtual const bool getUnlimitedMunition();77 70 78 //weapon actions79 71 virtual void takeBullets(); 80 72 virtual void takeMagazines(); 81 73 virtual void createProjectile(); 82 virtual void reloadBullet();83 virtual void reloadMagazine();84 74 85 //manually set or reset86 virtual void setWeapon();87 virtual void setMunition();88 89 75 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) 90 76 { this->parentWeaponSystem_=parentWeaponSystem; }; … … 97 83 { return this->attachedToWeaponSlot_; } 98 84 85 virtual void setWeapon(); 99 86 100 87 private: … … 104 91 bool bulletReadyToShoot_; 105 92 bool magazineReadyToShoot_; 106 bool unlimitedMunition_;107 93 float bulletLoadingTime_; 108 94 float magazineLoadingTime_; 109 unsigned int bulletAmount_;110 unsigned int magazineAmount_;111 95 std::string munitionType_; 112 96 -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.cc
r2907 r2908 63 63 for (int i=0; i < (int) this->weapons_.size(); i++) 64 64 { 65 //COUT(0) << "WeaponPack::fire (attached from WeaponSet) from Weapon: "<< i << std::endl; 65 66 this->weapons_[i]->getAttachedToWeaponSlot()->fire(); 66 67 } … … 82 83 void WeaponPack::setFireMode(unsigned int firemode) 83 84 { 85 //COUT(0) << "WeaponPack::setFireMode " << std::endl; 84 86 this->firemode_ = firemode; 85 87 } … … 92 94 void WeaponPack::addWeapon(Weapon * weapon) 93 95 { 96 //COUT(0) << "WeaponPack::addWeapon:" << weapon << " munition " << weapon->getMunitionType() << std::endl; 94 97 this->weapons_.push_back(weapon); 95 98 } … … 114 117 { 115 118 this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType()); 119 //hack! 116 120 this->weapons_[i]->setWeapon(); 117 121 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.h
r2907 r2908 59 59 const Weapon * getWeapon(unsigned int index); 60 60 61 //functions with effect to all weapons of the weaponPack62 61 //functions needed for creating Pointer to the right objects (-->Pawn.cc) 63 62 void setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem); -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2907 r2908 56 56 void WeaponSet::attachWeaponPack(WeaponPack *wPack) 57 57 { 58 //COUT(0) << "WeaponSet::attachWeaponPack" << std::endl; 59 //COUT(0) << "........ parentWeaponSystem_=" << this->parentWeaponSystem_ << std::endl; 60 //COUT(0) << "........ this->parentWeaponSystem_->getWeaponSlotSize()" << this->parentWeaponSystem_->getWeaponSlotSize() << std::endl; 61 //COUT(0) << "........ wPack->getSize()" << wPack->getSize() << std::endl; 58 62 if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) ) 59 63 { 64 //COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl; 60 65 this->attachedWeaponPack_ = wPack; 61 66 int wPackWeapon = 0; //WeaponCounter for Attaching 62 63 67 //should be possible to choose which slot to use 64 //attach every weapon of the weaponPack to a weaponSlot65 68 for ( int i=0; i < wPack->getSize() ; i++ ) 66 69 { 67 70 //at the moment this function only works for one weaponPack in the entire WeaponSystem... 68 //it also takes the first free weaponSlot...69 71 if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full 70 72 { 73 //COUT(0) << "WeaponSet::attachWeaponPack attaching Weapon" << std::endl; 71 74 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) ); 72 75 this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); … … 80 83 if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 ) 81 84 { 85 //COUT(0) << "WeaponSet::attachWeaponPack mode 2 k="<< k << std::endl; 82 86 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(k) ); 83 87 this->parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); … … 95 99 { 96 100 //fires all WeaponSlots available for this weaponSet attached from the WeaponPack 101 //COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl; 97 102 if (this->attachedWeaponPack_) 98 103 this->attachedWeaponPack_->fire(); -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.cc
- Property svn:mergeinfo changed
r2907 r2908 38 38 39 39 40 /* WeaponSystem 40 /* WEAPONSYSTEM 41 * creates the WeaponSystem and the ability to use weapons and munition 42 * loads the weapon the whole weaponSystem setting from an xml file 41 43 * 42 * www.orxonox.net/wiki/WeaponSystem43 44 */ 44 45 … … 51 52 RegisterObject(WeaponSystem); 52 53 54 this->activeWeaponSet_ = 0; 53 55 this->parentPawn_ = 0; 54 56 } … … 82 84 } 83 85 84 85 //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition 86 //returns the Pointer to the munitionType 86 87 Munition * WeaponSystem::getMunitionType(std::string munitionType) 87 88 { 89 //COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl; 88 90 std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType); 89 91 if (it != this->munitionSet_.end()) … … 94 96 95 97 98 /* 99 //the first weaponSet is at n=0 100 void WeaponSystem::setActiveWeaponSet(unsigned int n) 101 { 102 if (n < this->weaponSets_.size()) 103 this->activeWeaponSet_ = this->weaponSets_[n]; 104 else 105 this->activeWeaponSet_ = this->weaponSets_[0]; 106 } 107 */ 108 109 96 110 //n is the n'th weaponSet, starting with zero 97 //SpaceShip.cc only needs to have the keybinding to a specific Set-number n (=firemode) 98 //in future this could be well defined and not only for 3 different WeaponModes 111 //SpaceShip.cc only needs to have the keybinding to a specific Set-number n 99 112 void WeaponSystem::fire(WeaponMode::Enum n) 100 113 { … … 112 125 break; 113 126 } 127 //COUT(0) << "WeaponSystem::fire" << std::endl; 114 128 if (set < (int)this->weaponSets_.size()) 129 //COUT(0) << "WeaponSystem::fire - after if" << std::endl; 115 130 this->weaponSets_[set]->fire(); 116 131 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.h
- Property svn:mergeinfo changed
r2907 r2908 53 53 //void fire(); 54 54 void fire(WeaponMode::Enum fireMode); 55 //void setActiveWeaponSet(unsigned int n); 55 56 void attachWeaponPack(WeaponPack * wPack, unsigned int firemode); 56 57 WeaponSet * getWeaponSetPointer(unsigned int n); … … 58 59 WeaponPack * getWeaponPackPointer(unsigned int n); 59 60 void setNewMunition(std::string munitionType, Munition * munitionToAdd); 60 void setNewSharedMunition(std::string munitionType, Munition * munitionToAdd);61 61 Munition * getMunitionType(std::string munitionType); 62 62 … … 74 74 std::vector<WeaponPack *> weaponPacks_; 75 75 std::map<std::string, Munition *> munitionSet_; 76 WeaponSet *activeWeaponSet_; 76 77 Pawn *parentPawn_; 77 78 }; -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt
r2907 r2908 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 LaserGunMunition.cc 3 FusionMunition.cc4 3 ) -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
r2907 r2908 43 43 RegisterObject(LaserGunMunition); 44 44 45 //default if not defined in XML46 45 this->maxBullets_ = 40; 47 46 this->maxMagazines_ = 100; -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
r2907 r2908 32 32 #include <OgreBillboardSet.h> 33 33 34 #include "core/ GameMode.h"34 #include "core/Core.h" 35 35 #include "core/CoreIncludes.h" 36 36 #include "objects/Scene.h" … … 44 44 RegisterObject(BillboardProjectile); 45 45 46 if ( GameMode::showsGraphics())46 if (Core::showsGraphics()) 47 47 { 48 48 assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity … … 56 56 BillboardProjectile::~BillboardProjectile() 57 57 { 58 if (this->isInitialized() && GameMode::showsGraphics() && this->billboard_.getBillboardSet())58 if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet()) 59 59 this->detachOgreObject(this->billboard_.getBillboardSet()); 60 60 } -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
r2907 r2908 33 33 #include <OgreParticleEmitter.h> 34 34 35 #include "core/ GameMode.h"35 #include "core/Core.h" 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/ConfigValueIncludes.h" … … 46 46 RegisterObject(ParticleProjectile); 47 47 48 if ( GameMode::showsGraphics())48 if (Core::showsGraphics()) 49 49 { 50 50 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal); -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
r2907 r2908 41 41 #include "objects/worldentities/ParticleSpawner.h" 42 42 #include "objects/collisionshapes/SphereCollisionShape.h" 43 #include "core/ GameMode.h"43 #include "core/Core.h" 44 44 45 45 namespace orxonox … … 55 55 // Get notification about collisions 56 56 57 if ( GameMode::isMaster())57 if (Core::isMaster()) 58 58 { 59 59 this->enableCollisionCallback(); … … 93 93 void Projectile::destroyObject() 94 94 { 95 if ( GameMode::isMaster())95 if (Core::isMaster()) 96 96 delete this; 97 97 } … … 99 99 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 100 100 { 101 if (!this->bDestroy_ && GameMode::isMaster())101 if (!this->bDestroy_ && Core::isMaster()) 102 102 { 103 103 this->bDestroy_ = true; -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2907 r2908 53 53 } 54 54 55 void LaserGun::reloadBullet()56 {57 this->bulletTimer(this->bulletLoadingTime_);58 }59 60 void LaserGun::reloadMagazine()61 {62 this->magazineTimer(this->magazineLoadingTime_);63 }64 65 55 void LaserGun::takeBullets() 66 56 { 57 //COUT(0) << "LaserGun::takeBullets" << std::endl; 67 58 this->munition_->removeBullets(1); 59 this->bulletTimer(this->bulletLoadingTime_); 68 60 } 69 61 … … 71 63 { 72 64 this->munition_->removeMagazines(1); 65 this->magazineTimer(this->magazineLoadingTime_); 73 66 } 74 67 75 68 void LaserGun::createProjectile() 76 69 { 70 //COUT(0) << "LaserGun::createProjectile" << std::endl; 77 71 BillboardProjectile* projectile = new ParticleProjectile(this); 78 72 projectile->setOrientation(this->getWorldOrientation()); -
code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
r2907 r2908 51 51 virtual void takeMagazines(); 52 52 virtual void createProjectile(); 53 virtual void reloadBullet();54 virtual void reloadMagazine();55 53 56 54 private:
Note: See TracChangeset
for help on using the changeset viewer.