Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10889


Ignore:
Timestamp:
Nov 29, 2015, 9:05:26 PM (8 years ago)
Author:
fvultier
Message:

promised wor for Jannis.

Location:
code/branches/particleEffectsHS15
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/particleEffectsHS15/data/levels/includes/weaponSettingsEscort.oxi

    r10836 r10889  
    1414        </links>
    1515        <Weapon>
    16           <MineGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" />
     16          <MineGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" maxtimeuntilexplosion=5 timeuntilactivation=1.5/>
    1717        </Weapon>
    1818        <Weapon>
  • code/branches/particleEffectsHS15/src/modules/weapons/WeaponsPrereqs.h

    r10622 r10889  
    9393    class LaserFire;
    9494    class LightningGun;
     95    class MineGun;
    9596    class RocketFire;
    9697    class RocketFireOld;
  • code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc

    r10836 r10889  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "graphics/Model.h"
    3738#include "core/command/Executor.h"
    38 #include "util/Convert.h"
    39 #include "util/Math.h"
    40 
    41 #include "core/CoreIncludes.h"
    42 #include "graphics/Model.h"
    43 #include "graphics/ParticleSpawner.h"
    44 #include "Scene.h"
    45 #include "core/command/Executor.h"
    46 #include "tools/ParticleInterface.h"
    4739
    4840namespace orxonox
     
    5042    RegisterClass(MineProjectile);
    5143
    52     MineProjectile::MineProjectile(Context* context) : Projectile(context)
     44    MineProjectile::MineProjectile(Context* context) : MovableEntity(context), BasicProjectile()
    5345    {
    5446        RegisterObject(MineProjectile);
    5547
    56         this->lifeTime_ = 1.0f;
     48        this->bActive_ = false;
     49        this->maxTimeUntilExplosion_ = 10.0f;
     50        this->timeUntilActivation_ = 1.0f;
    5751
    58         Model* model = new Model(this->getContext());
    59         model->setMeshSource("sphere.mesh");
    60         model->setScale(15.0);
    61         this->attach(model);
    62         model->setPosition(Vector3(0,0,0));
     52        rings_ = new MovableEntity(this->getContext());
     53        this->attach(rings_);
     54        rings_->setPosition(Vector3(0.0,0.0,0.0));
     55        rings_->setAngularVelocity(Vector3(0.0,5.0,0.0));
     56
     57        modelCore_ = new Model(this->getContext());
     58        modelCore_->setMeshSource("Mine_Core.mesh");
     59        modelCore_->setScale(15.0);
     60        this->attach(modelCore_);
     61        modelCore_->setPosition(Vector3(0,0,0));
     62
     63        modelRing1_ = new Model(this->getContext());
     64        modelRing1_->setMeshSource("Mine_Ring.mesh");
     65        modelRing1_->setScale(15.0);
     66        rings_->attach(modelRing1_);
     67        modelRing1_->setPosition(Vector3(0,0,0));
     68        modelRing1_->yaw(Degree(0));
     69
     70        modelRing2_ = new Model(this->getContext());
     71        modelRing2_->setMeshSource("Mine_Ring.mesh");
     72        modelRing2_->setScale(15.0);
     73        rings_->attach(modelRing2_);
     74        modelRing2_->setPosition(Vector3(0,0,0));
     75        modelRing2_->yaw(Degree(180));
     76
     77        if (GameMode::isMaster())
     78        {
     79            this->setMass(10.0f);
     80            this->setFriction(100.0f);
     81            this->enableCollisionCallback();
     82            this->setCollisionResponse(false);
     83            this->setCollisionType(Dynamic);
     84
     85            // Create a sphere collision shape and attach it to the projectile.
     86            collisionShape_ = new SphereCollisionShape(this->getContext());
     87            collisionShape_->setRadius(10.0f);
     88            this->attachCollisionShape(collisionShape_);
     89
     90            // Create a distance trigger and attach it to the projectile.
     91            distanceTrigger_ = new DistanceTrigger(this->getContext());
     92            this->attach(distanceTrigger_);
     93            distanceTrigger_->setPosition(Vector3(0,0,0));
     94            distanceTrigger_->setDistance(40.0f);
     95            distanceTrigger_->addTarget("Pawn");
     96            distanceTrigger_->setStayActive(true);
     97        }
    6398    }
    6499
    65    
     100    MineProjectile::~MineProjectile()
     101    {
     102        /*if (modelCore_ != NULL)
     103        {
     104            modelCore_->destroy();
     105        }*/
     106        /*if (distanceTrigger_ != NULL)
     107        {
     108            distanceTrigger_->destroy();
     109        }*/
     110    }
     111
    66112    /**
    67113    @brief
    68         This function starts a timer that will cause the projectile to Mine after a time defined by the argument @param LifeTime.       
     114        TODO
    69115    */
    70     void MineProjectile::setLifeTime(float lifeTime)
     116    void MineProjectile::setMaxTimeUntilExplosion(float maxTimeUntilExplosion)
    71117    {
    72         orxout() << lifeTime << endl;
    73 
    74         if (lifeTime >= 0)
     118        if (maxTimeUntilExplosion >= 0)
    75119        {
    76             this->lifeTime_ = lifeTime;
    77             this->explodeTimer.setTimer(this->lifeTime_, false, createExecutor(createFunctor(&MineProjectile::Explode, this)));
     120            this->maxTimeUntilExplosion_ = maxTimeUntilExplosion;
     121            if (GameMode::isMaster())
     122            {
     123                this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::Explode, this)));
     124            }
    78125        }
    79126        else
    80127        {
    81             this->lifeTime_ = 0;
     128            this->maxTimeUntilExplosion_ = 0;
    82129        }
    83130    }
    84131
     132    /**
     133    @brief
     134        TODO
     135    */
     136    void MineProjectile::setTimeUntilActivation(float timeUntilActivation)
     137    {
     138        timeUntilActivation_ = timeUntilActivation;
     139
     140        if (GameMode::isMaster())
     141        {
     142            this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::Activate, this)));
     143        }
     144    }
    85145
    86146    /**
    87147    @brief
    88         This is the setter function for the damageReduction_ variable. The value of the variable is bounded between 0 and 1.
    89     */
    90 
    91 
    92     /**
    93     @brief
    94         If this function is called the projectile Mines up into many child projectiles. The original projectiles does not get destroyed but it will never Mine up again.
     148        TODO
    95149    */
    96150    void MineProjectile::Explode()
    97151    {
    98         orxout() << "Explode" << endl;
     152        orxout() << "MineProjectile::Explode" << endl;
    99153
    100154        this->destroyLater();
     
    102156
    103157    }
     158
     159    /**
     160    @brief
     161        TODO
     162    */
     163    void MineProjectile::Activate()
     164    {
     165        orxout() << "MineProjectile::Activate" << endl;
     166
     167        bActive_ = true;
     168    }
    104169}
  • code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.h

    r10836 r10889  
    2828
    2929/**
    30     @file IceGunProjectile.h
     30    @file MineProjectile.h
    3131    @brief Definition of the MineProjectile class.
    3232*/
     
    3636
    3737#include "weapons/WeaponsPrereqs.h"
    38 
    39 #include <string>
    4038#include "tools/Timer.h"
    41 #include "Projectile.h"
     39#include "worldentities/MovableEntity.h"
     40#include "objects/collisionshapes/SphereCollisionShape.h"
     41#include "objects/triggers/DistanceTrigger.h"
     42#include "BasicProjectile.h"
    4243
    4344namespace orxonox
     
    4647    /**
    4748    @brief
    48         The MineProjectile is a projectile that may Mine up into many child projectiles.
    49     @author
    50         Fabien Vultier
     49        TODO
    5150    @ingroup WeaponsProjectiles
    5251    */
    53     class _WeaponsExport MineProjectile : public Projectile
     52    class _WeaponsExport MineProjectile : public MovableEntity, public BasicProjectile
    5453    {
    5554        public:
    5655            MineProjectile(Context* context);
    57             virtual ~MineProjectile() {}
     56            virtual ~MineProjectile();
    5857
    59             virtual void setLifeTime(float LifeTime);
    60            
     58            virtual void setMaxTimeUntilExplosion(float maxTimeUntilExplosion);
     59            virtual void setTimeUntilActivation(float timeUntilActivation);
    6160
     61        private:
     62            bool bActive_; // The mine can only explode if it is active
     63            float maxTimeUntilExplosion_;
     64            float timeUntilActivation_;
     65            Timer activationTimer_;
     66            Timer explodeTimer_;
     67            Model* modelCore_;
     68            Model* modelRing1_;
     69            Model* modelRing2_;
     70            MovableEntity* rings_;
    6271
    63         private:           
    64             float lifeTime_;
    65             Timer explodeTimer;
     72            WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
     73            WeakPtr<DistanceTrigger> distanceTrigger_;
    6674
    67             virtual void Explode();           
     75            virtual void Activate();
     76            virtual void Explode();
    6877    };
    6978}
  • code/branches/particleEffectsHS15/src/modules/weapons/projectiles/Projectile.h

    r10629 r10889  
    6969        protected:
    7070            virtual void setCollisionShapeRadius(float radius);
     71            float lifetime_; //!< The time the projectile exists.
    7172
    7273        private:
    73             float lifetime_; //!< The time the projectile exists.
    7474            Timer destroyTimer_; //!< Timer to destroy the projectile after its lifetime has run out.
    75             WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.           
     75            WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
    7676    };
    7777}
  • code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.cc

    r10836 r10889  
    5151        RegisterObject(MineGun);
    5252
     53        this->speed_ = 0.0f;
    5354        this->reloadTime_ = 1.0f;
    5455        this->damage_ = 0.0f;
    55         this->speed_ = 0.0f;
    56         this->lifeTime_ = 7500.0f;
     56        this->maxTimeUntilExplosion_ = 0.0f;
    5757
    5858        this->setMunitionName("MineMunition");
     
    6666    /**
    6767    @brief
    68         XMLPort for the MineGun. You can define how often the projectiles Mine, how many childs should be created per Mine, the spread and the time between two Mines.
     68        XMLPort for the MineGun.
    6969    */
    7070    void MineGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7171    {
    7272        SUPER(MineGun, XMLPort, xmlelement, mode);
    73         XMLPortParam(MineGun, "Lifetime", setLifeTime, getLifeTime, xmlelement, mode);
     73
     74        XMLPortParam(MineGun, "maxtimeuntilexplosion", setMaxTimeUntilExplosion, getMaxTimeUntilExplosion, xmlelement, mode).defaultValues(10.0f);
     75        XMLPortParam(MineGun, "timeuntilactivation", setTimeUntilActivation, getTimeUntilActivation, xmlelement, mode).defaultValues(3.0f);
    7476    }
    7577
     
    8183    {
    8284        MineProjectile* projectile = new MineProjectile(this->getContext());
    83         //projectile->setMaterial("Flares/energyflare");
    8485
    8586        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
     
    8889        projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
    8990
    90         // Pass important information to the projectile: Number of Mines, Number of childs, Mine time, spread and the damage reduction
    91         /*projectile->setNumberOfMines(getNumberOfMines());
    92         projectile->setNumberOfChilds(getNumberOfChilds());*/
    93         projectile->setLifeTime(getLifeTime());
    94         /*projectile->setSpread(getSpread());
    95         projectile->setDamageReduction(getDamageReduction());*/
     91        projectile->setMaxTimeUntilExplosion(getMaxTimeUntilExplosion());
     92        projectile->setTimeUntilActivation(getTimeUntilActivation());
    9693
    9794        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
  • code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.h

    r10836 r10889  
    4444    @brief
    4545        A Mine that explodes when a ship is too close
    46     @author
    47         Fabien Vultier
    4846    @ingroup WeaponsWeaponModes
    4947    */
     
    5654            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5755            virtual void fire();
    58             inline void setLifeTime(float lifeTime)
    59                 { this->lifeTime_ = lifeTime; }
    60             inline float getLifeTime() const
    61                 { return this->lifeTime_; }
    6256
    63        private:
     57            inline float getMaxTimeUntilExplosion() const
     58                { return this->maxTimeUntilExplosion_; }
     59            inline float getTimeUntilActivation() const
     60                { return this->timeUntilActivation_; }
     61        protected:
     62            inline void setMaxTimeUntilExplosion(float maxTimeUntilExplosion)
     63                { this->maxTimeUntilExplosion_ = maxTimeUntilExplosion; }
     64            inline void setTimeUntilActivation(float timeUntilActivation)
     65                { this->timeUntilActivation_ = timeUntilActivation; }
     66        private:
    6467            float speed_; //The speed of the fired projectile.
    65             float lifeTime_;
    66 
     68            float maxTimeUntilExplosion_;
     69            float timeUntilActivation_;
    6770    };
    6871}
Note: See TracChangeset for help on using the changeset viewer.