Changeset 10067 for code/branches/modularships/src/orxonox/items
- Timestamp:
- May 21, 2014, 10:38:09 PM (11 years ago)
- Location:
- code/branches/modularships/src/orxonox/items
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/modularships/src/orxonox/items/ShipPart.cc
r10058 r10067 41 41 #include "worldentities/StaticEntity.h" 42 42 #include "items/PartDestructionEvent.h" 43 #include "worldentities/BigExplosion.h" 44 #include "chat/ChatManager.h" 43 45 44 46 … … 70 72 XMLPortParam(ShipPart, "damageabsorption", setDamageAbsorption, getDamageAbsorption, xmlelement, mode).defaultValues(0.5); 71 73 74 XMLPortParamTemplate(ShipPart, "explosionposition", setExplosionPosition, getExplosionPosition, xmlelement, mode, Vector3); 75 72 76 XMLPortObject(ShipPart, PartDestructionEvent, "destructionevents", addDestructionEvent, getDestructionEvent, xmlelement, mode); 73 74 /*75 XMLPortParam(ShipPart, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);76 XMLPortParam(ShipPart, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0);77 XMLPortParam(ShipPart, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);78 XMLPortParam(ShipPart, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);79 80 XMLPortParam(ShipPart, "sShipPartparticlesource", setSShipPartParticleSource, getSShipPartParticleSource, xmlelement, mode);81 XMLPortParam(ShipPart, "sShipPartparticleduration", setSShipPartParticleDuration, getSShipPartParticleDuration, xmlelement, mode).defaultValues(3.0f);82 XMLPortParam(ShipPart, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);83 84 XMLPortParam(ShipPart, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);85 XMLPortParam(ShipPart, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);86 87 XMLPortParam(ShipPart, "explosionSound", setExplosionSound, getExplosionSound, xmlelement, mode);88 89 XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );90 */91 77 } 92 78 … … 102 88 return; 103 89 90 this->explode(); 104 91 this->setAlive(false); 105 92 … … 115 102 // Remove this ShipPart from the parent. 116 103 this->parent_->removeShipPart(this); 117 orxout() << this->getName() << " has died." << endl; 104 } 105 106 void ShipPart::explode() 107 { 108 BigExplosion* chunk = new BigExplosion(this->getContext()); 109 chunk->setPosition(this->parent_->getPosition() + this->parent_->getOrientation() * (this->explosionPosition_)); 110 //chunk->setPosition(this->parent_->getPosition() + this->parent_->getOrientation() * Vector3(this->entityList_[0]->getLocalInertia())); 111 chunk->setVelocity(this->parent_->getVelocity()); 112 113 // this->explosionSound_->setPosition(this->parent_->getPosition()); 114 // this->explosionSound_->play(); 118 115 } 119 116 … … 160 157 } 161 158 162 void ShipPart::printEntities()163 {164 orxout() << "ShipPart " << this->getName() << " has the following entities assigned:" << endl;165 for(unsigned int j = 0; j < this->entityList_.size(); j++)166 {167 orxout() << " " << this->entityList_[j]->getName() << endl;168 }169 }170 171 159 /** 172 160 @brief … … 221 209 void ShipPart::handleHit(float damage, float healthdamage, float shielddamage, Pawn* originator) 222 210 { 223 orxout() << "ShipPart " <<this->getName() << " is handling a hit!" << endl;224 225 211 if (parent_->getGametype() && parent_->getGametype()->allowPawnDamage(parent_, originator)) 226 212 { … … 247 233 if (this->health_ < 0) 248 234 this->death(); 249 orxout() << "Health of ShipPart " << this->getName() << " is " << this->getHealth() << endl; 235 236 // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented. 237 if (this->health_ < 0.2 * this->maxHealth_) 238 { 239 ChatManager::message("ShipPart " + this->getName() + " remaining health is 20%!"); 240 return; 241 } 242 if (this->health_ < 0.4 * this->maxHealth_) 243 { 244 ChatManager::message("ShipPart " + this->getName() + " remaining health is 40%!"); 245 return; 246 } 247 if (this->health_ < 0.6 * this->maxHealth_) 248 { 249 ChatManager::message("ShipPart " + this->getName() + " remaining health is 60%!"); 250 return; 251 } 252 if (this->health_ < 0.8 * this->maxHealth_) 253 { 254 ChatManager::message("ShipPart " + this->getName() + " remaining health is 80%!"); 255 return; 256 } 250 257 } 251 258 -
code/branches/modularships/src/orxonox/items/ShipPart.h
r10058 r10067 52 52 53 53 virtual void death(); 54 virtual void explode(); 54 55 55 56 //virtual void attachTo(Pawn* newParent); … … 62 63 void addDestructionEvent(PartDestructionEvent* event); 63 64 PartDestructionEvent* getDestructionEvent(unsigned int index); 64 65 void printEntities(); // FIXME: (noep) remove debug66 65 67 66 virtual void setDamageAbsorption(float value); … … 101 100 { return this->initialHealth_; } 102 101 102 inline void setExplosionPosition(Vector3 pos) 103 { this->explosionPosition_ = pos; } 104 inline Vector3 getExplosionPosition() 105 { return this->explosionPosition_; } 106 103 107 104 108 // FIXME: (noep) Why doesn't this work? Works fine in Engine.h … … 121 125 bool eventExecution_; 122 126 127 Vector3 explosionPosition_; 128 123 129 124 130 }; // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.