Changeset 8727 for code/trunk/src/modules/pickup
- Timestamp:
- Jul 3, 2011, 5:42:19 PM (13 years ago)
- Location:
- code/trunk/src/modules/pickup/items
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/items/SpeedPickup.cc
r7548 r8727 38 38 #include "core/XMLPort.h" 39 39 40 #include "items/Engine.h"41 40 #include "pickup/PickupIdentifier.h" 42 41 #include "worldentities/pawns/SpaceShip.h" … … 76 75 this->speedMultiply_ = 1.0f; 77 76 78 this->addTarget(ClassIdentifier< Engine>::getIdentifier());77 this->addTarget(ClassIdentifier<SpaceShip>::getIdentifier()); 79 78 } 80 79 … … 127 126 SUPER(SpeedPickup, changedUsed); 128 127 129 Engine* engine = this->carrierToEngineHelper();130 if( engine == NULL) // If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.128 SpaceShip* ship = this->carrierToSpaceShipHelper(); 129 if(ship == NULL) // If the PickupCarrier is no SpaceShip, then this pickup is useless and therefore is destroyed. 131 130 this->Pickupable::destroy(); 132 131 … … 147 146 } 148 147 149 engine->setSpeedAdd(this->getSpeedAdd());150 engine->setSpeedMultiply(this->getSpeedMultiply());151 } 152 else 153 { 154 engine->setSpeedAdd(0.0f);155 engine->setSpeedMultiply(1.0f);148 ship->addSpeed(this->getSpeedAdd()); 149 ship->addSpeedFactor(this->getSpeedMultiply()); 150 } 151 else 152 { 153 ship->addSpeed(-this->getSpeedAdd()); 154 ship->addSpeedFactor(1.0f/this->getSpeedMultiply()); 156 155 157 156 // We destroy the pickup if either, the pickup has activationType immediate and durationType once or it has durationType continuous and the duration was exceeded. … … 170 169 /** 171 170 @brief 172 Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.171 Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails. 173 172 @return 174 A pointer to the Pawn, or NULL if the conversion failed.175 */ 176 Engine* SpeedPickup::carrierToEngineHelper(void)173 A pointer to the SpaceShip, or NULL if the conversion failed. 174 */ 175 SpaceShip* SpeedPickup::carrierToSpaceShipHelper(void) 177 176 { 178 177 PickupCarrier* carrier = this->getCarrier(); 179 Engine* engine = dynamic_cast<Engine*>(carrier);180 181 if( engine== NULL)178 SpaceShip* ship = dynamic_cast<SpaceShip*>(carrier); 179 180 if(ship == NULL) 182 181 { 183 182 COUT(1) << "Invalid PickupCarrier in SpeedPickup." << std::endl; 184 183 } 185 184 186 return engine;185 return ship; 187 186 } 188 187 -
code/trunk/src/modules/pickup/items/SpeedPickup.h
r7547 r8727 112 112 private: 113 113 void initialize(void); //!< Initializes the member variables. 114 Engine* carrierToEngineHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.114 SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceSHip, and throw an error message if the conversion fails. 115 115 116 116 Timer durationTimer_; //!< Timer.
Note: See TracChangeset
for help on using the changeset viewer.