- Timestamp:
- Dec 17, 2008, 3:20:25 AM (16 years ago)
- Location:
- code/branches/presentation/src/orxonox/objects
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/orxonox/objects/gametypes/Gametype.cc
r2492 r2494 169 169 void Gametype::pawnKilled(Pawn* victim, Pawn* killer) 170 170 { 171 if (victim && victim->getPlayer()) 172 { 173 std::string message; 174 if (killer) 175 { 176 if (killer->getPlayer()) 177 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName(); 178 else 179 message = victim->getPlayer()->getName() + " was killed"; 180 } 181 else 182 message = victim->getPlayer()->getName() + " died"; 183 184 COUT(0) << message << std::endl; 185 Host::Broadcast(message); 186 } 187 171 188 if (victim && victim->getPlayer()) 172 189 { -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
r2493 r2494 40 40 #include "objects/worldentities/Model.h" 41 41 #include "objects/worldentities/ParticleSpawner.h" 42 #include "objects/worldentities/pawns/Pawn.h" 43 #include "objects/collisionshapes/SphereCollisionShape.h" 42 44 #include "core/Core.h" 43 45 … … 49 51 50 52 this->setConfigValues(); 51 this->explosionTemplateName_ = "Orxonox/explosion3"; 52 this->smokeTemplateName_ = "Orxonox/smoke4"; 53 54 //this->setStatic(false); 55 // this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL); 53 this->bDestroy_ = false; 54 this->owner_ = 0; 56 55 57 56 // Get notification about collisions 58 57 this->enableCollisionCallback(); 59 58 60 /* 61 if (this->owner_) 62 { 63 this->setOrientation(this->owner_->getOrientation()); 64 this->setPosition(this->owner_->getPosition()); 65 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 66 } 67 */ 59 this->setCollisionType(Kinematic); 60 61 SphereCollisionShape* shape = new SphereCollisionShape(this); 62 shape->setRadius(10); 63 this->attachCollisionShape(shape); 68 64 69 65 if(!Core::isClient()) //only if not on client … … 88 84 if (!this->isActive()) 89 85 return; 90 /*91 float radius;92 for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it)93 {94 // if ((*it) != this->owner_)95 {96 radius = it->getScale3D().x * 3.0;97 86 98 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius)) 99 { 100 // hit 101 ParticleSpawner* explosion = new ParticleSpawner(this); 102 explosion->setSource(this->explosionTemplateName_); 103 explosion->setLOD(LODParticle::low); 104 explosion->configure(2.0); 105 explosion->setPosition(this->getPosition()); 106 explosion->create(); 107 ParticleSpawner* smoke = new ParticleSpawner(this); 108 smoke->setSource(this->smokeTemplateName_); 109 smoke->setLOD(LODParticle::normal); 110 smoke->configure(2.0, 0.0); 111 smoke->setPosition(this->getPosition()); 112 // smoke->getParticleInterface()->setSpeedFactor(3.0); 113 smoke->create(); 114 delete this; 115 return; 116 } 117 } 118 } 119 */ 87 if (this->bDestroy_) 88 delete this; 120 89 } 121 90 … … 124 93 delete this; 125 94 } 95 96 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 97 { 98 if (!this->bDestroy_) 99 { 100 this->bDestroy_ = true; 101 Pawn* victim = dynamic_cast<Pawn*>(otherObject); 102 if (victim) 103 victim->damage(this->damage_, this->owner_); 104 105 106 if (this->owner_) 107 { 108 { 109 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 110 effect->setPosition(this->getPosition()); 111 effect->setOrientation(this->getOrientation()); 112 effect->setDestroyAfterLife(true); 113 effect->setSource("Orxonox/explosion3"); 114 effect->setLifetime(2.0f); 115 } 116 { 117 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 118 effect->setPosition(this->getPosition()); 119 effect->setOrientation(this->getOrientation()); 120 effect->setDestroyAfterLife(true); 121 effect->setSource("Orxonox/smoke4"); 122 effect->setLifetime(3.0f); 123 } 124 } 125 } 126 return false; 127 } 126 128 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/projectiles/Projectile.h
r2493 r2494 40 40 { 41 41 public: 42 Projectile(BaseObject* creator); 42 43 virtual ~Projectile(); 44 43 45 void setConfigValues(); 44 46 void destroyObject(); 47 45 48 virtual void tick(float dt); 49 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 46 50 47 protected: 48 Projectile(BaseObject* creator); 51 inline void setOwner(Pawn* owner) 52 { this->owner_ = owner; } 53 inline Pawn* getOwner() const 54 { return this->owner_; } 49 55 50 56 private: 51 std::string explosionTemplateName_; 52 std::string smokeTemplateName_; 53 protected: 54 float speed_; 55 private: 57 Pawn* owner_; 56 58 float lifetime_; 57 59 float damage_; 60 bool bDestroy_; 58 61 Timer<Projectile> destroyTimer_; 59 62 }; -
code/branches/presentation/src/orxonox/objects/weaponSystem/weapons/Fusion.cc
r2493 r2494 73 73 projectile->setPosition(this->getWorldPosition()); 74 74 projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_); 75 projectile->setOwner(this->getParentWeaponSystem()->getParentPawn()); 75 76 } 76 77 } -
code/branches/presentation/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2493 r2494 73 73 projectile->setPosition(this->getWorldPosition()); 74 74 projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_); 75 projectile->setOwner(this->getParentWeaponSystem()->getParentPawn()); 75 76 } 76 77 } -
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc
r2485 r2494 498 498 void WorldEntity::setScale3D(const Vector3& scale) 499 499 { 500 /* 500 501 if (this->hasPhysics() && scale != Vector3::UNIT_SCALE) 501 502 { … … 503 504 return; 504 505 } 505 506 */ 506 507 this->node_->setScale(scale); 507 508
Note: See TracChangeset
for help on using the changeset viewer.