Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 22, 2010, 10:45:09 PM (14 years ago)
Author:
ebeier
Message:

first working version of the SpeedPickup, needs some more work for "onUse" type. Spaceship trails need to be looked at, because they don't show when a SpeedPickup with SpeedAdd is used.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ppspickups1/src/modules/pickup/Pickup.cc

    r6540 r6607  
    3939#include "DroppedPickup.h"
    4040
     41#include "tools/Timer.h"
     42
    4143namespace orxonox
    4244{
    43    
     45
    4446    /*static*/ const std::string Pickup::activationTypeImmediate_s = "immediate";
    4547    /*static*/ const std::string Pickup::activationTypeOnUse_s = "onUse";
    4648    /*static*/ const std::string Pickup::durationTypeOnce_s = "once";
    4749    /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous";
    48    
     50
    4951    Pickup::Pickup(BaseObject* creator) : BaseObject(creator)
    5052    {
    5153        RegisterObject(Pickup);
    52        
     54
    5355        this->initialize();
    5456    }
    55    
     57
    5658    Pickup::~Pickup()
    5759    {
    58        
    59     }
    60    
     60
     61    }
     62
    6163    /**
    6264    @brief
     
    6870        this->durationType_ = pickupDurationType::once;
    6971    }
    70    
     72
    7173    /**
    7274    @brief
     
    7476    */
    7577    void Pickup::initializeIdentifier(void)
    76     {       
     78    {
    7779        std::string val1 = this->getActivationType();
    7880        std::string type1 = "activationType";
    7981        this->pickupIdentifier_->addParameter(type1, val1);
    80        
     82
    8183        std::string val2 = this->getDurationType();
    8284        std::string type2 = "durationType";
    8385        this->pickupIdentifier_->addParameter(type2, val2);
    8486    }
    85    
     87
    8688    /**
    8789    @brief
     
    9496        XMLPortParam(Pickup, "activationType", setActivationType, getActivationType, xmlelement, mode);
    9597        XMLPortParam(Pickup, "durationType", setDurationType, getDurationType, xmlelement, mode);
    96        
     98
    9799        this->initializeIdentifier();
    98100    }
    99    
     101
    100102    /**
    101103    @brief
     
    116118        }
    117119    }
    118        
     120
    119121    /**
    120122    @brief
     
    135137        }
    136138    }
    137    
     139
    138140    /**
    139141    @brief
     
    157159        }
    158160    }
    159        
     161
    160162    /**
    161163    @brief
     
    179181        }
    180182    }
    181    
     183
    182184    /**
    183185    @brief
     
    188190    {
    189191        SUPER(Pickup, changedPickedUp);
    190        
     192
    191193        //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
    192194        if(this->getCarrier() != NULL && this->isPickedUp() && this->isImmediate())
     
    195197        }
    196198    }
    197    
     199
    198200    /**
    199201    @brief
     
    206208        if(item == NULL)
    207209            item = new Pickup(this);
    208        
     210
    209211        SUPER(Pickup, clone, item);
    210        
     212
    211213        Pickup* pickup = dynamic_cast<Pickup*>(item);
    212214        pickup->setActivationTypeDirect(this->getActivationTypeDirect());
    213215        pickup->setDurationTypeDirect(this->getDurationTypeDirect());
    214        
     216
    215217        pickup->initializeIdentifier();
    216218    }
    217        
     219
    218220    /**
    219221    @brief
     
    231233        return true;
    232234    }
    233    
     235
     236    /**
     237    @brief
     238        Starts the Pickup duration Timer.
     239    */
     240    bool Pickup::startPickupTimer(float durationTime)
     241    {
     242        if (durationTime<=0)
     243        {
     244            COUT(1) << "Invalid durationTime in pickup." << std::endl;
     245            return false;
     246        }
     247        if (false) /* How to check if Timer already running? */
     248        {
     249            COUT(1) << "Pickup durationTimer already in use." << std::endl;
     250            return false;
     251        }
     252        this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::PickupTimerCallBack, this)));
     253        return true;
     254    }
    234255}
Note: See TracChangeset for help on using the changeset viewer.