Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

promised wor for Jannis.

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.