Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

promised wor for Jannis.

Location:
code/branches/particleEffectsHS15/src/modules/weapons/projectiles
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.