Changeset 10889
- Timestamp:
- Nov 29, 2015, 9:05:26 PM (9 years ago)
- Location:
- code/branches/particleEffectsHS15
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/particleEffectsHS15/data/levels/includes/weaponSettingsEscort.oxi
r10836 r10889 14 14 </links> 15 15 <Weapon> 16 <MineGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" />16 <MineGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" maxtimeuntilexplosion=5 timeuntilactivation=1.5/> 17 17 </Weapon> 18 18 <Weapon> -
code/branches/particleEffectsHS15/src/modules/weapons/WeaponsPrereqs.h
r10622 r10889 93 93 class LaserFire; 94 94 class LightningGun; 95 class MineGun; 95 96 class RocketFire; 96 97 class RocketFireOld; -
code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc
r10836 r10889 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "graphics/Model.h" 37 38 #include "core/command/Executor.h" 38 #include "util/Convert.h"39 #include "util/Math.h"40 41 #include "core/CoreIncludes.h"42 #include "graphics/Model.h"43 #include "graphics/ParticleSpawner.h"44 #include "Scene.h"45 #include "core/command/Executor.h"46 #include "tools/ParticleInterface.h"47 39 48 40 namespace orxonox … … 50 42 RegisterClass(MineProjectile); 51 43 52 MineProjectile::MineProjectile(Context* context) : Projectile(context)44 MineProjectile::MineProjectile(Context* context) : MovableEntity(context), BasicProjectile() 53 45 { 54 46 RegisterObject(MineProjectile); 55 47 56 this->lifeTime_ = 1.0f; 48 this->bActive_ = false; 49 this->maxTimeUntilExplosion_ = 10.0f; 50 this->timeUntilActivation_ = 1.0f; 57 51 58 Model* model = new Model(this->getContext()); 59 model->setMeshSource("sphere.mesh"); 60 model->setScale(15.0); 61 this->attach(model); 62 model->setPosition(Vector3(0,0,0)); 52 rings_ = new MovableEntity(this->getContext()); 53 this->attach(rings_); 54 rings_->setPosition(Vector3(0.0,0.0,0.0)); 55 rings_->setAngularVelocity(Vector3(0.0,5.0,0.0)); 56 57 modelCore_ = new Model(this->getContext()); 58 modelCore_->setMeshSource("Mine_Core.mesh"); 59 modelCore_->setScale(15.0); 60 this->attach(modelCore_); 61 modelCore_->setPosition(Vector3(0,0,0)); 62 63 modelRing1_ = new Model(this->getContext()); 64 modelRing1_->setMeshSource("Mine_Ring.mesh"); 65 modelRing1_->setScale(15.0); 66 rings_->attach(modelRing1_); 67 modelRing1_->setPosition(Vector3(0,0,0)); 68 modelRing1_->yaw(Degree(0)); 69 70 modelRing2_ = new Model(this->getContext()); 71 modelRing2_->setMeshSource("Mine_Ring.mesh"); 72 modelRing2_->setScale(15.0); 73 rings_->attach(modelRing2_); 74 modelRing2_->setPosition(Vector3(0,0,0)); 75 modelRing2_->yaw(Degree(180)); 76 77 if (GameMode::isMaster()) 78 { 79 this->setMass(10.0f); 80 this->setFriction(100.0f); 81 this->enableCollisionCallback(); 82 this->setCollisionResponse(false); 83 this->setCollisionType(Dynamic); 84 85 // Create a sphere collision shape and attach it to the projectile. 86 collisionShape_ = new SphereCollisionShape(this->getContext()); 87 collisionShape_->setRadius(10.0f); 88 this->attachCollisionShape(collisionShape_); 89 90 // Create a distance trigger and attach it to the projectile. 91 distanceTrigger_ = new DistanceTrigger(this->getContext()); 92 this->attach(distanceTrigger_); 93 distanceTrigger_->setPosition(Vector3(0,0,0)); 94 distanceTrigger_->setDistance(40.0f); 95 distanceTrigger_->addTarget("Pawn"); 96 distanceTrigger_->setStayActive(true); 97 } 63 98 } 64 99 65 100 MineProjectile::~MineProjectile() 101 { 102 /*if (modelCore_ != NULL) 103 { 104 modelCore_->destroy(); 105 }*/ 106 /*if (distanceTrigger_ != NULL) 107 { 108 distanceTrigger_->destroy(); 109 }*/ 110 } 111 66 112 /** 67 113 @brief 68 T his function starts a timer that will cause the projectile to Mine after a time defined by the argument @param LifeTime.114 TODO 69 115 */ 70 void MineProjectile::set LifeTime(float lifeTime)116 void MineProjectile::setMaxTimeUntilExplosion(float maxTimeUntilExplosion) 71 117 { 72 orxout() << lifeTime << endl; 73 74 if (lifeTime >= 0) 118 if (maxTimeUntilExplosion >= 0) 75 119 { 76 this->lifeTime_ = lifeTime; 77 this->explodeTimer.setTimer(this->lifeTime_, false, createExecutor(createFunctor(&MineProjectile::Explode, this))); 120 this->maxTimeUntilExplosion_ = maxTimeUntilExplosion; 121 if (GameMode::isMaster()) 122 { 123 this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::Explode, this))); 124 } 78 125 } 79 126 else 80 127 { 81 this-> lifeTime_ = 0;128 this->maxTimeUntilExplosion_ = 0; 82 129 } 83 130 } 84 131 132 /** 133 @brief 134 TODO 135 */ 136 void MineProjectile::setTimeUntilActivation(float timeUntilActivation) 137 { 138 timeUntilActivation_ = timeUntilActivation; 139 140 if (GameMode::isMaster()) 141 { 142 this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::Activate, this))); 143 } 144 } 85 145 86 146 /** 87 147 @brief 88 This is the setter function for the damageReduction_ variable. The value of the variable is bounded between 0 and 1. 89 */ 90 91 92 /** 93 @brief 94 If this function is called the projectile Mines up into many child projectiles. The original projectiles does not get destroyed but it will never Mine up again. 148 TODO 95 149 */ 96 150 void MineProjectile::Explode() 97 151 { 98 orxout() << " Explode" << endl;152 orxout() << "MineProjectile::Explode" << endl; 99 153 100 154 this->destroyLater(); … … 102 156 103 157 } 158 159 /** 160 @brief 161 TODO 162 */ 163 void MineProjectile::Activate() 164 { 165 orxout() << "MineProjectile::Activate" << endl; 166 167 bActive_ = true; 168 } 104 169 } -
code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.h
r10836 r10889 28 28 29 29 /** 30 @file IceGunProjectile.h30 @file MineProjectile.h 31 31 @brief Definition of the MineProjectile class. 32 32 */ … … 36 36 37 37 #include "weapons/WeaponsPrereqs.h" 38 39 #include <string>40 38 #include "tools/Timer.h" 41 #include "Projectile.h" 39 #include "worldentities/MovableEntity.h" 40 #include "objects/collisionshapes/SphereCollisionShape.h" 41 #include "objects/triggers/DistanceTrigger.h" 42 #include "BasicProjectile.h" 42 43 43 44 namespace orxonox … … 46 47 /** 47 48 @brief 48 The MineProjectile is a projectile that may Mine up into many child projectiles. 49 @author 50 Fabien Vultier 49 TODO 51 50 @ingroup WeaponsProjectiles 52 51 */ 53 class _WeaponsExport MineProjectile : public Projectile52 class _WeaponsExport MineProjectile : public MovableEntity, public BasicProjectile 54 53 { 55 54 public: 56 55 MineProjectile(Context* context); 57 virtual ~MineProjectile() {}56 virtual ~MineProjectile(); 58 57 59 virtual void set LifeTime(float LifeTime);60 58 virtual void setMaxTimeUntilExplosion(float maxTimeUntilExplosion); 59 virtual void setTimeUntilActivation(float timeUntilActivation); 61 60 61 private: 62 bool bActive_; // The mine can only explode if it is active 63 float maxTimeUntilExplosion_; 64 float timeUntilActivation_; 65 Timer activationTimer_; 66 Timer explodeTimer_; 67 Model* modelCore_; 68 Model* modelRing1_; 69 Model* modelRing2_; 70 MovableEntity* rings_; 62 71 63 private: 64 float lifeTime_; 65 Timer explodeTimer; 72 WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile. 73 WeakPtr<DistanceTrigger> distanceTrigger_; 66 74 67 virtual void Explode(); 75 virtual void Activate(); 76 virtual void Explode(); 68 77 }; 69 78 } -
code/branches/particleEffectsHS15/src/modules/weapons/projectiles/Projectile.h
r10629 r10889 69 69 protected: 70 70 virtual void setCollisionShapeRadius(float radius); 71 float lifetime_; //!< The time the projectile exists. 71 72 72 73 private: 73 float lifetime_; //!< The time the projectile exists.74 74 Timer destroyTimer_; //!< Timer to destroy the projectile after its lifetime has run out. 75 WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile. 75 WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile. 76 76 }; 77 77 } -
code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.cc
r10836 r10889 51 51 RegisterObject(MineGun); 52 52 53 this->speed_ = 0.0f; 53 54 this->reloadTime_ = 1.0f; 54 55 this->damage_ = 0.0f; 55 this->speed_ = 0.0f; 56 this->lifeTime_ = 7500.0f; 56 this->maxTimeUntilExplosion_ = 0.0f; 57 57 58 58 this->setMunitionName("MineMunition"); … … 66 66 /** 67 67 @brief 68 XMLPort for the MineGun. You can define how often the projectiles Mine, how many childs should be created per Mine, the spread and the time between two Mines.68 XMLPort for the MineGun. 69 69 */ 70 70 void MineGun::XMLPort(Element& xmlelement, XMLPort::Mode mode) 71 71 { 72 72 SUPER(MineGun, XMLPort, xmlelement, mode); 73 XMLPortParam(MineGun, "Lifetime", setLifeTime, getLifeTime, xmlelement, mode); 73 74 XMLPortParam(MineGun, "maxtimeuntilexplosion", setMaxTimeUntilExplosion, getMaxTimeUntilExplosion, xmlelement, mode).defaultValues(10.0f); 75 XMLPortParam(MineGun, "timeuntilactivation", setTimeUntilActivation, getTimeUntilActivation, xmlelement, mode).defaultValues(3.0f); 74 76 } 75 77 … … 81 83 { 82 84 MineProjectile* projectile = new MineProjectile(this->getContext()); 83 //projectile->setMaterial("Flares/energyflare");84 85 85 86 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); … … 88 89 projectile->setVelocity(this->getMuzzleDirection() * this->speed_); 89 90 90 // Pass important information to the projectile: Number of Mines, Number of childs, Mine time, spread and the damage reduction 91 /*projectile->setNumberOfMines(getNumberOfMines()); 92 projectile->setNumberOfChilds(getNumberOfChilds());*/ 93 projectile->setLifeTime(getLifeTime()); 94 /*projectile->setSpread(getSpread()); 95 projectile->setDamageReduction(getDamageReduction());*/ 91 projectile->setMaxTimeUntilExplosion(getMaxTimeUntilExplosion()); 92 projectile->setTimeUntilActivation(getTimeUntilActivation()); 96 93 97 94 projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); -
code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.h
r10836 r10889 44 44 @brief 45 45 A Mine that explodes when a ship is too close 46 @author47 Fabien Vultier48 46 @ingroup WeaponsWeaponModes 49 47 */ … … 56 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 57 55 virtual void fire(); 58 inline void setLifeTime(float lifeTime)59 { this->lifeTime_ = lifeTime; }60 inline float getLifeTime() const61 { return this->lifeTime_; }62 56 63 private: 57 inline float getMaxTimeUntilExplosion() const 58 { return this->maxTimeUntilExplosion_; } 59 inline float getTimeUntilActivation() const 60 { return this->timeUntilActivation_; } 61 protected: 62 inline void setMaxTimeUntilExplosion(float maxTimeUntilExplosion) 63 { this->maxTimeUntilExplosion_ = maxTimeUntilExplosion; } 64 inline void setTimeUntilActivation(float timeUntilActivation) 65 { this->timeUntilActivation_ = timeUntilActivation; } 66 private: 64 67 float speed_; //The speed of the fired projectile. 65 float lifeTime_;66 68 float maxTimeUntilExplosion_; 69 float timeUntilActivation_; 67 70 }; 68 71 }
Note: See TracChangeset
for help on using the changeset viewer.