Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 27, 2010, 3:33:15 PM (14 years ago)
Author:
gnadler
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.cc

    r6966 r6969  
    5858        this->localAngularVelocity_ = 0;
    5959        this->bDestroy_ = false;
    60         this->lifetime_ = 100;
     60        this->lifetime_ = 120;
    6161        this->setMass(15);
    6262        COUT(4) << "simplerocket constructed\n";
    63         this->counter_=0;
    64         this->slowing_=false;
     63        this->maxLife_=90;
    6564
    6665        if (GameMode::isMaster())
     
    8988            collisionShape->setHeight(200);
    9089            this->attachCollisionShape(collisionShape);
    91            
    92 
    9390            this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&SimpleRocket::destroyObject, this)));
    9491        }
     
    9693    }
    9794   
    98     void SimpleRocket::disableFire(){
    99         this->setAcceleration(0,0,0);
    100         this->setVelocity(Vector3(0,0,0));
     95
     96
     97
     98    void SimpleRocket::tick(float dt)
     99    {
     100
     101        SUPER(SimpleRocket, tick, dt);
     102        if (this->getVelocity().squaredLength() >130000) this->maxLife_-=dt; //if Velocity bigger than about 360, uses a lot more "fuel" :)
    101103       
    102         this->fire_->detachFromParent();
    103         //this->fire_->setVisible(false);
    104 
    105     }
    106 
    107 
    108     void SimpleRocket::tick(float dt)
    109     {
    110 
    111         SUPER(SimpleRocket, tick, dt);
    112         counter_++;
    113         if (this->getVelocity().squaredLength() >130000 && !slowing_) counter_++; //if Velocity bigger than about 360, uses a lot more "fuel" :)
    114104
    115105            this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
     
    119109           
    120110            if (this->fuel_) {
    121                 COUT(0)<<this->getVelocity().length()<<endl;
    122                 if (this->counter_>1000 && counter_%12==0)
    123                    
    124                     if (!this->slowing_) {
    125                         this->setAcceleration(this->getOrientation()*Vector3(10,10,10));
    126                         this->slowing_=true;
    127                     }
    128 
    129                 if (this->counter_ > 1800)
     111                if (this->destroyTimer_.getRemainingTime()<  this->lifetime_-this->maxLife_ )
    130112                    this->fuel_=false;
    131             }
     113            } else this->disableFire();
     114
    132115            if( this->bDestroy_ )
    133116                this->destroy();
    134             if (!this->fuel_)
    135                 this->disableFire();
    136        
    137            
    138            
    139        
     117               
     118    }
     119
     120    void SimpleRocket::disableFire(){
     121        this->setAcceleration(0,0,0);       
     122        this->fire_->detachFromParent();
     123
    140124    }
    141125
     
    221205    }
    222206   
    223     void SimpleRocket::setDestroy()
    224     {
    225         this->bDestroy_=true;
    226         CCOUT(4)<<"trying to destroy";
    227     }
    228207
    229208    void SimpleRocket::fired(unsigned int firemode)
Note: See TracChangeset for help on using the changeset viewer.