- Timestamp:
- Nov 12, 2008, 4:45:50 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2186 r2203 35 35 #include "Weapon.h" 36 36 37 38 37 namespace orxonox 39 38 { … … 43 42 this->weaponReadyToShoot_ = true; 44 43 this->setParentWeaponSystem(); 45 this->pointerToMunition_ = this->parentWeaponSystem_->getAttachedMunitionPointer;46 this->attachNeededMunition(this->pointerToMunition_);47 48 44 } 49 45 … … 62 58 63 59 } 60 void Weapon::timer() 61 { 62 this->reloadTimer_.setTimer( this->loadingTime_ , false , this , createExecutor(createFunctor(&Weapon::reloaded))); 63 } 64 64 65 65 void Weapon::reloaded() 66 66 { 67 67 68 this->weaponReadyToShoot_ = true; 68 69 } 69 70 70 void attachNeededMunition(Munition *pointerToMunition)71 void Weapon::attachNeededMunition(std::string munitionName) 71 72 { 72 73 //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); 75 76 else 76 77 { 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_); 80 82 } 81 83 } 82 84 83 /* 85 86 /*get and set functions 87 * 88 */ 84 89 void Weapon::setParentWeaponSystem() 85 { 86 this->parentWeaponSystem_ = this->parentWeaponSlot_->parentWeaponSet_->parentWeaponSystem_; 87 } 88 */ 90 { this->parentWeaponSystem_ = this->parentWeaponSlot_->getParentWeaponSet()->getParentWeaponSystem(); } 89 91 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_; } 90 108 }
Note: See TracChangeset
for help on using the changeset viewer.