Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 27, 2008, 8:07:29 AM (17 years ago)
Author:
rgrieder
Message:

updated input branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/orxonox/objects/Projectile.cc

    r1505 r1629  
    3535#include "core/Executor.h"
    3636#include "core/ConfigValueIncludes.h"
     37#include "tools/ParticleInterface.h"
    3738
    38 #include "SpaceShip.h"
    39 #include "Explosion.h"
     39#include "SpaceShipAI.h"
     40#include "ParticleSpawner.h"
    4041#include "Model.h"
    4142
    4243namespace orxonox
    4344{
    44     CreateFactory(Projectile);
     45    float Projectile::speed_ = 5000;
    4546
    46     float Projectile::speed_ = 0;
    47 
    48     Projectile::Projectile(SpaceShip* owner) :
    49       owner_(owner)
     47    Projectile::Projectile(SpaceShip* owner) : owner_(owner)
    5048    {
    5149        RegisterObject(Projectile);
    5250
    5351        this->setConfigValues();
    54 
    55         this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
    56         this->attachObject(this->billboard_.getBillboardSet());
    57         this->scale(0.5);
     52        this->explosionTemplateName_ = "Orxonox/explosion3";
     53        this->smokeTemplateName_ = "Orxonox/smoke4";
    5854
    5955        if (this->owner_)
     
    6359            this->setPosition(this->owner_->getPosition());
    6460            this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);
    65             this->setVelocity(Vector3(1, 0, 0) * this->speed_);
     61            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
    6662        }
    6763
    6864        this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
    69 //        COUT(3) << this->classID << std::endl;
    7065    }
    7166
     
    7671    void Projectile::setConfigValues()
    7772    {
    78         SetConfigValue(lifetime_, 10.0).description("The time in seconds a projectile stays alive");
    79         SetConfigValue(speed_, 2000.0).description("The speed of a projectile in units per second");
     73        SetConfigValue(damage_, 15.0).description("The damage caused by the projectile");
     74        SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive");
     75        SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second");
    8076
    81         this->setVelocity(Vector3(1, 0, 0) * this->speed_);
     77        if(this->owner_)
     78          this->setVelocity(this->owner_->getInitialDir() * this->speed_);
    8279    }
    8380
     
    8582    {
    8683        WorldEntity::tick(dt);
     84
     85        if (!this->isActive())
     86            return;
    8787
    8888        float radius;
     
    9595                if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
    9696                {
    97                     Explosion *exp = new Explosion(this);
    98                     exp->create();
     97                    // hit
     98                    if (it->isA(Class(SpaceShipAI)))
     99                        ((SpaceShipAI*)(*it))->damage(this->damage_);
     100                    ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, LODParticle::low, 2.0);
     101                    explosion->setPosition(this->getPosition());
     102                    explosion->create();
     103                    ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, LODParticle::normal, 2.0, 0.0);
     104                    smoke->setPosition(this->getPosition());
     105//                    smoke->getParticleInterface()->setSpeedFactor(3.0);
     106                    smoke->create();
    99107                    delete this;
    100108                    return;
     
    108116        delete this;
    109117    }
    110 
    111     void Projectile::setColour(const ColourValue& colour)
    112     {
    113         this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
    114     }
    115118}
Note: See TracChangeset for help on using the changeset viewer.