Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 23, 2015, 7:33:37 PM (9 years ago)
Author:
meggiman
Message:
 
File:
1 edited

Legend:

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

    r10436 r10455  
    33 *
    44 *  Created on: Mar 26, 2015
    5  *      Author: meggiman
     5 *      Author: Manuel Eggimann
    66 */
    77#include "GravityBomb.h"
     
    1212        RegisterClass(GravityBomb);
    1313
    14         const float GravityBomb::LIFETIME = 5;
     14        const float GravityBomb::LIFETIME = 5;  ///< The gravity bomb lifetime in seconds.
    1515
    1616        GravityBomb::GravityBomb(Context* context):
     
    4141                    rocketModel->scale(3.0f);
    4242                    this->attach(rocketModel);
    43 
     43                                //Add second model because the bomb consists of the bomb and attached rockets (2 separate models)
    4444                    Model* bombModel =  new Model(this->getContext());
    4545                    bombModel->setMeshSource("GravityBomb.mesh"); //Demo Model from SimpleRocket
     
    4747                                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);
     54
     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();
    4962                        }
    5063                }
     
    5770                        if(timeToLife_ < 0)
    5871                        {
    59                                 orxout(debug_output) << "bomb has stoped moving" <<endl;
    60                                 setVelocity(Vector3::ZERO);
    61                                 setAcceleration(Vector3::ZERO);
     72                                //orxout(debug_output) << "bomb has stoped moving" <<endl;
     73                                setVelocity(Vector3::ZERO); //Stop the bomb.
    6274                                isDetonated_ = true;
    6375                        }
    6476                        else
    6577                        {
    66                                 orxout(debug_output)<< "Time to live:" << timeToLife_ <<endl;
    67                                 destroyCheck();
     78                                //orxout(debug_output)<< "Time to live:" << timeToLife_ <<endl;
     79                                destroyCheck(); //Every BasicProjectil has to call this method in each tick.
    6880                        }
    6981                        if(isDetonated_) detonate();
     
    7385        bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    7486        {
    75                 if(otherObject != getShooter())
     87                if(otherObject != getShooter()) //Ensure that the bomb cannot collide with its shooter.
    7688                {
    7789                        orxout(debug_output) << "collides" << endl;
     
    8193                }
    8294                else{
    83                         orxout(debug_output) << "collided with shooter. Has no effect..." << endl;
     95                        //orxout(debug_output) << "collided with shooter. Has no effect..." << endl;
    8496                        return false;
    8597                }
     
    88100        void GravityBomb::detonate()
    89101        {
     102                //Create the GravityBombField and destroy the Projectil.
    90103                GravityBombField* field = new GravityBombField(this->getContext());
    91104                field->setShooter(this->getShooter());
    92105                field->setPosition(getPosition());
    93                 orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
    94                 orxout(debug_output) << "Field is at Position: " << getPosition() << endl;
     106                //orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
     107                //orxout(debug_output) << "Field is at Position: " << getPosition() << endl;
    95108                this->destroy();
    96109        }
Note: See TracChangeset for help on using the changeset viewer.