Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 4, 2019, 5:13:42 PM (6 years ago)
Author:
cwaupoti
Message:

added working HoverGun

Location:
code/branches/Boxhead_FS19/src/modules/weapons/weaponmodes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Boxhead_FS19/src/modules/weapons/weaponmodes/HoverGun.cc

    r12273 r12284  
    2121 *
    2222 *   Author:
    23  *      Joel Smely
     23 *      Hagen Seifert
    2424 *   Co-authors:
    2525 *      simonmie
     
    3535
    3636#include "core/CoreIncludes.h"
     37#include "core/XMLPort.h"
     38#include "core/command/Executor.h"
     39
     40#include "graphics/Model.h"
    3741#include "weaponsystem/Weapon.h"
    3842#include "weaponsystem/WeaponPack.h"
    3943#include "weaponsystem/WeaponSystem.h"
     44#include "worldentities/WorldEntity.h"
    4045#include "worldentities/pawns/Pawn.h"
    4146
    4247#include "weapons/projectiles/HoverGunProjectile.h"
     48#include "weapons/MuzzleFlash.h"
    4349
    4450namespace orxonox
     
    5056        RegisterObject(HoverGun);
    5157
    52         this->reloadTime_ = 1.0f;
    53         this->damage_ = 0.0f;
     58        this->reloadTime_ = 0.25f;
     59        this->damage_ = 0.0f; //default 15
    5460        this->speed_ = 750.0f;
     61        this->delay_ = 0.0f;
     62        this->setMunitionName("LaserMunition");
     63        this->mesh_ = "laserbeam.mesh";
    5564
    56         this->setMunitionName("HoverMunition");
    57         this->setFireSound("sounds/Weapon_HoverGun.ogg");
    5865
    59         hudImageString_ = "Orxonox/WSHUD_WM_HoverGun";
     66        this->delayTimer_.setTimer(this->delay_, false, createExecutor(createFunctor(&HoverGun::shot, this)));
     67        this->delayTimer_.stopTimer();
     68
     69        this->setFireSound("sounds/Weapon_HsW01.ogg");
     70        this->setReloadSound("sounds/Reload_HsW01.ogg", 0.5);
     71
     72        hudImageString_ = "Orxonox/WSHUD_WM_HsW01";
    6073    }
    6174
     
    6477    }
    6578
     79    void HoverGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     80    {
     81        SUPER(HoverGun, XMLPort, xmlelement, mode);
     82
     83        XMLPortParam(HoverGun, "delay", setDelay, getDelay, xmlelement, mode);
     84        XMLPortParam(HoverGun, "material", setMaterial, getMaterial, xmlelement, mode);
     85        XMLPortParam(HoverGun, "projectileMesh", setMesh, getMesh, xmlelement, mode);
     86        XMLPortParam(HoverGun, "sound", setSound, getSound, xmlelement, mode);
     87    }
     88
     89    /**
     90    @brief
     91        Set the firing delay.
     92    @param delay
     93        The firing delay in seconds.
     94    */
     95    void HoverGun::setDelay(float delay)
     96    {
     97        this->delay_ = delay;
     98        this->delayTimer_.setInterval(this->delay_);
     99    }
     100
     101    void HoverGun::fire()
     102    {
     103        this->delayTimer_.startTimer();
     104    }
     105
    66106    /**
    67107    @brief
    68108        Fires the weapon. Creates a projectile and fires it.
    69109    */
    70     void HoverGun::fire()
     110    void HoverGun::shot()
    71111    {
     112        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
     113
     114        // Create the projectile.
    72115        HoverGunProjectile* projectile = new HoverGunProjectile(this->getContext());
    73         projectile->setMaterial("Flares/HoverBall_");
     116        Model* model = new Model(projectile->getContext());
     117        model->setMeshSource(mesh_);
     118        model->setCastShadows(false);
     119        projectile->attach(model);
     120        model->setScale(5);
    74121
    75122        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
     
    82129        projectile->setShieldDamage(this->getShieldDamage());
    83130        projectile->setHealthDamage(this->getHealthDamage());
     131
     132        // Display the muzzle flash.
     133        this->HoverGun::muzzleflash();
     134    }
     135
     136    /**
     137    @brief
     138        Displays the muzzle flash.
     139    */
     140    void HoverGun::muzzleflash()
     141    {
     142        MuzzleFlash *muzzleFlash = new MuzzleFlash(this->getContext());
     143        this->getWeapon()->attach(muzzleFlash);
     144        muzzleFlash->setPosition(this->getMuzzleOffset());
     145        muzzleFlash->setMaterial(this->material_);
    84146    }
    85147}
  • code/branches/Boxhead_FS19/src/modules/weapons/weaponmodes/HoverGun.h

    r12273 r12284  
    2121 *
    2222 *   Author:
    23  *      Joel Smely
     23 *      Hagen Seifert
    2424 *   Co-authors:
    2525 *      ...
     
    3636
    3737#include "weapons/WeaponsPrereqs.h"
     38
     39#include "tools/Timer.h"
    3840#include "weaponsystem/WeaponMode.h"
    3941
     
    4345    /**
    4446    @brief
    45         A slow ball of lightning.
     47        Shoots laser beams.
    4648    @author
    47         Joel Smely
     49        Hagen Seifert
    4850    @ingroup WeaponsWeaponModes
    4951    */
     
    5557
    5658            virtual void fire() override;
     59            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5760
    58        private:
     61        protected:
     62            /**
     63            @brief Set the mesh.
     64            @param mesh The mesh name.
     65            */
     66            void setMesh(const std::string& mesh)
     67                { this->mesh_ = mesh; }
     68
     69            /**
     70            @brief Get the mesh.
     71            @return Returns the mesh name.
     72            */
     73            const std::string& getMesh() const
     74                { return this->mesh_; }
     75
     76            /**
     77            @brief Set the sound.
     78            @param sound The Sound name.
     79            */
     80            void setSound(const std::string& sound)
     81                { this->sound_ = sound; }
     82
     83            /**
     84            @brief Get the sound.
     85            @return Returns the sound name.
     86            */
     87            const std::string& getSound() const
     88                { return this->sound_; }
     89
     90            /**
     91            @brief Set the material.
     92            @param material The material name.
     93            */
     94            void setMaterial(const std::string& material)
     95                { this->material_ = material; }
     96            /**
     97            @brief Get the material.
     98            @return Returns the material name.
     99            */
     100            const std::string& getMaterial() const
     101                { return this->material_; }
     102
     103            void setDelay(float delay);
     104            /**
     105            @brief Get the firing delay.
     106            @return Returns the firing delay in seconds.
     107            */
     108            float getDelay() const
     109                { return this->delay_; }
     110
     111            virtual void shot();
     112            void muzzleflash();
     113
     114            std::string material_; //!< The material.
     115            std::string mesh_; //!< The mesh.
     116            std::string sound_; //!< The sound.
     117
     118
     119
    59120            float speed_; //!< The speed of the fired projectile.
     121            float delay_; //!< The firing delay.
     122            Timer delayTimer_; //!< A timer to delay the firing.
    60123    };
    61124}
  • code/branches/Boxhead_FS19/src/modules/weapons/weaponmodes/IceGun.cc

    r11108 r12284  
    4949    IceGun::IceGun(Context* context) : WeaponMode(context)
    5050    {
     51        orxout() << "DEBUG Fire HoverGun";   
    5152        RegisterObject(IceGun);
    5253
  • code/branches/Boxhead_FS19/src/modules/weapons/weaponmodes/LightningGun.cc

    r11108 r12284  
    4848    LightningGun::LightningGun(Context* context) : WeaponMode(context)
    4949    {
     50        orxout() << "DEBUG Fire HoverGun";   
    5051        RegisterObject(LightningGun);
    5152
     
    7071    void LightningGun::fire()
    7172    {
     73
    7274        LightningGunProjectile* projectile = new LightningGunProjectile(this->getContext());
    7375        projectile->setMaterial("Flares/LightningBall_");
Note: See TracChangeset for help on using the changeset viewer.