Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2979 for code/branches


Ignore:
Timestamp:
May 18, 2009, 2:06:04 PM (16 years ago)
Author:
Hagen
Message:

working laser style weapon with muzzleflash

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  
    22  FusionFire.cc
    33  LaserFire.cc
     4<<<<<<< .mine
     5  HsW01.cc
     6=======
    47  LightningGun.cc
     8>>>>>>> .r2978
    59)
  • code/branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.cc

    r2912 r2979  
    2121 *
    2222 *   Author:
    23  *      Martin Polak
     23 *      Hagen Seifert
    2424 *   Co-authors:
    2525 *      ...
     
    3232#include "core/CoreIncludes.h"
    3333#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"
    3441
    3542namespace orxonox
     
    3744    CreateFactory(HsW01);
    3845
    39     HsW01::HsW01(BaseObject* creator) : Weapon(creator)
     46    HsW01::HsW01(BaseObject* creator) : WeaponMode(creator)
    4047    {
    4148        RegisterObject(HsW01);
    4249
    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);
    4466
    4567    }
    4668
    47     HsW01::~HsW01()
     69    void HsW01::setMaterial(const std::string& material)
    4870    {
     71        this->material_ = material;
    4972    }
    5073
    51     void HsW01::reloadBullet()
     74    std::string& HsW01::getMaterial()
    5275    {
    53         this->bulletTimer(this->bulletLoadingTime_);
     76        return this->material_;
    5477    }
    5578
    56     void HsW01::reloadMagazine()
     79    void HsW01::setDelay(float d)
    5780    {
    58         this->magazineTimer(this->magazineLoadingTime_);
     81        this->delay_ = d;
     82        this->delayTimer_.setInterval(this->delay_);
    5983    }
    6084
    61     void HsW01::takeBullets()
     85    float HsW01::getDelay() const
    6286    {
    63         this->munition_->removeBullets(1);
     87        return this->delay_;
    6488    }
    6589
    66     void HsW01::takeMagazines()
     90    void HsW01::fire()
    6791    {
    68         this->munition_->removeMagazines(1);
     92        this->delayTimer_.startTimer();
    6993    }
    7094
    71     void HsW01::createProjectile()
     95    void HsW01::muendungsfeuer()
    7296    {
    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();
    78120    }
    79121}
  • code/branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h

    r2901 r2979  
    2121 *
    2222 *   Author:
    23  *      Martin Polak
     23 *      Hagen Seifert
    2424 *   Co-authors:
    2525 *      ...
     
    3131
    3232#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"
    4135
    4236namespace orxonox
    4337{
    44     class _OrxonoxExport HsW01 : public Weapon
     38    class _OrxonoxExport HsW01 : public WeaponMode
    4539    {
    4640        public:
    4741            HsW01(BaseObject* creator);
    48             virtual ~HsW01();
     42            virtual ~HsW01() {}
    4943
    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);
    5546
    5647        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_;
    5756            float speed_;
    58 
     57            float delay_;
     58            Timer<HsW01> delayTimer_;
    5959    };
    6060}
  • code/branches/weapons/src/orxonox/objects/worldentities/CMakeLists.txt

    r2826 r2979  
    1515  CameraPosition.cc
    1616  Model.cc
     17  MuzzleFlash.cc
    1718  ParticleEmitter.cc
    1819  ParticleSpawner.cc
Note: See TracChangeset for help on using the changeset viewer.