Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 12, 2008, 4:45:50 PM (17 years ago)
Author:
polakma
Message:

added munition, fixed reloadTimer_

File:
1 edited

Legend:

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

    r2186 r2203  
    3535#include "Weapon.h"
    3636
    37 
    3837namespace orxonox
    3938{
     
    4342        this->weaponReadyToShoot_ = true;
    4443        this->setParentWeaponSystem();
    45         this->pointerToMunition_ = this->parentWeaponSystem_->getAttachedMunitionPointer;
    46         this->attachNeededMunition(this->pointerToMunition_);
    47 
    4844    }
    4945
     
    6258
    6359    }
     60    void Weapon::timer()
     61    {
     62        this->reloadTimer_.setTimer( this->loadingTime_ , false , this , createExecutor(createFunctor(&Weapon::reloaded)));
     63    }
    6464
    6565    void Weapon::reloaded()
    6666    {
     67
    6768        this->weaponReadyToShoot_ = true;
    6869    }
    6970
    70     void attachNeededMunition(Munition *pointerToMunition)
     71    void Weapon::attachNeededMunition(std::string munitionName)
    7172    {
    7273        //if munition type already exist attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
    73         if ( this->parentWeaponSystem_->munitionSet_[laserGunMunition] )
    74             this->pointerToMunition_ = pointerToMunition;
     74        if ( this->parentWeaponSystem_->getMunitionType(munitionName) )
     75            this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionName);
    7576        else
    7677        {
    77             this->pointerToMunition_ = new LaserGunMunition;
    78             this->parentWeaponSystem_->munitionSet_[laserGunMunition] = this->pointerToMunition_;
    79 
     78            //create new munition with identifier
     79            this->munitionIdentifier_ = ClassByString(munitionName);
     80            this->munition_ = this->munitionIdentifier_.fabricate(this);
     81            this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
    8082        }
    8183    }
    8284
    83 /*
     85
     86    /*get and set functions
     87     *
     88     */
    8489    void Weapon::setParentWeaponSystem()
    85     {
    86         this->parentWeaponSystem_ = this->parentWeaponSlot_->parentWeaponSet_->parentWeaponSystem_;
    87     }
    88 */
     90    {   this->parentWeaponSystem_ = this->parentWeaponSlot_->getParentWeaponSet()->getParentWeaponSystem(); }
    8991
     92    Munition * Weapon::getAttachedMunition()
     93    {   return this->munition_; }
     94
     95    void Weapon::setLoadingTime(float loadingTime)
     96    {   this->loadingTime_ = loadingTime;   }
     97
     98    float Weapon::getLoadingTime()
     99    {   return this->loadingTime_;  }
     100
     101    void Weapon::setWeaponReadyToShoot(bool b)
     102    {   this->weaponReadyToShoot_ = b;   }
     103
     104    bool Weapon::getWeaponReadyToShoot()
     105    {   return this->weaponReadyToShoot_;    }
     106    Timer<Weapon> * Weapon::getTimer()
     107    {   return &this->reloadTimer_;   }
    90108}
Note: See TracChangeset for help on using the changeset viewer.