- Timestamp:
- Dec 9, 2015, 2:45:58 PM (9 years ago)
- Location:
- code/branches/presentationHS15
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationHS15
- Property svn:mergeinfo changed
/code/branches/fabienHS15 (added) merged: 10685,10688,10692,10713-10715,10721,10724,10739,10746,10791,10794-10795,10814,10842,10878
- Property svn:mergeinfo changed
-
code/branches/presentationHS15/src/orxonox/worldentities/pawns/Pawn.cc
r10650 r10961 46 46 #include "weaponsystem/WeaponPack.h" 47 47 #include "weaponsystem/WeaponSet.h" 48 #include "weaponsystem/Munition.h" 48 49 #include "sound/WorldSound.h" 49 50 … … 61 62 62 63 this->bAlive_ = true; 63 this->bReload_ = false;64 64 65 65 this->health_ = 0; … … 71 71 this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max 72 72 this->shieldAbsorption_ = 0.5; 73 74 this->reloadRate_ = 0; 75 this->reloadWaitTime_ = 1.0f; 76 this->reloadWaitCountdown_ = 0; 73 this->shieldRechargeRate_ = 0; 74 this->shieldRechargeWaitTime_ = 1.0f; 75 this->shieldRechargeWaitCountdown_ = 0; 77 76 78 77 this->lastHitOriginator_ = 0; … … 141 140 XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode); 142 141 XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode); 143 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode); 144 145 XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0); 146 XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f); 142 XMLPortObject(Pawn, WeaponPack, "weaponpacks", addWeaponPackXML, getWeaponPack, xmlelement, mode); 143 XMLPortObject(Pawn, Munition, "munition", addMunitionXML, getMunitionXML, xmlelement, mode); 144 145 XMLPortParam(Pawn, "shieldrechargerate", setShieldRechargeRate, getShieldRechargeRate, xmlelement, mode).defaultValues(0); 146 XMLPortParam(Pawn, "shieldrechargewaittime", setShieldRechargeWaitTime, getShieldRechargeWaitTime, xmlelement, mode).defaultValues(1.0f); 147 147 148 148 XMLPortParam(Pawn, "explosionSound", setExplosionSound, getExplosionSound, xmlelement, mode); … … 153 153 void Pawn::registerVariables() 154 154 { 155 registerVariable(this->bAlive_, VariableDirection::ToClient); 156 registerVariable(this->health_, VariableDirection::ToClient); 157 registerVariable(this->maxHealth_, VariableDirection::ToClient); 158 registerVariable(this->shieldHealth_, VariableDirection::ToClient); 159 registerVariable(this->maxShieldHealth_, VariableDirection::ToClient); 160 registerVariable(this->shieldAbsorption_, VariableDirection::ToClient); 161 registerVariable(this->bReload_, VariableDirection::ToServer); 162 registerVariable(this->aimPosition_, VariableDirection::ToServer); // For the moment this variable gets only transfered to the server 155 registerVariable(this->bAlive_, VariableDirection::ToClient); 156 registerVariable(this->health_, VariableDirection::ToClient); 157 registerVariable(this->maxHealth_, VariableDirection::ToClient); 158 registerVariable(this->shieldHealth_, VariableDirection::ToClient); 159 registerVariable(this->maxShieldHealth_, VariableDirection::ToClient); 160 registerVariable(this->shieldAbsorption_, VariableDirection::ToClient); 161 registerVariable(this->aimPosition_, VariableDirection::ToServer); // For the moment this variable gets only transfered to the server 163 162 } 164 163 … … 167 166 SUPER(Pawn, tick, dt); 168 167 169 this->bReload_ = false; 170 168 // Recharge the shield 171 169 // TODO: use the existing timer functions instead 172 if(this-> reloadWaitCountdown_ > 0)173 { 174 this->decrease ReloadCountdownTime(dt);175 } 176 else 177 { 178 this->addShieldHealth(this->get ReloadRate() * dt);179 this->reset ReloadCountdown();170 if(this->shieldRechargeWaitCountdown_ > 0) 171 { 172 this->decreaseShieldRechargeCountdownTime(dt); 173 } 174 else 175 { 176 this->addShieldHealth(this->getShieldRechargeRate() * dt); 177 this->resetShieldRechargeCountdown(); 180 178 } 181 179 … … 229 227 } 230 228 231 void Pawn::set ReloadRate(float reloadrate)232 { 233 this-> reloadRate_ = reloadrate;234 } 235 236 void Pawn::set ReloadWaitTime(float reloadwaittime)237 { 238 this-> reloadWaitTime_ = reloadwaittime;239 } 240 241 void Pawn::decrease ReloadCountdownTime(float dt)242 { 243 this-> reloadWaitCountdown_ -= dt;229 void Pawn::setShieldRechargeRate(float shieldRechargeRate) 230 { 231 this->shieldRechargeRate_ = shieldRechargeRate; 232 } 233 234 void Pawn::setShieldRechargeWaitTime(float shieldRechargeWaitTime) 235 { 236 this->shieldRechargeWaitTime_ = shieldRechargeWaitTime; 237 } 238 239 void Pawn::decreaseShieldRechargeCountdownTime(float dt) 240 { 241 this->shieldRechargeWaitCountdown_ -= dt; 244 242 } 245 243 … … 252 250 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 253 251 { 252 // Health-damage cannot be absorbed by shields. 253 // Shield-damage only reduces shield health. 254 // Normal damage can be (partially) absorbed by shields. 255 254 256 if (shielddamage >= this->getShieldHealth()) 255 257 { … … 480 482 } 481 483 482 void Pawn::reload()483 {484 this->bReload_ = true;485 }486 487 484 void Pawn::postSpawn() 488 485 { … … 554 551 } 555 552 553 std::vector<WeaponPack *> * Pawn::getAllWeaponPacks() 554 { 555 if (this->weaponSystem_) 556 return this->weaponSystem_->getAllWeaponPacks(); 557 else 558 return 0; 559 } 560 561 void Pawn::addMunitionXML(Munition* munition) 562 { 563 if (this->weaponSystem_ && munition) 564 { 565 this->weaponSystem_->addMunition(munition); 566 } 567 } 568 569 Munition* Pawn::getMunitionXML() const 570 { 571 return NULL; 572 } 573 574 Munition* Pawn::getMunition(SubclassIdentifier<Munition> * identifier) 575 { 576 if (weaponSystem_) 577 { 578 return weaponSystem_->getMunition(identifier); 579 } 580 581 return NULL; 582 } 583 556 584 //Tell the Map (RadarViewable), if this is a playership 557 585 void Pawn::startLocalHumanControl() 558 586 { 559 // SUPER(ControllableEntity, changedPlayer());587 // SUPER(ControllableEntity, startLocalHumanControl()); 560 588 ControllableEntity::startLocalHumanControl(); 561 589 this->isHumanShip_ = true;
Note: See TracChangeset
for help on using the changeset viewer.