Changeset 2979 for code/branches/weapons/src/orxonox/objects
- Timestamp:
- May 18, 2009, 2:06:04 PM (16 years ago)
- Location:
- code/branches/weapons/src/orxonox/objects
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/CMakeLists.txt
r2969 r2979 2 2 FusionFire.cc 3 3 LaserFire.cc 4 <<<<<<< .mine 5 HsW01.cc 6 ======= 4 7 LightningGun.cc 8 >>>>>>> .r2978 5 9 ) -
code/branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.cc
r2912 r2979 21 21 * 22 22 * Author: 23 * Martin Polak23 * Hagen Seifert 24 24 * Co-authors: 25 25 * ... … … 32 32 #include "core/CoreIncludes.h" 33 33 #include "core/XMLPort.h" 34 #include "objects/weaponsystem/projectiles/ParticleProjectile.h" 35 #include "objects/worldentities/Model.h" 36 #include "objects/worldentities/MuzzleFlash.h" 37 38 #include "objects/weaponsystem/Weapon.h" 39 #include "objects/weaponsystem/WeaponPack.h" 40 #include "objects/weaponsystem/WeaponSystem.h" 34 41 35 42 namespace orxonox … … 37 44 CreateFactory(HsW01); 38 45 39 HsW01::HsW01(BaseObject* creator) : Weapon (creator)46 HsW01::HsW01(BaseObject* creator) : WeaponMode(creator) 40 47 { 41 48 RegisterObject(HsW01); 42 49 43 this->speed_ = 1250; 50 this->reloadTime_ = 0.25; 51 this->damage_ = 15; 52 this->speed_ = 2500; 53 this->delay_ = 0; 54 this->setMunitionName("HsW01"); 55 56 this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&HsW01::shot))); 57 this->delayTimer_.stopTimer(); 58 } 59 60 void HsW01::XMLPort(Element& xmlelement, XMLPort::Mode mode) 61 { 62 SUPER(HsW01, XMLPort, xmlelement, mode); 63 64 XMLPortParam(HsW01, "delay", setDelay, getDelay, xmlelement, mode); 65 XMLPortParam(HsW01, "material", setMaterial, getMaterial, xmlelement, mode); 44 66 45 67 } 46 68 47 HsW01::~HsW01()69 void HsW01::setMaterial(const std::string& material) 48 70 { 71 this->material_ = material; 49 72 } 50 73 51 void HsW01::reloadBullet()74 std::string& HsW01::getMaterial() 52 75 { 53 this->bulletTimer(this->bulletLoadingTime_);76 return this->material_; 54 77 } 55 78 56 void HsW01:: reloadMagazine()79 void HsW01::setDelay(float d) 57 80 { 58 this->magazineTimer(this->magazineLoadingTime_); 81 this->delay_ = d; 82 this->delayTimer_.setInterval(this->delay_); 59 83 } 60 84 61 void HsW01::takeBullets()85 float HsW01::getDelay() const 62 86 { 63 this->munition_->removeBullets(1);87 return this->delay_; 64 88 } 65 89 66 void HsW01:: takeMagazines()90 void HsW01::fire() 67 91 { 68 this-> munition_->removeMagazines(1);92 this->delayTimer_.startTimer(); 69 93 } 70 94 71 void HsW01:: createProjectile()95 void HsW01::muendungsfeuer() 72 96 { 73 BillboardProjectile* projectile = new ParticleProjectile(this); 74 projectile->setOrientation(this->getWorldOrientation()); 75 projectile->setPosition(this->getWorldPosition()); 76 projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_); 77 projectile->setOwner(this->getWeaponSystem()->getPawn()); 97 MuzzleFlash *muzzleFlash = new MuzzleFlash(this); 98 this->getWeapon()->attach(muzzleFlash); 99 muzzleFlash->setPosition(this->getMuzzleOffset()); 100 muzzleFlash->setMaterial(this->material_); 101 } 102 103 void HsW01::shot() 104 { 105 Projectile* projectile = new Projectile(this); 106 Model* model = new Model(projectile); 107 model->setMeshSource("laserbeam.mesh"); 108 model->setCastShadows(false); 109 projectile->attach(model); 110 model->setScale(5); 111 112 projectile->setOrientation(this->getMuzzleOrientation()); 113 projectile->setPosition(this->getMuzzlePosition()); 114 projectile->setVelocity(this->getMuzzleDirection() * this->speed_); 115 116 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 117 projectile->setDamage(this->getDamage()); 118 119 HsW01::muendungsfeuer(); 78 120 } 79 121 } -
code/branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h
r2901 r2979 21 21 * 22 22 * Author: 23 * Martin Polak23 * Hagen Seifert 24 24 * Co-authors: 25 25 * ... … … 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include "core/BaseObject.h" 35 36 #include "../munitions/LaserGunMunition.h" 37 #include "util/Math.h" 38 #include "../Weapon.h" 39 #include "../projectiles/BillboardProjectile.h" 40 #include "../projectiles/ParticleProjectile.h" 33 #include "objects/weaponsystem/WeaponMode.h" 34 #include "tools/Timer.h" 41 35 42 36 namespace orxonox 43 37 { 44 class _OrxonoxExport HsW01 : public Weapon 38 class _OrxonoxExport HsW01 : public WeaponMode 45 39 { 46 40 public: 47 41 HsW01(BaseObject* creator); 48 virtual ~HsW01() ;42 virtual ~HsW01() {} 49 43 50 virtual void takeBullets(); 51 virtual void takeMagazines(); 52 virtual void createProjectile(); 53 virtual void reloadBullet(); 54 virtual void reloadMagazine(); 44 virtual void fire(); 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 55 46 56 47 private: 48 void setMaterial(const std::string& material); 49 std::string& getMaterial(); 50 void setDelay(float d); 51 float getDelay() const; 52 void shot(); 53 void muendungsfeuer(); 54 55 std::string material_; 57 56 float speed_; 58 57 float delay_; 58 Timer<HsW01> delayTimer_; 59 59 }; 60 60 } -
code/branches/weapons/src/orxonox/objects/worldentities/CMakeLists.txt
r2826 r2979 15 15 CameraPosition.cc 16 16 Model.cc 17 MuzzleFlash.cc 17 18 ParticleEmitter.cc 18 19 ParticleSpawner.cc
Note: See TracChangeset
for help on using the changeset viewer.