Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 2:38:33 PM (16 years ago)
Author:
polakma
Message:

changed Weapon::fire and munition reloading

File:
1 edited

Legend:

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

    r2366 r2379  
    6060    }
    6161
     62    void Weapon::setWeapon()
     63    {
     64        this->bulletLoadingTime_ = 0.5;
     65        this->magazineLoadingTime_ = 3.0;
     66        this->munition_->setMaxMagazines(100);
     67        this->munition_->setMaxBullets(30);
     68        this->munition_->fillBullets();
     69        this->munition_->fillMagazines();
     70    }
     71
     72
    6273    void Weapon::fire()
    6374    {
     75COUT(0) << "LaserGun::fire, this=" << this << std::endl;
     76        if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ )
     77        {
     78COUT(0) << "LaserGun::fire - ready to shoot" << std::endl;
     79
     80            this->bulletReadyToShoot_ = false;
     81            if ( this->munition_->bullets() )
     82            {
     83                //shoot
     84                this->takeBullets();
     85                this->createProjectile();
     86            }
     87            //if there are no bullets, but magazines
     88            else if ( this->munition_->magazines() && !this->munition_->bullets() )
     89            {
     90                this->takeMagazines();
     91            }
     92        }
     93        else
     94        {
     95COUT(0) << "LaserGun::fire - weapon not reloaded" << std::endl;
     96        }
    6497
    6598    }
    6699
    67100
    68     void Weapon::bulletTimer()
     101    void Weapon::bulletTimer(float bulletLoadingTime)
    69102    {
    70         this->bulletReloadTimer_.setTimer( this->bulletLoadingTime_ , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded)));
     103COUT(0) << "Weapon::bulletTimer started" << std::endl;
     104        this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded)));
    71105    }
    72     void Weapon::magazineTimer()
     106    void Weapon::magazineTimer(float magazineLoadingTime)
    73107    {
    74         this->magazineReloadTimer_.setTimer( this->magazineLoadingTime_ , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded)));
     108COUT(0) << "Weapon::magazineTimer started" << std::endl;
     109        this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded)));
    75110    }
    76111
     
    79114
    80115    void Weapon::magazineReloaded()
    81     { this->magazineReadyToShoot_ = true; }
     116    {
     117        this->munition_->fillBullets();
     118        this->magazineReadyToShoot_ = true;
     119    }
    82120
    83121
     
    104142
    105143
    106     /*get and set functions
     144     /*get and set functions
    107145     *
    108146     */
     
    123161return this->munition_; }
    124162
     163
     164
    125165    void Weapon::setBulletLoadingTime(float loadingTime)
    126166    {   this->bulletLoadingTime_ = loadingTime;   }
     
    135175    {   return this->magazineLoadingTime_;  }
    136176
    137     void Weapon::setBulletReadyToShoot(bool b)
    138     {   this->bulletReadyToShoot_ = b;   }
    139 
    140     bool Weapon::getBulletReadyToShoot()
    141     {   return this->bulletReadyToShoot_;    }
    142 
    143     void Weapon::setMagazineReadyToShoot(bool b)
    144     {   this->magazineReadyToShoot_ = b;   }
    145 
    146     bool Weapon::getMagazineReadyToShoot()
    147     {   return this->magazineReadyToShoot_;    }
    148177
    149178    Timer<Weapon> * Weapon::getBulletTimer()
     
    152181    Timer<Weapon> * Weapon::getMagazineTimer()
    153182    {   return &this->magazineReloadTimer_;   }
     183
     184    void Weapon::takeBullets() { };
     185    void Weapon::createProjectile() { };
     186    void Weapon::takeMagazines() { };
     187
    154188}
Note: See TracChangeset for help on using the changeset viewer.