Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2012, 11:08:17 PM (12 years ago)
Author:
landauf
Message:

merged branch presentation2012merge back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/pickup/items/ShrinkPickup.cc

    r8713 r9348  
    4040#include "core/XMLPort.h"
    4141
    42 #include "pickup/PickupIdentifier.h"
    4342#include "worldentities/pawns/Pawn.h"
    4443
     
    8180    }
    8281
    83     void ShrinkPickup::initializeIdentifier(void)
    84     {
    85         std::stringstream stream;
    86         stream << this->getShrinkFactor();
    87         std::string type1 = "shrinkFactor";
    88         std::string val1 = stream.str();
    89         this->pickupIdentifier_->addParameter(type1, val1);
    90 
    91         stream.clear();
    92         stream << this->getDuration();
    93         std::string val2 = stream.str();
    94         std::string type2 = "duration";
    95         this->pickupIdentifier_->addParameter(type2, val2);
    96 
    97         stream.clear();
    98         stream << this->getShrinkDuration();
    99         std::string val3 = stream.str();
    100         std::string type3 = "shrinkDuration";
    101         this->pickupIdentifier_->addParameter(type3, val3);
    102     }
    103 
    10482   /**
    10583    @brief
     
    11391        XMLPortParam(ShrinkPickup, "duration", setDuration, getDuration, xmlelement, mode);
    11492        XMLPortParam(ShrinkPickup, "shrinkDuration", setShrinkDuration, getShrinkDuration, xmlelement, mode);
    115 
    116         this->initializeIdentifier();
     93    }
     94
     95    /**
     96    @brief Sets the shrinking factor.
     97    @param factor The factor, needs to greater than 1.
     98    */
     99    void ShrinkPickup::setShrinkFactor(float factor)
     100    {
     101        if(factor <= 1.0f)
     102        {
     103            orxout(internal_warning, context::pickups) << "Invalid shrinking factor in ShrinkPickup. Ignoring.." << endl;
     104            return;
     105        }
     106        this->shrinkFactor_ = factor;
     107    }
     108
     109    /**
     110    @brief Set the duration for which the ship remains shrunken.
     111    @param duration The duration, needs to be non-negative.
     112    */
     113    void ShrinkPickup::setDuration(float duration)
     114    {
     115        if(duration < 0.0f)
     116        {
     117            orxout(internal_warning, context::pickups) << "Invalid duration in ShrinkPickup. Ignoring.." << endl;
     118            return;
     119        }
     120        this->duration_ = duration;
     121    }
     122
     123    /**
     124    @brief Set the shrink duration.
     125    @param speed The shrink duration, needs to be positive.
     126    */
     127    void ShrinkPickup::setShrinkDuration(float speed)
     128    {
     129        if(speed <= 0.0f)
     130        {
     131            orxout(internal_warning, context::pickups) << "Invalid shrink duration in ShrinkPickup. Ignoring.." << endl;
     132            return;
     133        }
     134        this->shrinkDuration_ = speed;
    117135    }
    118136
     
    148166    {
    149167        SUPER(ShrinkPickup, changedPickedUp);
    150        
     168
    151169        if(!this->isPickedUp() && this->isActive_)
    152170        {
     
    271289
    272290                bool destroy = false;
    273                
     291
    274292                // Stop shrinking if the desired size is reached.
    275293                if(this->timeRemainig_ <= 0.0f)
     
    314332    {
    315333        PickupCarrier* carrier = this->getCarrier();
    316         Pawn* pawn = dynamic_cast<Pawn*>(carrier);
     334        Pawn* pawn = orxonox_cast<Pawn*>(carrier);
    317335
    318336        return pawn;
    319337    }
    320 
    321     /**
    322     @brief
    323         Creates a duplicate of the input OrxonoxClass.
    324     @param item
    325         A pointer to the Orxonox class.
    326     */
    327     void ShrinkPickup::clone(OrxonoxClass*& item)
    328     {
    329         if(item == NULL)
    330             item = new ShrinkPickup(this);
    331 
    332         SUPER(ShrinkPickup, clone, item);
    333         ShrinkPickup* pickup = dynamic_cast<ShrinkPickup*>(item);
    334         pickup->setShrinkFactor(this->getShrinkFactor());
    335         pickup->setDuration(this->getDuration());
    336         pickup->setShrinkDuration(this->getShrinkDuration());
    337 
    338         pickup->initializeIdentifier();
    339     }
    340338}
Note: See TracChangeset for help on using the changeset viewer.