Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 5:30:39 PM (15 years ago)
Author:
polakma
Message:

fixed projectile, particle effect, reloadingTimer and magazineTimer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc

    r2379 r2391  
    3939    CreateFactory(Weapon);
    4040
    41     Weapon::Weapon(BaseObject* creator) : BaseObject(creator)
     41    Weapon::Weapon(BaseObject* creator) : PositionableEntity(creator)
    4242    {
    4343        RegisterObject(Weapon);
     
    4747        this->parentWeaponSlot_ = 0;
    4848        this->munition_ = 0;
     49        this->bulletLoadingTime_ = 0;
     50        this->magazineLoadingTime_ = 0;
     51        this->bReloading_ = false;
    4952    }
    5053
     
    6265    void Weapon::setWeapon()
    6366    {
     67COUT(0) << "LaserGun::setWeapon" << std::endl;
    6468        this->bulletLoadingTime_ = 0.5;
    6569        this->magazineLoadingTime_ = 3.0;
    6670        this->munition_->setMaxMagazines(100);
    67         this->munition_->setMaxBullets(30);
     71        this->munition_->setMaxBullets(6);
    6872        this->munition_->fillBullets();
    6973        this->munition_->fillMagazines();
     
    7478    {
    7579COUT(0) << "LaserGun::fire, this=" << this << std::endl;
    76         if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ )
     80        if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
    7781        {
    7882COUT(0) << "LaserGun::fire - ready to shoot" << std::endl;
    79 
     83COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl;
    8084            this->bulletReadyToShoot_ = false;
    81             if ( this->munition_->bullets() )
     85            if ( this->munition_->bullets() > 0)
    8286            {
    8387                //shoot
     
    8690            }
    8791            //if there are no bullets, but magazines
    88             else if ( this->munition_->magazines() && !this->munition_->bullets() )
    89             {
     92            else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
     93            {
     94COUT(0) << "LaserGun::fire - no bullets" << std::endl;
    9095                this->takeMagazines();
     96            }
     97            else
     98            {
     99COUT(0) << "LaserGun::fire - no magazines" << std::endl;
     100                //actions
    91101            }
    92102        }
     
    94104        {
    95105COUT(0) << "LaserGun::fire - weapon not reloaded" << std::endl;
     106            //actions
    96107        }
    97108
     
    102113    {
    103114COUT(0) << "Weapon::bulletTimer started" << std::endl;
     115        this->bReloading_ = true;
    104116        this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded)));
    105117    }
     
    107119    {
    108120COUT(0) << "Weapon::magazineTimer started" << std::endl;
     121        this->bReloading_ = true;
    109122        this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded)));
    110123    }
    111124
    112125    void Weapon::bulletReloaded()
    113     { this->bulletReadyToShoot_ = true; }
     126    {
     127        this->bReloading_ = false;
     128        this->bulletReadyToShoot_ = true;
     129    }
    114130
    115131    void Weapon::magazineReloaded()
    116     {
     132    {
     133        this->bReloading_ = false;
    117134        this->munition_->fillBullets();
    118135        this->magazineReadyToShoot_ = true;
Note: See TracChangeset for help on using the changeset viewer.