- Timestamp:
- Dec 10, 2008, 3:37:48 AM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2256 r2369 33 33 #include "core/XMLPort.h" 34 34 #include "util/Math.h" 35 #include "PawnManager.h" 35 36 #include "objects/infos/PlayerInfo.h" 36 37 #include "objects/gametypes/Gametype.h" … … 45 46 RegisterObject(Pawn); 46 47 47 this->bAlive_ = false; 48 PawnManager::touch(); 49 50 this->bAlive_ = true; 48 51 49 52 this->health_ = 0; … … 70 73 Pawn::~Pawn() 71 74 { 75 if (this->isInitialized()) 76 { 77 for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it) 78 it->destroyedPawn(this); 79 } 72 80 } 73 81 … … 76 84 SUPER(Pawn, XMLPort, xmlelement, mode); 77 85 78 XMLPortParam(Pawn, "health", setHealth, getHeal ht, xmlelement, mode).defaultValues(100);86 XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); 79 87 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 80 88 XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); … … 85 93 REGISTERDATA(this->bAlive_, direction::toclient); 86 94 REGISTERDATA(this->health_, direction::toclient); 95 REGISTERDATA(this->initialHealth_, direction::toclient); 87 96 } 88 97 … … 90 99 { 91 100 SUPER(Pawn, tick, dt); 101 102 this->health_ -= 15 * dt * rnd(); 92 103 93 104 if (this->health_ <= 0) … … 129 140 void Pawn::death() 130 141 { 142 // Set bAlive_ to false and wait for PawnManager to do the destruction 131 143 this->bAlive_ = false; 144 132 145 if (this->getGametype()) 133 146 this->getGametype()->pawnKilled(this, this->lastHitOriginator_); 147 148 this->setDestroyWhenPlayerLeft(false); 149 134 150 if (this->getPlayer()) 135 151 this->getPlayer()->stopControl(this); 136 137 delete this;138 152 139 153 // play death effect … … 151 165 this->spawn(); 152 166 } 167 168 /////////////////// 169 // Pawn Listener // 170 /////////////////// 171 PawnListener::PawnListener() 172 { 173 RegisterRootObject(PawnListener); 174 } 153 175 } -
code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.h
r2256 r2369 55 55 inline void removeHealth(float health) 56 56 { this->setHealth(this->health_ - health); } 57 inline float getHeal ht() const57 inline float getHealth() const 58 58 { return this->health_; } 59 59 … … 96 96 WeaponSystem* weaponSystem_; 97 97 }; 98 99 class _OrxonoxExport PawnListener : public OrxonoxClass 100 { 101 friend class Pawn; 102 103 public: 104 PawnListener(); 105 virtual ~PawnListener() {} 106 107 protected: 108 virtual void destroyedPawn(Pawn* pawn) = 0; 109 }; 98 110 } 99 111
Note: See TracChangeset
for help on using the changeset viewer.