Changeset 2919 for code/branches
- Timestamp:
- Apr 18, 2009, 6:41:00 PM (16 years ago)
- Location:
- code/branches/weapons/src/orxonox/objects/weaponSystem
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapons/src/orxonox/objects/weaponSystem/DefaultWeaponmodeLink.cc
r2915 r2919 45 45 this->firemode_ = WeaponSystem::FIRE_MODE_UNASSIGNED; 46 46 this->weaponmode_ = WeaponSystem::WEAPON_MODE_UNASSIGNED; 47 48 COUT(0) << "+DefaultWeaponmodeLink" << std::endl;49 47 } 50 48 51 49 DefaultWeaponmodeLink::~DefaultWeaponmodeLink() 52 50 { 53 COUT(0) << "~DefaultWeaponmodeLink" << std::endl;54 51 } 55 52 -
code/branches/weapons/src/orxonox/objects/weaponSystem/Munition.cc
r2918 r2919 51 51 52 52 this->reloadTime_ = 0; 53 54 COUT(0) << "+Munition" << std::endl;55 53 } 56 54 … … 59 57 for (std::map<WeaponMode*, Magazine*>::iterator it = this->currentMagazines_.begin(); it != this->currentMagazines_.end(); ++it) 60 58 delete it->second; 61 62 COUT(0) << "~Munition" << std::endl;63 59 } 64 60 -
code/branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc
r2918 r2919 53 53 this->reloadTimer_.setTimer(0.0f, false, this, createExecutor(createFunctor(&Weapon::reloaded))); 54 54 this->reloadTimer_.stopTimer(); 55 56 COUT(0) << "+Weapon" << std::endl;57 55 } 58 56 59 57 Weapon::~Weapon() 60 58 { 61 COUT(0) << "~Weapon" << std::endl;62 63 59 if (this->isInitialized()) 64 60 { -
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.cc
r2918 r2919 63 63 this->damage_ = 0; 64 64 this->muzzleOffset_ = Vector3::ZERO; 65 66 COUT(0) << "+WeaponMode" << std::endl;67 65 } 68 66 69 67 WeaponMode::~WeaponMode() 70 68 { 71 COUT(0) << "~WeaponMode" << std::endl;72 69 } 73 70 … … 221 218 return WorldEntity::FRONT; 222 219 } 223 224 /*225 WeaponMode::WeaponMode(BaseObject* creator) : StaticEntity(creator)226 {227 RegisterObject(WeaponMode);228 229 this->bulletReadyToShoot_ = true;230 this->magazineReadyToShoot_ = true;231 this->weaponSystem_ = 0;232 this->weaponPack_ = 0;233 this->weaponSlot_ = 0;234 this->bulletLoadingTime_ = 0;235 this->magazineLoadingTime_ = 0;236 this->bReloading_ = false;237 this->bulletAmount_= 0;238 this->magazineAmount_ = 0;239 this->munition_ = 0;240 this->unlimitedMunition_ = false;241 this->setObjectMode(0x0);242 COUT(0) << "+WeaponMode" << std::endl;243 }244 245 WeaponMode::~WeaponMode()246 {247 COUT(0) << "~WeaponMode" << std::endl;248 if (this->isInitialized() && this->weaponPack_)249 this->weaponPack_->removeWeapon(this);250 }251 252 void WeaponMode::XMLPort(Element& xmlelement, XMLPort::Mode mode)253 {254 SUPER(WeaponMode, XMLPort, xmlelement, mode);255 256 XMLPortParam(WeaponMode, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);257 XMLPortParam(WeaponMode, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);258 XMLPortParam(WeaponMode, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);259 XMLPortParam(WeaponMode, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);260 XMLPortParam(WeaponMode, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);261 XMLPortParam(WeaponMode, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);262 }263 264 void WeaponMode::setWeapon()265 {266 this->munition_->fillBullets();267 this->munition_->fillMagazines();268 }269 270 void WeaponMode::setMunition()271 {272 this->munition_->setMaxBullets(this->bulletAmount_);273 this->munition_->setMaxMagazines(this->magazineAmount_);274 }275 276 void WeaponMode::fire()277 {278 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)279 {280 this->bulletReadyToShoot_ = false;281 if ( this->unlimitedMunition_== true )282 {283 //shoot284 this->reloadBullet();285 this->createProjectile();286 }287 else288 {289 if ( this->munition_->bullets() > 0)290 {291 //shoot and reload292 this->takeBullets();293 this->reloadBullet();294 this->createProjectile();295 }296 //if there are no bullets, but magazines297 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )298 {299 //reload magazine300 this->takeMagazines();301 this->reloadMagazine();302 }303 else304 {305 //no magazines306 }307 }308 }309 else310 {311 //weapon not reloaded312 }313 }314 315 316 //weapon reloading317 void WeaponMode::bulletTimer(float bulletLoadingTime)318 {319 this->bReloading_ = true;320 this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&WeaponMode::bulletReloaded)));321 }322 void WeaponMode::magazineTimer(float magazineLoadingTime)323 {324 this->bReloading_ = true;325 this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&WeaponMode::magazineReloaded)));326 }327 328 void WeaponMode::bulletReloaded()329 {330 this->bReloading_ = false;331 this->bulletReadyToShoot_ = true;332 }333 334 void WeaponMode::magazineReloaded()335 {336 this->bReloading_ = false;337 this->munition_->fillBullets();338 }339 340 341 342 void WeaponMode::attachNeededMunition(const std::string& munitionName)343 {344 // if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem345 if (this->weaponSystem_)346 {347 //getMunitionType returns 0 if there is no such munitionType348 Munition* munition = this->weaponSystem_->getMunitionType(munitionName);349 if ( munition )350 {351 this->munition_ = munition;352 this->setMunition();353 }354 else355 {356 //create new munition with identifier because there is no such munitionType357 this->munitionIdentifier_ = ClassByString(munitionName);358 this->munition_ = this->munitionIdentifier_.fabricate(this);359 this->weaponSystem_->setNewMunition(munitionName, this->munition_);360 this->setMunition();361 }362 }363 }364 365 366 Munition * WeaponMode::getAttachedMunition(const std::string& munitionType)367 {368 this->munition_ = this->weaponSystem_->getMunitionType(munitionType);369 return this->munition_;370 }371 */372 220 } -
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.h
r2918 r2919 151 151 Timer<WeaponMode> reloadTimer_; 152 152 bool bReloading_; 153 /*154 virtual void fire();155 void attachNeededMunition(const std::string& munitionType);156 Munition * getAttachedMunition(const std::string& munitiontype);157 158 //reloading159 void bulletTimer(float bulletLoadingTime);160 void magazineTimer(float magazineLoadingTime);161 void bulletReloaded();162 void magazineReloaded();163 164 //get and set functions for XMLPort165 void setMunitionType(const std::string& munitionType)166 { this->munitionType_ = munitionType; }167 std::string& getMunitionType() const168 { return this->munitionType_; }169 170 void setBulletLoadingTime(float loadingTime)171 { this->bulletLoadingTime_ = loadingTime; }172 float getBulletLoadingTime() const173 { return this->bulletLoadingTime_; }174 175 void setMagazineLoadingTime(float loadingTime)176 { this->magazineLoadingTime_ = loadingTime; }177 float getMagazineLoadingTime() const178 { return this->magazineLoadingTime_; }179 180 void setBulletAmount(unsigned int amount)181 { this->bulletAmount_ = amount; }182 unsigned int getBulletAmount() const183 { return this->bulletAmount_; }184 185 void setMagazineAmount(unsigned int amount)186 { this->magazineAmount_ = amount; }187 unsigned int getMagazineAmount() const188 { return this->magazineAmount_; }189 190 void setUnlimitedMunition(bool unlimitedMunition)191 { this->unlimitedMunition_ = unlimitedMunition; }192 bool getUnlimitedMunition() const193 { return this->unlimitedMunition_; }194 195 //weapon actions196 //these function are defined in the weapon classes197 virtual void takeBullets() {}198 virtual void takeMagazines() {}199 virtual void createProjectile() {}200 virtual void reloadBullet() {}201 virtual void reloadMagazine() {}202 203 //manually set or reset204 virtual void setWeapon();205 virtual void setMunition();206 207 inline void setWeaponSystem(WeaponSystem *weaponSystem)208 { this->weaponSystem_ = weaponSystem; };209 inline WeaponSystem * getWeaponSystem() const210 { return this->weaponSystem_; };211 212 inline void setWeaponPack(WeaponPack *weaponPack)213 { this->weaponPack_ = weaponPack; };214 inline WeaponPack * getWeaponPack() const215 { return this->weaponPack_; };216 217 inline void setWeaponSlot(WeaponSlot * wSlot)218 { this->weaponSlot_ = wSlot; }219 inline WeaponSlot * getWeaponSlot() const220 { return this->weaponSlot_; }221 222 protected:223 bool bReloading_;224 bool bulletReadyToShoot_;225 bool magazineReadyToShoot_;226 bool unlimitedMunition_;227 float bulletLoadingTime_;228 float magazineLoadingTime_;229 unsigned int bulletAmount_;230 unsigned int magazineAmount_;231 std::string munitionType_;232 233 WeaponSlot * weaponSlot_;234 Munition * munition_;235 WeaponSystem * weaponSystem_;236 WeaponPack* weaponPack_;237 238 SubclassIdentifier<Munition> munitionIdentifier_;239 240 Timer<WeaponMode> bulletReloadTimer_;241 Timer<WeaponMode> magazineReloadTimer_;242 */243 153 }; 244 154 } -
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponPack.cc
r2918 r2919 48 48 49 49 this->weaponSystem_ = 0; 50 51 COUT(0) << "+WeaponPack" << std::endl;52 50 } 53 51 54 52 WeaponPack::~WeaponPack() 55 53 { 56 COUT(0) << "~WeaponPack" << std::endl;57 58 54 if (this->isInitialized() && this->weaponSystem_) 59 55 { -
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2918 r2919 46 46 this->weaponSystem_ = 0; 47 47 this->desiredFiremode_ = WeaponSystem::FIRE_MODE_UNASSIGNED; 48 49 COUT(0) << "+WeaponSet" << std::endl;50 48 } 51 49 52 50 WeaponSet::~WeaponSet() 53 51 { 54 COUT(0) << "~WeaponSet" << std::endl;55 56 52 if (this->isInitialized() && this->weaponSystem_) 57 53 this->weaponSystem_->removeWeaponSet(this); -
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2918 r2919 48 48 49 49 this->setObjectMode(0x0); 50 51 COUT(0) << "+WeaponSlot" << std::endl;52 50 } 53 51 54 52 WeaponSlot::~WeaponSlot() 55 53 { 56 COUT(0) << "~WeaponSlot" << std::endl;57 58 54 if (this->isInitialized() && this->weaponSystem_) 59 55 this->weaponSystem_->removeWeaponSlot(this); -
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2918 r2919 53 53 54 54 this->pawn_ = 0; 55 COUT(0) << "+WeaponSystem" << std::endl;56 55 } 57 56 58 57 WeaponSystem::~WeaponSystem() 59 58 { 60 COUT(0) << "~WeaponSystem" << std::endl;61 59 if (this->isInitialized()) 62 60 { -
code/branches/weapons/src/orxonox/objects/weaponSystem/weapons/FusionFire.cc
r2918 r2919 60 60 projectile->setPosition(this->getMuzzlePosition()); 61 61 projectile->setVelocity(this->getMuzzleDirection() * this->speed_); 62 projectile->scale(5); 62 63 63 64 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
Note: See TracChangeset
for help on using the changeset viewer.