Changeset 2232 for code/branches
- Timestamp:
- Nov 19, 2008, 7:07:36 PM (16 years ago)
- Location:
- code/branches/weapon2/src/orxonox
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/CMakeLists.txt
r2203 r2232 92 92 objects/weaponSystem/weapons/LaserGun.cc 93 93 objects/weaponSystem/munitions/LaserGunMunition.cc 94 #objects/weaponSystem/projectiles/BillboardProjectile.cc95 #objects/weaponSystem/projectiles/ParticleProjectile.cc96 #objects/weaponSystem/projectiles/Projectile.cc94 objects/weaponSystem/projectiles/BillboardProjectile.cc 95 objects/weaponSystem/projectiles/ParticleProjectile.cc 96 objects/weaponSystem/projectiles/Projectile.cc 97 97 98 98 objects/worldentities/triggers/Trigger.cc -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Munition.cc
r2203 r2232 46 46 } 47 47 48 unsigned int Munition::getBullets() 49 { return this->bullets_; } 48 50 49 void Munition::decrementBullets() 51 unsigned int Munition::getMagazines() 52 { return this->magazines_; } 53 54 void Munition::setMaxBullets(unsigned int amount) 55 { this->maxBullets_ = amount; } 56 57 void Munition::setMaxMagazines(unsigned int amount) 58 { this->maxMagazines_ = amount; } 59 60 void Munition::removeBullets(unsigned int amount, Weapon * parentWeapon) 50 61 { 51 this->bullets--; 62 //if actual magazine is empty, decrement it and set the bullets amount to full (masBullets_) 63 if ( this->bullets_ == 0 ) 64 { 65 this->removeMagazines(1); 66 parentWeapon->magazineTimer(); 67 this->bullets_ = this->maxBullets_; 68 } 69 else 70 this->bullets_ = this->bullets_ - amount; 52 71 } 53 void Munition::decrementMagazines() 72 73 void Munition::removeMagazines(unsigned int amount) 54 74 { 55 this->magazines--; 75 if ( this->magazines_ == 0 ) 76 { 77 if ( this->bullets_ == 0 ) 78 { 79 //no bullets and no magazines 80 } 81 else 82 { 83 //what to do when there are no more magazines? 84 } 85 } 86 else 87 this->magazines_ = this->magazines_ - amount; } 88 89 void Munition::addBullets(unsigned int amount) 90 { 91 if ( this->bullets_ == this->maxBullets_ ) 92 { 93 //cannot add bullets to actual magazine 94 } 95 else 96 this->bullets_ = this->bullets_ + amount; 56 97 } 57 void Munition::incrementBullets() 98 99 void Munition::addMagazines(unsigned int amount) 58 100 { 59 this->bullets++; 60 } 61 void Munition::incrementMagazines() 62 { 63 this->magazines++; 101 if ( this->magazines_ == this->maxMagazines_ ) 102 { 103 //no more capacity for another magazine 104 } 105 else 106 this->magazines_ = this->magazines_ + amount; 64 107 } 65 108 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Munition.h
r2203 r2232 34 34 #include "core/BaseObject.h" 35 35 36 #include "Weapon.h" 37 36 38 37 39 namespace orxonox … … 45 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 48 47 void decrementBullets(); 48 void decrementMagazines(); 49 void incrementBullets(); 50 void incrementMagazines(); 49 void setMaxBullets(unsigned int amount); 50 void setMaxMagazines(unsigned int amount); 51 52 unsigned int getBullets(); 53 unsigned int getMagazines(); 54 55 void removeBullets(unsigned int k, Weapon * parentWeapon); 56 void removeMagazines(unsigned int k); 57 void addBullets(unsigned int k); 58 void addMagazines(unsigned int k); 51 59 52 60 private: 53 int bullets; 54 int magazines; 61 unsigned int bullets_; 62 unsigned int magazines_; 63 unsigned int maxBullets_; 64 unsigned int maxMagazines_; 55 65 }; 56 66 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2203 r2232 40 40 { 41 41 RegisterObject(Weapon); 42 this->weaponReadyToShoot_ = true; 42 this->bulletReadyToShoot_ = true; 43 this->magazineReadyToShoot_ = true; 43 44 this->setParentWeaponSystem(); 44 45 } … … 51 52 void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode) 52 53 { 53 54 SUPER(Weapon, XMLPort, xmlelement, mode); 54 55 } 55 56 … … 58 59 59 60 } 60 void Weapon::timer() 61 62 63 void Weapon::bulletTimer() 61 64 { 62 this->reloadTimer_.setTimer( this->loadingTime_ , false , this , createExecutor(createFunctor(&Weapon::reloaded))); 65 this->bulletReloadTimer_.setTimer( this->bulletLoadingTime_ , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded))); 66 } 67 void Weapon::magazineTimer() 68 { 69 this->magazineReloadTimer_.setTimer( this->magazineLoadingTime_ , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded))); 63 70 } 64 71 65 void Weapon:: reloaded()66 { 72 void Weapon::bulletReloaded() 73 { this->bulletReadyToShoot_ = true; } 67 74 68 this->weaponReadyToShoot_ = true; 69 } 75 void Weapon::magazineReloaded() 76 { this->magazineReadyToShoot_ = true; } 77 70 78 71 79 void Weapon::attachNeededMunition(std::string munitionName) 72 80 { 73 //if munition type already exist attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem81 //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 74 82 if ( this->parentWeaponSystem_->getMunitionType(munitionName) ) 75 83 this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionName); … … 93 101 { return this->munition_; } 94 102 95 void Weapon::set LoadingTime(float loadingTime)96 { this-> loadingTime_ = loadingTime; }103 void Weapon::setBulletLoadingTime(float loadingTime) 104 { this->bulletLoadingTime_ = loadingTime; } 97 105 98 float Weapon::get LoadingTime()99 { return this-> loadingTime_; }106 float Weapon::getBulletLoadingTime() 107 { return this->bulletLoadingTime_; } 100 108 101 void Weapon::set WeaponReadyToShoot(bool b)102 { this-> weaponReadyToShoot_ = b; }109 void Weapon::setMagazineLoadingTime(float loadingTime) 110 { this->magazineLoadingTime_ = loadingTime; } 103 111 104 bool Weapon::getWeaponReadyToShoot() 105 { return this->weaponReadyToShoot_; } 106 Timer<Weapon> * Weapon::getTimer() 107 { return &this->reloadTimer_; } 112 float Weapon::getMagazineLoadingTime() 113 { return this->magazineLoadingTime_; } 114 115 void Weapon::setBulletReadyToShoot(bool b) 116 { this->bulletReadyToShoot_ = b; } 117 118 bool Weapon::getBulletReadyToShoot() 119 { return this->bulletReadyToShoot_; } 120 121 void Weapon::setMagazineReadyToShoot(bool b) 122 { this->magazineReadyToShoot_ = b; } 123 124 bool Weapon::getMagazineReadyToShoot() 125 { return this->magazineReadyToShoot_; } 126 127 Timer<Weapon> * Weapon::getBulletTimer() 128 { return &this->bulletReloadTimer_; } 129 130 Timer<Weapon> * Weapon::getMagazineTimer() 131 { return &this->magazineReloadTimer_; } 108 132 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h
r2203 r2232 51 51 52 52 virtual void fire(); 53 void timer(); 54 void reloaded(); 53 void bulletTimer(); 54 void magazineTimer(); 55 void bulletReloaded(); 56 void magazineReloaded(); 55 57 void attachNeededMunition(std::string munitionType); 56 58 … … 58 60 virtual void setParentWeaponSystem(); 59 61 Munition * getAttachedMunition(); 60 void setLoadingTime(float loadingTime); 61 float getLoadingTime(); 62 void setWeaponReadyToShoot(bool b); 63 bool getWeaponReadyToShoot(); 64 Timer<Weapon> *getTimer(); 62 void setBulletLoadingTime(float loadingTime); 63 float getBulletLoadingTime(); 64 void setMagazineLoadingTime(float loadingTime); 65 float getMagazineLoadingTime(); 66 void setBulletReadyToShoot(bool b); 67 bool getBulletReadyToShoot(); 68 void setMagazineReadyToShoot(bool b); 69 bool getMagazineReadyToShoot(); 70 Timer<Weapon> *getBulletTimer(); 71 Timer<Weapon> *getMagazineTimer(); 65 72 66 73 inline void setParentWeaponSlot(WeaponSlot *parentWeaponSlot) … … 70 77 71 78 private: 72 bool weaponReadyToShoot_; 73 float loadingTime_; 79 bool bulletReadyToShoot_; 80 bool magazineReadyToShoot_; 81 float bulletLoadingTime_; 82 float magazineLoadingTime_; 74 83 Munition *munition_; 75 84 … … 77 86 WeaponSystem *parentWeaponSystem_; 78 87 SubclassIdentifier<Munition> munitionIdentifier_; 79 Timer<Weapon> reloadTimer_; 88 Timer<Weapon> bulletReloadTimer_; 89 Timer<Weapon> magazineReloadTimer_; 80 90 }; 81 91 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2145 r2232 44 44 this->parentWeaponSystem_ = 0; 45 45 46 /* will be made with XML 46 47 for (int i=0;i<k;i++) 47 48 { 48 49 attachWeaponSlot(new WeaponSlot(this)); 49 50 } 51 */ 50 52 } 51 53 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2203 r2232 52 52 } 53 53 54 void WeaponSlot::attachWeapon(Weapon *weaponPointer)55 {56 this->attachedWeapon_ = weaponPointer;57 }58 59 54 60 55 /*sets the munition type … … 67 62 } 68 63 64 69 65 void WeaponSlot::fire() 70 66 { … … 72 68 } 73 69 70 71 //XMLPort functions 74 72 void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode) 75 73 { 76 74 SUPER(WeaponSlot, XMLPort, xmlelement, mode); 75 XMLPortObject(WeaponSlot, Weapon, "attached-weapon", attachWeapon, getAttachedWeapon, xmlelement, mode); 77 76 } 78 77 78 void WeaponSlot::attachWeapon(Weapon *weaponPointer) 79 { this->attachedWeapon_ = weaponPointer; } 80 81 Weapon * WeaponSlot::getAttachedWeapon(unsigned int index) const 82 { return this->attachedWeapon_; } 83 84 79 85 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.h
r2203 r2232 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "core/BaseObject.h"35 36 34 #include "Weapon.h" 37 #include " ../worldentities/PositionableEntity.h"35 #include "objects/worldentities/PositionableEntity.h" 38 36 39 37 namespace orxonox … … 48 46 49 47 void attachWeapon(Weapon *weaponPointer); 48 Weapon * getAttachedWeapon(unsigned int index) const; 50 49 void setAmmoType(bool isUnlimited); 51 50 void fire(); -
code/branches/weapon2/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h
r2186 r2232 47 47 48 48 private: 49 int bullets_;50 int magazines_;51 int maxBullets_;52 int maxMagazines_;53 49 54 50 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
r2099 r2232 42 42 RegisterObject(BillboardProjectile); 43 43 44 this->billboard_.setBillboardSet( "Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);45 this->attachObject(this->billboard_.getBillboardSet());44 this->billboard_.setBillboardSet(this->scenemanager_, "Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1); 45 //this->attachObject(this->billboard_.getBillboardSet()); 46 46 this->scale(0.5); 47 47 } … … 49 49 BillboardProjectile::~BillboardProjectile() 50 50 { 51 if (this->isInitialized() && this->owner_)52 this->detachObject(this->billboard_.getBillboardSet());51 //if (this->isInitialized() && this->owner_) 52 //this->detachObject(this->billboard_.getBillboardSet()); 53 53 } 54 54 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.h
r2099 r2232 47 47 virtual void changedVisibility(); 48 48 49 inline Ogre::SceneManager* getSceneManager() 50 { return this->scenemanager_; } 51 49 52 private: 50 53 BillboardSet billboard_; 54 Ogre::SceneManager* scenemanager_; 51 55 }; 52 56 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
r2099 r2232 30 30 #include "ParticleProjectile.h" 31 31 32 #include " SpaceShip.h"32 #include "../../worldentities/pawns/SpaceShip.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/ConfigValueIncludes.h" … … 42 42 RegisterObject(ParticleProjectile); 43 43 44 this->particles_ = new ParticleInterface( "Orxonox/shot2", LODParticle::normal);44 this->particles_ = new ParticleInterface(this->getSceneManager(), "Orxonox/shot2", LODParticle::normal); 45 45 this->particles_->addToSceneNode(this->getNode()); 46 46 this->particles_->setKeepParticlesInLocalSpace(true); -
code/branches/weapon2/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
r2100 r2232 54 54 this->smokeTemplateName_ = "Orxonox/smoke4"; 55 55 56 this->setStatic(false);56 //this->setStatic(false); 57 57 this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL); 58 58 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2203 r2232 44 44 45 45 //set weapon properties here 46 this->setLoadingTime(0.5);46 //this->setLoadingTime(0.5); 47 47 48 48 //Hack --> will be loaded by XML … … 56 56 void LaserGun::fire() 57 57 { 58 if ( this->get WeaponReadyToShoot() )58 if ( this->getBulletReadyToShoot() && this->getMagazineReadyToShoot() ) 59 59 { 60 this->setWeaponReadyToShoot(false);61 60 62 Weapon::timer(); 61 63 62 64 63 //take munition 65 this->getAttachedMunition()->decrementBullets(); 64 this->getAttachedMunition()->removeBullets(1,this); 65 Weapon::bulletTimer(); 66 this->setBulletReadyToShoot(false); 66 67 67 68 //create projectile 68 //BillboardProjectile* projectile = new ParticleProjectile(this);69 BillboardProjectile* projectile = new ParticleProjectile(this,this); 69 70 //projectile->setColour(this->getProjectileColour()); 70 71 } -
code/branches/weapon2/src/orxonox/tools/BillboardSet.h
r2087 r2232 52 52 inline Ogre::BillboardSet* getBillboardSet() 53 53 { return this->billboardSet_; } 54 inline Ogre::SceneManager* getSceneManager() 55 { return this->scenemanager_; } 54 56 55 57 const std::string& getName() const;
Note: See TracChangeset
for help on using the changeset viewer.