Changeset 2391 for code/branches/weapon2
- Timestamp:
- Dec 10, 2008, 5:30:39 PM (16 years ago)
- Location:
- code/branches/weapon2/src/orxonox/objects
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/objects/weaponSystem/Munition.cc
r2379 r2391 46 46 } 47 47 48 boolMunition::bullets()48 unsigned int Munition::bullets() 49 49 { 50 50 if (this->bullets_ > 0) 51 return true;51 return bullets_; 52 52 else 53 return false;53 return 0; 54 54 } 55 55 56 boolMunition::magazines()56 unsigned int Munition::magazines() 57 57 { 58 58 if (this->magazines_ > 0) 59 return true;59 return magazines_; 60 60 else 61 return false;61 return 0; 62 62 } 63 63 … … 68 68 { this->maxMagazines_ = amount; } 69 69 70 void Munition::removeBullets(unsigned int amount , Weapon * parentWeapon)70 void Munition::removeBullets(unsigned int amount) 71 71 { 72 if ( this->bullets_ == 0 ) 73 { 74 this->removeMagazines(1); 75 parentWeapon->magazineTimer(0); 76 this->bullets_ = this->maxBullets_; 77 } 78 else 72 if ( this->bullets_ != 0 ) 79 73 this->bullets_ = this->bullets_ - amount; 80 74 } … … 82 76 void Munition::removeMagazines(unsigned int amount) 83 77 { 84 if ( this->magazines_ == 0 ) 85 { 86 if ( this->bullets_ == 0 ) 87 { 88 //no bullets and no magazines 89 } 90 else 91 { 92 //what to do when there are no more magazines? 93 } 94 } 95 else 78 if ( this->magazines_ != 0 ) 96 79 this->magazines_ = this->magazines_ - amount; 97 80 } … … 120 103 void Munition::fillBullets() 121 104 { 105 COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl; 122 106 this->bullets_ = this->maxBullets_; 123 107 } … … 130 114 void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode) 131 115 { 132 116 SUPER(Munition, XMLPort, xmlelement, mode); 133 117 } 134 118 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Munition.h
r2379 r2391 53 53 void fillMagazines(); 54 54 55 boolbullets();56 boolmagazines();55 unsigned int bullets(); 56 unsigned int magazines(); 57 57 58 void removeBullets(unsigned int k , Weapon * parentWeapon);58 void removeBullets(unsigned int k); 59 59 void removeMagazines(unsigned int k); 60 60 void addBullets(unsigned int k); -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2379 r2391 39 39 CreateFactory(Weapon); 40 40 41 Weapon::Weapon(BaseObject* creator) : BaseObject(creator)41 Weapon::Weapon(BaseObject* creator) : PositionableEntity(creator) 42 42 { 43 43 RegisterObject(Weapon); … … 47 47 this->parentWeaponSlot_ = 0; 48 48 this->munition_ = 0; 49 this->bulletLoadingTime_ = 0; 50 this->magazineLoadingTime_ = 0; 51 this->bReloading_ = false; 49 52 } 50 53 … … 62 65 void Weapon::setWeapon() 63 66 { 67 COUT(0) << "LaserGun::setWeapon" << std::endl; 64 68 this->bulletLoadingTime_ = 0.5; 65 69 this->magazineLoadingTime_ = 3.0; 66 70 this->munition_->setMaxMagazines(100); 67 this->munition_->setMaxBullets( 30);71 this->munition_->setMaxBullets(6); 68 72 this->munition_->fillBullets(); 69 73 this->munition_->fillMagazines(); … … 74 78 { 75 79 COUT(0) << "LaserGun::fire, this=" << this << std::endl; 76 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ )80 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_) 77 81 { 78 82 COUT(0) << "LaserGun::fire - ready to shoot" << std::endl; 79 83 COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl; 80 84 this->bulletReadyToShoot_ = false; 81 if ( this->munition_->bullets() )85 if ( this->munition_->bullets() > 0) 82 86 { 83 87 //shoot … … 86 90 } 87 91 //if there are no bullets, but magazines 88 else if ( this->munition_->magazines() && !this->munition_->bullets() ) 89 { 92 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 ) 93 { 94 COUT(0) << "LaserGun::fire - no bullets" << std::endl; 90 95 this->takeMagazines(); 96 } 97 else 98 { 99 COUT(0) << "LaserGun::fire - no magazines" << std::endl; 100 //actions 91 101 } 92 102 } … … 94 104 { 95 105 COUT(0) << "LaserGun::fire - weapon not reloaded" << std::endl; 106 //actions 96 107 } 97 108 … … 102 113 { 103 114 COUT(0) << "Weapon::bulletTimer started" << std::endl; 115 this->bReloading_ = true; 104 116 this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded))); 105 117 } … … 107 119 { 108 120 COUT(0) << "Weapon::magazineTimer started" << std::endl; 121 this->bReloading_ = true; 109 122 this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded))); 110 123 } 111 124 112 125 void Weapon::bulletReloaded() 113 { this->bulletReadyToShoot_ = true; } 126 { 127 this->bReloading_ = false; 128 this->bulletReadyToShoot_ = true; 129 } 114 130 115 131 void Weapon::magazineReloaded() 116 { 132 { 133 this->bReloading_ = false; 117 134 this->munition_->fillBullets(); 118 135 this->magazineReadyToShoot_ = true; -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h
r2379 r2391 40 40 #include "Munition.h" 41 41 42 #include "objects/worldentities/PositionableEntity.h" 43 42 44 namespace orxonox 43 45 { 44 class _OrxonoxExport Weapon : public BaseObject46 class _OrxonoxExport Weapon : public PositionableEntity 45 47 { 46 48 public: … … 82 84 { return this->parentWeaponSystem_; }; 83 85 84 //in future by XMLPort ,86 //in future by XMLPort 85 87 virtual void setWeapon(); 86 88 … … 92 94 float bulletLoadingTime_; 93 95 float magazineLoadingTime_; 96 bool bReloading_; 97 94 98 Munition *munition_; 95 99 std::string munitionType_; -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.cc
r2366 r2391 75 75 void WeaponPack::XMLPort(Element& xmlelement, XMLPort::Mode mode) 76 76 { 77 SUPER(WeaponPack, XMLPort, xmlelement, mode); 78 77 79 XMLPortObject(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode); 78 80 XMLPortParam(WeaponPack, "firemode", setFireMode, getFireMode, xmlelement, mode); … … 115 117 { 116 118 this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType()); 119 //hack! 120 this->weapons_[i]->setWeapon(); 117 121 } 118 122 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2366 r2391 68 68 { 69 69 //at the moment this function only works for one weaponPack in the entire WeaponSystem... 70 if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() != 0 ) //if slot not full70 if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 ) //if slot not full 71 71 { 72 72 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) ); -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2327 r2391 73 73 void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode) 74 74 { 75 75 SUPER(WeaponSlot, XMLPort, xmlelement, mode); 76 76 } 77 77 78 void WeaponSlot::attachWeapon(Weapon *weaponPointer) 79 { this->attachedWeapon_ = weaponPointer; } 78 void WeaponSlot::attachWeapon(Weapon *weapon) 79 { 80 this->attachedWeapon_ = weapon; 81 this->attach(weapon); 82 COUT(0) << "WeaponSlot::attachWeapon position=" << this->getWorldPosition() << std::endl; 83 } 80 84 81 85 Weapon * WeaponSlot::getAttachedWeapon() const -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.h
r2319 r2391 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 46 47 void attachWeapon(Weapon *weapon Pointer);47 void attachWeapon(Weapon *weapon); 48 48 Weapon * getAttachedWeapon() const; 49 49 void setAmmoType(bool isUnlimited); -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2366 r2391 145 145 void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 146 146 { 147 147 SUPER(WeaponSystem, XMLPort, xmlelement, mode); 148 148 } 149 149 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
r2367 r2391 45 45 assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity 46 46 47 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue( 1.0, 1.0, 0.5), 1);48 //this->attachObject(this->billboard_.getBillboardSet());49 this->scale(0. 5);47 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(0.5, 0.5, 0.7, 0.8), 1); 48 this->getNode()->attachObject(this->billboard_.getBillboardSet()); 49 this->scale(0.2); 50 50 } 51 51 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
r2368 r2391 43 43 RegisterObject(ParticleProjectile); 44 44 45 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot2 ", LODParticle::normal);45 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot2_small", LODParticle::normal); 46 46 this->particles_->addToSceneNode(this->getNode()); 47 this->particles_->setKeepParticlesInLocalSpace(true);47 //this->particles_->setKeepParticlesInLocalSpace(true); 48 48 49 this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT); 49 50 /* 50 51 if (this->owner_) … … 76 77 this->particles_->setEnabled(this->isVisible()); 77 78 } 78 79 bool ParticleProjectile::create(){80 if(!Projectile::create())81 return false;82 this->particles_->getAllEmitters()->setDirection(-this->getOrientation()*Vector3(1,0,0));83 return true;84 }85 79 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.h
r2272 r2391 46 46 void setConfigValues(); 47 47 48 virtual bool create();49 50 48 private: 51 49 ParticleInterface* particles_; -
code/branches/weapon2/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
r2379 r2391 48 48 RegisterObject(Projectile); 49 49 50 COUT(0) << "Projectile::Projectile" << std::endl; 51 50 52 this->setConfigValues(); 51 53 this->explosionTemplateName_ = "Orxonox/explosion3"; … … 53 55 54 56 //this->setStatic(false); 55 this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);57 // this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL); 56 58 57 59 /* … … 121 123 delete this; 122 124 } 123 124 bool Projectile::create(){125 return WorldEntity::create();126 }127 125 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/projectiles/Projectile.h
r2272 r2391 45 45 virtual void tick(float dt); 46 46 47 virtual bool create();48 49 47 protected: 50 48 Projectile(BaseObject* creator); -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2379 r2391 44 44 { 45 45 RegisterObject(LaserGun); 46 47 //in future XMLPort 48 this->speed_ = 250; 49 46 50 } 47 51 … … 52 56 void LaserGun::takeBullets() 53 57 { 54 this->munition_->removeBullets(1,this); 58 COUT(0) << "LaserGun::takeBullets" << std::endl; 59 this->munition_->removeBullets(1); 55 60 this->bulletTimer(this->bulletLoadingTime_); 56 61 } … … 64 69 void LaserGun::createProjectile() 65 70 { 71 COUT(0) << "LaserGun::createProjectile" << std::endl; 66 72 BillboardProjectile* projectile = new ParticleProjectile(this); 67 projectile->setOrientation( projectile->getOrientation());68 projectile->setPosition( projectile->getWorldPosition());73 projectile->setOrientation(this->getWorldOrientation()); 74 projectile->setPosition(this->getWorldPosition()); 69 75 projectile->setVelocity(WorldEntity::FRONT * this->speed_); 70 76 } -
code/branches/weapon2/src/orxonox/objects/worldentities/MovableEntity.cc
r2087 r2391 75 75 { 76 76 this->velocity_ += (dt * this->acceleration_); 77 this->node_->translate(dt * this->velocity_ );77 this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL); 78 78 79 79 this->rotationRate_ += (dt * this->momentum_); -
code/branches/weapon2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2379 r2391 153 153 { 154 154 COUT(0) << "Pawn::setWeaponSlot" << std::endl; 155 this->attach(wSlot); 155 156 this->weaponSystem_->attachWeaponSlot(wSlot); } 157 156 158 WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const 157 159 { return this->weaponSystem_->getWeaponSlotPointer(index); }
Note: See TracChangeset
for help on using the changeset viewer.