Changeset 2203 for code/branches/weapon2/src/orxonox
- Timestamp:
- Nov 12, 2008, 4:45:50 PM (16 years ago)
- Location:
- code/branches/weapon2/src/orxonox
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/CMakeLists.txt
r2186 r2203 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/OrxonoxPrereqs.h
r2186 r2203 73 73 } 74 74 75 //put here all existing munitionTypes 76 namespace MunitionType 77 { 78 79 80 81 enum Enum 82 { laserGunMunition }; 83 } 84 85 //put here all weapon fire modes. 86 //they have to be added to Pawn and HumanController, too. 87 namespace WeaponMode 88 { 89 enum Enum 90 { 91 fire, 92 altFire, 93 altFire2 94 }; 95 } 96 97 75 98 class GraphicsEngine; 76 99 class Settings; -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Munition.cc
r2097 r2203 46 46 } 47 47 48 49 void Munition::decrementBullets() 50 { 51 this->bullets--; 52 } 53 void Munition::decrementMagazines() 54 { 55 this->magazines--; 56 } 57 void Munition::incrementBullets() 58 { 59 this->bullets++; 60 } 61 void Munition::incrementMagazines() 62 { 63 this->magazines++; 64 } 65 66 48 67 void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode) 49 68 { -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Munition.h
r2106 r2203 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 46 47 void decrementBullets(); 48 void decrementMagazines(); 49 void incrementBullets(); 50 void incrementMagazines(); 47 51 48 52 private: 49 50 53 int bullets; 54 int magazines; 51 55 }; 52 56 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2186 r2203 35 35 #include "Weapon.h" 36 36 37 38 37 namespace orxonox 39 38 { … … 43 42 this->weaponReadyToShoot_ = true; 44 43 this->setParentWeaponSystem(); 45 this->pointerToMunition_ = this->parentWeaponSystem_->getAttachedMunitionPointer;46 this->attachNeededMunition(this->pointerToMunition_);47 48 44 } 49 45 … … 62 58 63 59 } 60 void Weapon::timer() 61 { 62 this->reloadTimer_.setTimer( this->loadingTime_ , false , this , createExecutor(createFunctor(&Weapon::reloaded))); 63 } 64 64 65 65 void Weapon::reloaded() 66 66 { 67 67 68 this->weaponReadyToShoot_ = true; 68 69 } 69 70 70 void attachNeededMunition(Munition *pointerToMunition)71 void Weapon::attachNeededMunition(std::string munitionName) 71 72 { 72 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 WeaponSystem 73 if ( this->parentWeaponSystem_-> munitionSet_[laserGunMunition])74 this-> pointerToMunition_ = pointerToMunition;74 if ( this->parentWeaponSystem_->getMunitionType(munitionName) ) 75 this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionName); 75 76 else 76 77 { 77 this->pointerToMunition_ = new LaserGunMunition; 78 this->parentWeaponSystem_->munitionSet_[laserGunMunition] = this->pointerToMunition_; 79 78 //create new munition with identifier 79 this->munitionIdentifier_ = ClassByString(munitionName); 80 this->munition_ = this->munitionIdentifier_.fabricate(this); 81 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_); 80 82 } 81 83 } 82 84 83 /* 85 86 /*get and set functions 87 * 88 */ 84 89 void Weapon::setParentWeaponSystem() 85 { 86 this->parentWeaponSystem_ = this->parentWeaponSlot_->parentWeaponSet_->parentWeaponSystem_; 87 } 88 */ 90 { this->parentWeaponSystem_ = this->parentWeaponSlot_->getParentWeaponSet()->getParentWeaponSystem(); } 89 91 92 Munition * Weapon::getAttachedMunition() 93 { return this->munition_; } 94 95 void Weapon::setLoadingTime(float loadingTime) 96 { this->loadingTime_ = loadingTime; } 97 98 float Weapon::getLoadingTime() 99 { return this->loadingTime_; } 100 101 void Weapon::setWeaponReadyToShoot(bool b) 102 { this->weaponReadyToShoot_ = b; } 103 104 bool Weapon::getWeaponReadyToShoot() 105 { return this->weaponReadyToShoot_; } 106 Timer<Weapon> * Weapon::getTimer() 107 { return &this->reloadTimer_; } 90 108 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h
r2186 r2203 35 35 #include "tools/BillboardSet.h" 36 36 #include "tools/Timer.h" 37 #include "core/Identifier.h" 38 39 #include "WeaponSystem.h" 40 #include "Munition.h" 37 41 38 42 namespace orxonox … … 47 51 48 52 virtual void fire(); 53 void timer(); 49 54 void reloaded(); 55 void attachNeededMunition(std::string munitionType); 56 57 //get and set functions 50 58 virtual void setParentWeaponSystem(); 51 void attachNeededMunition(Munition *munitionPointer); 59 Munition * getAttachedMunition(); 60 void setLoadingTime(float loadingTime); 61 float getLoadingTime(); 62 void setWeaponReadyToShoot(bool b); 63 bool getWeaponReadyToShoot(); 64 Timer<Weapon> *getTimer(); 52 65 53 66 inline void setParentWeaponSlot(WeaponSlot *parentWeaponSlot) … … 56 69 { return parentWeaponSlot_; }; 57 70 58 59 60 61 71 private: 62 72 bool weaponReadyToShoot_; 63 73 float loadingTime_; 64 Munition *pointerToMunition_; 74 Munition *munition_; 75 65 76 WeaponSlot *parentWeaponSlot_; 66 77 WeaponSystem *parentWeaponSystem_; 78 SubclassIdentifier<Munition> munitionIdentifier_; 67 79 Timer<Weapon> reloadTimer_; 68 69 70 80 }; 71 81 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2145 r2203 74 74 void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode) 75 75 { 76 SUPER(WeaponSlot, XMLPort, xmlelement, mode); 77 } 76 78 77 }78 79 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSlot.h
r2186 r2203 34 34 #include "core/BaseObject.h" 35 35 36 37 36 #include "Weapon.h" 38 37 #include "../worldentities/PositionableEntity.h" … … 63 62 64 63 WeaponSet *parentWeaponSet_; 65 66 //attached weapon orientation67 int yaw_ = 0;68 int pitch_ = 0;69 int roll_ = 0;70 64 }; 71 65 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2186 r2203 52 52 this->activeWeaponSet_ = 0; 53 53 this->parentSpaceShip_ = 0; 54 this->attachedMunition_ =0;55 54 } 56 55 … … 64 63 wSet->setParentWeaponSystem(this); 65 64 } 65 66 void WeaponSystem::setNewMunition(std::string munitionType, Munition * munitionToAdd) 67 { 68 this->munitionSet_[munitionType] = munitionToAdd; 69 } 70 Munition * WeaponSystem::getMunitionType(std::string munitionType) 71 { 72 return this->munitionSet_[munitionType]; 73 } 74 66 75 67 76 /* … … 98 107 } 99 108 100 Munition * WeaponSystem::getAttachedMunitionPointer()101 {102 return this->attachedMunition_;103 }104 105 void WeaponSystem::addMunitionType(Munition *munitionPointer)106 {107 108 109 if (munitionPointer != NULL) //gewährleiste, dass munitionPointer auf etwas sinnvolles zeigt110 this->attachedMunition_ = munitionPointer;111 else112 ;//was?113 114 }115 116 117 109 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.h
r2186 r2203 39 39 namespace orxonox 40 40 { 41 //put here all existing munitionTypes42 namespace MunitionType43 {44 enum Enum45 { laserGunMunition };46 }47 48 //put here all weapon fire modes.49 //they have to be added to Pawn and HumanController, too.50 namespace WeaponMode51 {52 enum Enum53 { fire, altFire, altFire2 };54 }55 41 56 42 class _OrxonoxExport WeaponSystem : public BaseObject … … 63 49 64 50 void attachWeaponSet(WeaponSet *wSet); 65 void addMunitionType(Munition *munitionPointer);66 51 void fire(); 67 52 void fire(WeaponMode::Enum fireMode); 68 53 //void setActiveWeaponSet(unsigned int n); 69 54 WeaponSet * getWeaponSetPointer(unsigned int n); 70 Munition * getAttachedMunitionPointer(); 55 56 void setNewMunition(std::string munitionType, Munition * munitionToAdd); 57 Munition * getMunitionType(std::string munitionType); 71 58 72 59 inline void setParentSpaceShip(SpaceShip *parentSpaceShip) … … 78 65 private: 79 66 std::vector<WeaponSet *> weaponSets_; 80 std::map< MunitionType::Enum,Munition *> munitionSet_;67 std::map<std::string, Munition *> munitionSet_; 81 68 WeaponSet *activeWeaponSet_; 82 69 SpaceShip *parentSpaceShip_; 83 Munition * attachedMunition_;84 70 }; 85 71 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2186 r2203 44 44 45 45 //set weapon properties here 46 this->loadingTime_ = 0.5; 46 this->setLoadingTime(0.5); 47 48 //Hack --> will be loaded by XML 49 this->attachNeededMunition("LaserGunMunition"); 47 50 } 48 51 … … 51 54 } 52 55 53 LaserGun::fire()56 void LaserGun::fire() 54 57 { 55 if { this->weaponReadyToShoot_ }58 if ( this->getWeaponReadyToShoot() ) 56 59 { 57 this->weaponReadyToShoot_ = false; 60 this->setWeaponReadyToShoot(false); 61 62 Weapon::timer(); 63 58 64 //take munition 59 //this->pointerToMunition_->65 this->getAttachedMunition()->decrementBullets(); 60 66 61 this->reloadTimer_.setTimer( loadingTime_ , false , this , &this->reloaded ); 62 63 BillboardProjectile* projectile = new ParticleProjectile(this); 64 projectile->setColour(this->getProjectileColour()); 67 //create projectile 68 //BillboardProjectile* projectile = new ParticleProjectile(this); 69 //projectile->setColour(this->getProjectileColour()); 65 70 } 66 71 else 67 72 { 68 //actions, when weapon is not reloaded 73 //actions, when weapon is not reloaded if there are some 69 74 } 70 75 } … … 75 80 } 76 81 82 83 77 84 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
r2186 r2203 37 37 #include "util/Math.h" 38 38 #include "../Weapon.h" 39 #include "../projectiles/BillboardProjectile.h" 40 #include "../projectiles/ParticleProjectile.h" 39 41 40 42 namespace orxonox … … 50 52 void fire(); 51 53 52 53 54 private: 54 55
Note: See TracChangeset
for help on using the changeset viewer.