Changeset 7021 for code/branches/presentation3
- Timestamp:
- May 30, 2010, 3:57:05 PM (14 years ago)
- Location:
- code/branches/presentation3/src/modules/weapons
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/weapons/RocketController.cc
r7018 r7021 50 50 this->rocket_->setController(this); 51 51 this->setControllableEntity(dynamic_cast<ControllableEntity*> (this->rocket_)); 52 this->counter_=0;53 52 } 54 53 … … 62 61 void RocketController::tick(float dt) 63 62 { 64 counter_++;65 63 66 64 if (this->target_ && this->rocket_->hasFuel()) { … … 99 97 if (!this->getControllableEntity()) 100 98 return; 101 Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target); 102 float distance = (target - this->getControllableEntity()->getWorldPosition()).length(); 99 100 Vector2 coord = get2DViewdirection(this->rocket_->getPosition(), this->rocket_->getOrientation() * WorldEntity::FRONT, this->rocket_->getOrientation() * WorldEntity::UP, target); 101 float distance = (target - this->rocket_->getWorldPosition()).length(); 103 102 104 103 105 if (distance > 1000 &&this->getControllableEntity()->getVelocity().squaredLength()<160000)106 this-> getControllableEntity()->setAcceleration(this->rocket_->getOrientation()*Vector3(-20,-20,-20));104 if (distance > 1000 && this->rocket_->getVelocity().squaredLength()<160000) 105 this->rocket_->setAcceleration(this->rocket_->getOrientation()*Vector3(-20,-20,-20)); 107 106 if (distance <1000) this->rocket_->setAcceleration(0,0,0); 108 109 this-> getControllableEntity()->rotateYaw(-sgn(coord.x)*coord.x*coord.x);110 this-> getControllableEntity()->rotatePitch(sgn(coord.y)*coord.y*coord.y);107 108 this->rocket_->rotateYaw(-sgn(coord.x)*coord.x*coord.x); 109 this->rocket_->rotatePitch(sgn(coord.y)*coord.y*coord.y); 111 110 } 112 111 -
code/branches/presentation3/src/modules/weapons/RocketController.h
r7018 r7021 52 52 53 53 virtual void tick(float dt); 54 SimpleRocket* getRocket(){return this->rocket_;}; 54 SimpleRocket* getRocket() const 55 { return this->rocket_; }; 55 56 void setTarget(WorldEntity* target); 56 57 protected: … … 60 61 61 62 private: 62 SimpleRocket* rocket_; 63 SimpleRocket* rocket_; //!<The Rocket it controlls 63 64 Vector3 targetPosition_; 64 65 WeakPtr<PlayerInfo> player_; 65 66 66 67 WeakPtr<WorldEntity> target_; 67 int counter_;68 68 69 69 -
code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc
r7019 r7021 45 45 namespace orxonox 46 46 { 47 /** 48 @file 49 @brief 50 SimpleRocket, follows direction from a Rocketcontroller, has fuel for 80% of its lifetime, afterwords it's fire disappears. 51 @author 52 Gabriel Nadler (Original file: Oli Scheuss) 53 */ 47 54 CreateFactory(SimpleRocket); 48 // create the factory for the SimpleRocket 49 50 /** 51 @brief 52 Constructor. Registers the object and initializes some default values. 53 */ 55 56 54 57 SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator) 55 58 { … … 59 62 this->bDestroy_ = false; 60 63 this->lifetime_ = 120; 64 61 65 this->setMass(15); 62 66 COUT(4) << "simplerocket constructed\n"; 63 this->maxLife_=90;64 67 65 68 if (GameMode::isMaster()) … … 92 95 93 96 } 94 95 96 97 97 98 99 100 /** 101 * @brief updates state of rocket, disables fire if no fuel 102 * @param dt tick-length 103 */ 98 104 void SimpleRocket::tick(float dt) 99 105 { … … 102 108 if ( GameMode::isMaster() ) 103 109 { 104 if (this->getVelocity().squaredLength() >130000) 105 this->maxLife_-=dt; //if Velocity bigger than about 360, uses a lot more "fuel" :) 106 110 107 111 108 112 this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_); … … 110 114 this->localAngularVelocity_ = 0; 111 115 112 116 113 117 if (this->fuel_) 114 118 { 115 if (this->destroyTimer_.getRemainingTime()< this->lifetime_-this->maxLife_ )119 if (this->destroyTimer_.getRemainingTime()< (static_cast<float>(this->FUEL_PERCENTAGE)/100) *this->lifetime_ ) 116 120 this->fuel_=false; 117 } 118 else 121 } else 119 122 this->disableFire(); 120 123 121 if( this->bDestroy_ ) 124 if( this->bDestroy_ ) 122 125 this->destroy(); 123 126 } … … 125 128 } 126 129 130 /** 131 * @brief Sets the Acceleration to 0 and detaches the fire 132 * @return void 133 */ 127 134 void SimpleRocket::disableFire() 128 135 { 129 this->setAcceleration(0,0,0); 130 this->fire_->destroy(); 131 this->fire_ = 0; 132 // this->fire_->detachFromParent(); 136 this->setAcceleration(0,0,0); 137 this->fire_->detachFromParent(); 133 138 } 134 139 … … 144 149 { 145 150 this->getController()->destroy(); 146 COUT(4)<< "simplerocket destroyed\n";147 151 } 148 152 } … … 162 166 { 163 167 this->owner_ = owner; 164 //this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();165 168 this->player_ = this->owner_->getPlayer(); 166 169 } 170 167 171 168 172 -
code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.h
r7019 r7021 27 27 */ 28 28 29 /** 30 @file 31 @brief 32 SimpleRocket, follows direction from a Rocketcontroller, has fuel for 80% of its lifetime, afterwords it's fire disappears. 33 @author 34 Gabriel Nadler (Original file: Oli Scheuss) 35 */ 36 37 38 29 39 #ifndef _SimpleRocket_H__ 30 40 #define _SimpleRocket_H__ … … 40 50 class ConeCollisionShape; 41 51 42 /** 43 @brief 44 SimpleRocket, that is made to move upon a specified pattern. 45 This class was constructed for the PPS tutorial. 46 @author 47 Oli Scheuss 48 */ 52 49 53 class _WeaponsExport SimpleRocket : public ControllableEntity 50 54 { … … 58 62 void destroyObject(); 59 63 60 void disableFire(); 64 void disableFire(); //!< Method to disable the fire and stop all acceleration 61 65 62 66 virtual void moveFrontBack(const Vector2& value){} … … 112 116 inline Pawn* getOwner() const 113 117 { return this->owner_; } 114 inline bool hasFuel() 115 { return this->fuel_;} 116 117 inline void fuelRefill() 118 {this->fuel_=true;} 118 inline bool hasFuel() const 119 { return this->fuel_; } 119 120 120 121 inline void setDamage(float damage) … … 128 129 Vector3 localAngularVelocity_; 129 130 float damage_; 130 bool bDestroy_; 131 bool fuel_; 131 bool bDestroy_; 132 bool fuel_; //!< Bool is true while the rocket "has fuel" 132 133 133 134 … … 135 136 Timer destroyTimer_; 136 137 float lifetime_; 137 float maxLife_;138 static const int FUEL_PERCENTAGE=80; //!<Percentage of Lifetime the rocket has fuel 138 139 139 ParticleEmitter* fire_; 140 ParticleEmitter* fire_; //!< Fire-Emittor 140 141 141 142 -
code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
r7019 r7021 40 40 namespace orxonox 41 41 { 42 /** 43 @file 44 @brief 45 FireMode for target-seeking Rocket 46 @author 47 Gabriel Nadler (Original file: Oli Scheuss) 48 */ 42 49 CreateFactory(SimpleRocketFire); 43 50
Note: See TracChangeset
for help on using the changeset viewer.