Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 27, 2015, 10:03:53 PM (9 years ago)
Author:
landauf
Message:

cleanup: empty level is empty again & tabs→spaces.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc

    r10502 r10601  
    1010
    1111namespace orxonox{
    12         RegisterClass(GravityBomb);
     12    RegisterClass(GravityBomb);
    1313
    14         const float GravityBomb::LIFETIME = 2.5;  ///< The gravity bomb lifetime in seconds.
     14    const float GravityBomb::LIFETIME = 2.5;  ///< The gravity bomb lifetime in seconds.
    1515
    16         GravityBomb::GravityBomb(Context* context):
    17                                 BasicProjectile(),
    18                                 MovableEntity(context),
    19                                 RadarViewable(this,static_cast<WorldEntity*>(this))
    20                 {
    21                         RegisterObject(GravityBomb);
     16    GravityBomb::GravityBomb(Context* context):
     17                BasicProjectile(),
     18                MovableEntity(context),
     19                RadarViewable(this,static_cast<WorldEntity*>(this))
     20        {
     21            RegisterObject(GravityBomb);
    2222
    23                         this->setMass(10.0);
    24                         this->hasCollided_ = false;
    25                         if (GameMode::isMaster())
    26                         {
    27                                 //Define CollisionType of the bomb
    28                                 this->timeToLife_= LIFETIME;
    29                                 this->setCollisionResponse(false);
    30                                 this->setCollisionType(WorldEntity::Dynamic);
    31                                 this->enableCollisionCallback();
     23            this->setMass(10.0);
     24            this->hasCollided_ = false;
     25            if (GameMode::isMaster())
     26            {
     27                //Define CollisionType of the bomb
     28                this->timeToLife_= LIFETIME;
     29                this->setCollisionResponse(false);
     30                this->setCollisionType(WorldEntity::Dynamic);
     31                this->enableCollisionCallback();
    3232
    33                                 //Add Collision Shape
    34                                 SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
    35                                 collisionShape->setRadius(1.0);
    36                                 this->attachCollisionShape(collisionShape);
     33                //Add Collision Shape
     34                SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
     35                collisionShape->setRadius(1.0);
     36                this->attachCollisionShape(collisionShape);
    3737
    38                                 //Create Bomb Model
    39                     Model* rocketModel = new Model(this->getContext());
    40                     rocketModel->setMeshSource("GravityBombRocket.mesh"); //Demo Model from SimpleRocket
    41                     rocketModel->scale(3.0f);
    42                     this->attach(rocketModel);
    43                                 //Add second model because the bomb consists of the bomb and attached rockets (2 separate models)
    44                     Model* bombModel =  new Model(this->getContext());
    45                     bombModel->setMeshSource("GravityBomb.mesh"); //Demo Model from SimpleRocket
    46                                 bombModel->scale(3.0f);
    47                                 this->attach(bombModel);
     38                //Create Bomb Model
     39                Model* rocketModel = new Model(this->getContext());
     40                rocketModel->setMeshSource("GravityBombRocket.mesh"); //Demo Model from SimpleRocket
     41                rocketModel->scale(3.0f);
     42                this->attach(rocketModel);
     43                //Add second model because the bomb consists of the bomb and attached rockets (2 separate models)
     44                Model* bombModel =  new Model(this->getContext());
     45                bombModel->setMeshSource("GravityBomb.mesh"); //Demo Model from SimpleRocket
     46                bombModel->scale(3.0f);
     47                this->attach(bombModel);
    4848
    49                                 //Add particle effect to the flying rockets.
    50                                 ParticleEmitter* fire = new ParticleEmitter(this->getContext());
    51                                 fire->setOrientation(this->getOrientation());
    52                                 fire->setSource("Orxonox/simplerocketfire");
    53                                 this->attach(fire);
     49                //Add particle effect to the flying rockets.
     50                ParticleEmitter* fire = new ParticleEmitter(this->getContext());
     51                fire->setOrientation(this->getOrientation());
     52                fire->setSource("Orxonox/simplerocketfire");
     53                this->attach(fire);
    5454
    55                                 //Add sound effect while the bomb is flying.
    56                                 WorldSound* bombSound = new WorldSound(context);
    57                                 bombSound->setSource("sounds/GravityBombFlight.ogg");
    58                                 bombSound->setLooping(true);
    59                                 bombSound->setVolume(1.0);
    60                                 this->attach(bombSound);
    61                                 bombSound->play();
    62                         }
    63                 }
     55                //Add sound effect while the bomb is flying.
     56                WorldSound* bombSound = new WorldSound(context);
     57                bombSound->setSource("sounds/GravityBombFlight.ogg");
     58                bombSound->setLooping(true);
     59                bombSound->setVolume(1.0);
     60                this->attach(bombSound);
     61                bombSound->play();
     62            }
     63        }
    6464
    65         GravityBomb::~GravityBomb(){}
     65    GravityBomb::~GravityBomb(){}
    6666
    67         void GravityBomb::tick(float dt)
    68         {
    69                 SUPER(GravityBomb, tick, dt);
    70                 timeToLife_ -= dt;
    71                 if (timeToLife_ < 0)
    72                 {
    73                         //orxout(debug_output) << "bomb has stoped moving" <<endl;
    74                         setVelocity(Vector3::ZERO); //Stop the bomb.
    75                         detonate();
    76                         this->destroy();
    77                 }
    78                 else
    79                 {
    80                         if (hasCollided_) detonate();
    81                         destroyCheck(); //Bomb is going to be destroyed by destroyCheck(). As written in BasicProectile, this Method should be called by every Projectile.
    82                 }
    83         }
     67    void GravityBomb::tick(float dt)
     68    {
     69        SUPER(GravityBomb, tick, dt);
     70        timeToLife_ -= dt;
     71        if (timeToLife_ < 0)
     72        {
     73            //orxout(debug_output) << "bomb has stoped moving" <<endl;
     74            setVelocity(Vector3::ZERO); //Stop the bomb.
     75            detonate();
     76            this->destroy();
     77        }
     78        else
     79        {
     80            if (hasCollided_) detonate();
     81            destroyCheck(); //Bomb is going to be destroyed by destroyCheck(). As written in BasicProectile, this Method should be called by every Projectile.
     82        }
     83    }
    8484
    85         bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    86         {
    87                 hasCollided_ = processCollision(otherObject, contactPoint, cs);
    88                 return hasCollided_;
    89         }
     85    bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
     86    {
     87        hasCollided_ = processCollision(otherObject, contactPoint, cs);
     88        return hasCollided_;
     89    }
    9090
    91         void GravityBomb::detonate()
    92         {
    93                 //Create the GravityBombField and destroy the Projectil.
    94                 GravityBombField* field = new GravityBombField(this->getContext());
    95                 field->setShooter(this->getShooter());
    96                 field->setPosition(getPosition());
    97                 //orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
    98                 //orxout(debug_output) << "Field is at Position: " << getPosition() << endl;
    99         }
     91    void GravityBomb::detonate()
     92    {
     93        //Create the GravityBombField and destroy the Projectil.
     94        GravityBombField* field = new GravityBombField(this->getContext());
     95        field->setShooter(this->getShooter());
     96        field->setPosition(getPosition());
     97        //orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
     98        //orxout(debug_output) << "Field is at Position: " << getPosition() << endl;
     99    }
    100100}
    101101
Note: See TracChangeset for help on using the changeset viewer.