[Orxonox-commit 5947] r10606 - in code/branches/towerdefenseFabien: data/levels src/modules/towerdefense src/modules/weapons src/modules/weapons/projectiles src/modules/weapons/weaponmodes
fvultier at orxonox.net
fvultier at orxonox.net
Fri Oct 2 22:46:40 CEST 2015
Author: fvultier
Date: 2015-10-02 22:46:40 +0200 (Fri, 02 Oct 2015)
New Revision: 10606
Added:
code/branches/towerdefenseFabien/src/modules/weapons/IceGunFreezer.cc
code/branches/towerdefenseFabien/src/modules/weapons/IceGunFreezer.h
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/IceGunProjectile.cc
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/IceGunProjectile.h
code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.cc
code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.h
Modified:
code/branches/towerdefenseFabien/data/levels/towerDefense.oxw
code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.h
code/branches/towerdefenseFabien/src/modules/weapons/CMakeLists.txt
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/CMakeLists.txt
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/Projectile.cc
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/Projectile.h
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h
code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/CMakeLists.txt
code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc
code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h
Log:
The most expensive tower fires now a new weapon: The Ice gun; a weapon that slows down a hit SpaceShip. This weapon may be used outside the tower defense minigame.
Modified: code/branches/towerdefenseFabien/data/levels/towerDefense.oxw
===================================================================
--- code/branches/towerdefenseFabien/data/levels/towerDefense.oxw 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/data/levels/towerDefense.oxw 2015-10-02 20:46:40 UTC (rev 10606)
@@ -219,7 +219,7 @@
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
</links>
<Weapon>
- <<HsW01 mode=0 munitionpershot=0 delay=0.125 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0,0,0" projectileMesh="LaserBeam2.mesh" />
+ <IceGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0,0,0" freezefactor=0.5 freezetime=2.0 />
</Weapon>
</WeaponPack>
</weapons>
Modified: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.h 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefenseEnemy.h 2015-10-02 20:46:40 UTC (rev 10606)
@@ -21,7 +21,6 @@
#include "towerdefense/TowerDefensePrereqs.h"
#include "worldentities/pawns/SpaceShip.h"
#include "util/Output.h"
-#include "controllers/ArtificialController.h"
#include "TowerDefense.h"
namespace orxonox
Modified: code/branches/towerdefenseFabien/src/modules/weapons/CMakeLists.txt
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/CMakeLists.txt 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/weapons/CMakeLists.txt 2015-10-02 20:46:40 UTC (rev 10606)
@@ -1,6 +1,7 @@
SET_SOURCE_FILES(WEAPONS_SRC_FILES
MuzzleFlash.cc
RocketController.cc
+ IceGunFreezer.cc
)
ADD_SUBDIRECTORY(munitions)
Added: code/branches/towerdefenseFabien/src/modules/weapons/IceGunFreezer.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/IceGunFreezer.cc (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/IceGunFreezer.cc 2015-10-02 20:46:40 UTC (rev 10606)
@@ -0,0 +1,117 @@
+/*
+* ORXONOX - the hottest 3D action shooter ever to exist
+* > www.orxonox.net <
+*
+*
+* License notice:
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* Author:
+* Fabien Vultier
+* Co-authors:
+* ...
+*
+*/
+
+/**
+ @file IceGunFreezer.h
+ @brief Implementation of the IceGunFreezer class.
+*/
+
+#include "core/CoreIncludes.h"
+#include "core/command/Executor.h"
+
+#include "IceGunFreezer.h"
+
+namespace orxonox
+{
+ RegisterClass(IceGunFreezer);
+
+ /**
+ @brief
+ Constructor.
+ */
+ IceGunFreezer::IceGunFreezer(Context* context) : StaticEntity(context)
+ {
+ RegisterObject(IceGunFreezer);
+
+ model = new Model(this->getContext());
+ model->setMeshSource("IceStar.mesh");
+ model->setScale(4.0);
+ this->attach(model);
+ model->setPosition(Vector3(0,0,0));
+ }
+
+ IceGunFreezer::~IceGunFreezer()
+ {
+
+ }
+
+ /**
+ @brief
+ The controlling happens here. This method defines what the controller has to do each tick.
+ @param dt
+ The duration of the tick.
+ */
+ void IceGunFreezer::tick(float dt)
+ {
+ SUPER(IceGunFreezer, tick, dt);
+
+
+ }
+
+ /**
+ @brief
+ Sets the freeze time variable to the passed value.
+ */
+ void IceGunFreezer::setFreezeTime(float freezeTime)
+ {
+ freezeTime_ = freezeTime;
+ }
+
+ /**
+ @brief
+ Sets the freeze factor variable to the passed value.
+ */
+ void IceGunFreezer::setFreezeFactor(float freezeFactor)
+ {
+ freezeFactor_ = freezeFactor;
+ }
+
+ void IceGunFreezer::startFreezing()
+ {
+ WorldEntity* parent = this->getParent();
+
+ if (parent != NULL && parent->isA(Class(SpaceShip)))
+ {
+ freezedSpaceShip_ = orxonox_cast<SpaceShip*>(parent);
+ freezedSpaceShip_->addSpeedFactor(freezeFactor_);
+ }
+
+ // Start timer even if the victim is not a SpaceShip to avoid that the IceGunFreezer gets never destroyed if it collided against a Pawn
+ this->freezeTimer_.setTimer(this->freezeTime_, false, createExecutor(createFunctor(&IceGunFreezer::stopFreezing, this)));
+ }
+
+ void IceGunFreezer::stopFreezing()
+ {
+ if (freezedSpaceShip_ != NULL && freezeFactor_ != 0.0)
+ {
+ freezedSpaceShip_->addSpeedFactor(1/freezeFactor_);
+ }
+
+ this->destroy();
+ }
+}
Added: code/branches/towerdefenseFabien/src/modules/weapons/IceGunFreezer.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/IceGunFreezer.h (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/IceGunFreezer.h 2015-10-02 20:46:40 UTC (rev 10606)
@@ -0,0 +1,71 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file IceGunFreezer.h
+ @brief Definition of the IceGunFreezer class.
+*/
+
+#ifndef _IceGunFreezer_H__
+#define _IceGunFreezer_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "worldentities/StaticEntity.h"
+#include "graphics/Model.h"
+#include "tools/Timer.h"
+#include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ blablabla
+ @ingroup Weapons
+ */
+ class _WeaponsExport IceGunFreezer : public StaticEntity, public Tickable
+ {
+ public:
+ IceGunFreezer(Context* context);
+ virtual ~IceGunFreezer();
+ virtual void tick(float dt);
+ virtual void startFreezing();
+ virtual void stopFreezing();
+ virtual void setFreezeTime(float freezeTime);
+ virtual void setFreezeFactor(float freezeFactor);
+ private:
+ float freezeTime_; //The duration of the freezing effect on a target
+ float freezeFactor_; //The strength of the freezing effect
+ Model* model;
+ Timer freezeTimer_;
+ WeakPtr<SpaceShip> freezedSpaceShip_;
+ };
+}
+
+#endif /* _IceGunFreezer_H__ */
Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/CMakeLists.txt 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/CMakeLists.txt 2015-10-02 20:46:40 UTC (rev 10606)
@@ -7,4 +7,5 @@
Rocket.cc
SimpleRocket.cc
SplitGunProjectile.cc
+ IceGunProjectile.cc
)
Added: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/IceGunProjectile.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/IceGunProjectile.cc (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/IceGunProjectile.cc 2015-10-02 20:46:40 UTC (rev 10606)
@@ -0,0 +1,96 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file IceGunProjectile.cc
+ @brief Implementation of the IceGunProjectile class.
+*/
+
+#include "IceGunProjectile.h"
+
+#include "core/CoreIncludes.h"
+#include "graphics/Model.h"
+
+namespace orxonox
+{
+ RegisterClass(IceGunProjectile);
+
+ IceGunProjectile::IceGunProjectile(Context* context) : Projectile(context)
+ {
+ RegisterObject(IceGunProjectile);
+
+ this->setCollisionShapeRadius(8.0f);
+
+ this->setFreezeTime(3.0);
+ this->setFreezeFactor(0.5);
+
+ Model* model = new Model(this->getContext());
+ model->setMeshSource("IceBolt.mesh");
+ model->setScale(15.0);
+ this->attach(model);
+ model->setPosition(Vector3(0,0,0));
+ }
+
+ /**
+ @brief
+ Sets the freeze time variable to the passed value.
+ */
+ void IceGunProjectile::setFreezeTime(float freezeTime)
+ {
+ freezeTime_ = freezeTime;
+ }
+
+ /**
+ @brief
+ Sets the freeze factor variable to the passed value.
+ */
+ void IceGunProjectile::setFreezeFactor(float freezeFactor)
+ {
+ freezeFactor_ = freezeFactor;
+ }
+
+ bool IceGunProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
+ {
+ bool bCollision = Projectile::collidesAgainst(otherObject, cs, contactPoint);
+
+ if (bCollision)
+ {
+ IceGunFreezer* freezer = new IceGunFreezer(this->getContext());
+ freezer->setFreezeTime(freezeTime_);
+ freezer->setFreezeFactor(freezeFactor_);
+ otherObject->attach(freezer);
+
+ Vector3 offset = this->getWorldPosition() - otherObject->getWorldPosition();
+ freezer->setPosition(Vector3(0,0,0));
+ freezer->translate(offset, WorldEntity::World);
+ freezer->startFreezing();
+ }
+
+ return bCollision;
+ }
+}
Added: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/IceGunProjectile.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/IceGunProjectile.h (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/IceGunProjectile.h 2015-10-02 20:46:40 UTC (rev 10606)
@@ -0,0 +1,71 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file IceGunProjectile.h
+ @brief Definition of the IceGunProjectile class.
+*/
+
+#ifndef _IceGunProjectile_H__
+#define _IceGunProjectile_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include <string>
+#include "tools/Timer.h"
+#include "BillboardProjectile.h"
+#include "weapons/IceGunFreezer.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The IceGunProjectile is a projectile that may split up into many child projectiles.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsProjectiles
+ */
+ class _WeaponsExport IceGunProjectile : public Projectile
+ {
+ public:
+ IceGunProjectile(Context* context);
+ virtual ~IceGunProjectile() {}
+
+ virtual void setFreezeTime(float freezeTime);
+ virtual void setFreezeFactor(float freezeFactor);
+
+ protected:
+ virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
+ private:
+ float freezeTime_; //The duration of the freezing effect on a target
+ float freezeFactor_; //The strength of the freezing effect
+ };
+}
+
+#endif /* _IceGunProjectile_H__ */
Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/Projectile.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/Projectile.cc 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/Projectile.cc 2015-10-02 20:46:40 UTC (rev 10606)
@@ -38,7 +38,6 @@
#include "core/GameMode.h"
#include "core/command/Executor.h"
-#include "objects/collisionshapes/SphereCollisionShape.h"
#include "worldentities/pawns/Pawn.h"
namespace orxonox
@@ -59,9 +58,10 @@
this->setCollisionResponse(false);
this->setCollisionType(Dynamic);
- SphereCollisionShape* shape = new SphereCollisionShape(this->getContext());
- shape->setRadius(20.0f);
- this->attachCollisionShape(shape);
+ // Create a sphere collision shape and attach it to the projectile.
+ collisionShape_ = new SphereCollisionShape(this->getContext());
+ setCollisionShapeRadius(20.0f);
+ this->attachCollisionShape(collisionShape_);
this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this)));
}
@@ -76,7 +76,6 @@
SetConfigValue(lifetime_, 4.0f).description("The time in seconds a projectile stays alive");
}
-
void Projectile::tick(float dt)
{
SUPER(Projectile, tick, dt);
@@ -92,4 +91,11 @@
return this->processCollision(otherObject, contactPoint, cs);
}
+ void Projectile::setCollisionShapeRadius(float radius)
+ {
+ if (collisionShape_ != NULL && radius > 0)
+ {
+ collisionShape_->setRadius(radius);
+ }
+ }
}
Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/Projectile.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/Projectile.h 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/Projectile.h 2015-10-02 20:46:40 UTC (rev 10606)
@@ -38,6 +38,7 @@
#include "tools/Timer.h"
#include "worldentities/MovableEntity.h"
+#include "objects/collisionshapes/SphereCollisionShape.h"
#include "BasicProjectile.h"
@@ -65,9 +66,13 @@
virtual void tick(float dt);
virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
+ protected:
+ virtual void setCollisionShapeRadius(float radius);
+
private:
float lifetime_; //!< The time the projectile exists.
Timer destroyTimer_; //!< Timer to destroy the projectile after its lifetime has run out.
+ WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
};
}
Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc 2015-10-02 20:46:40 UTC (rev 10606)
@@ -85,7 +85,7 @@
if (splitTime >= 0)
{
this->splitTime_ = splitTime;
- this->textureTimer_.setTimer(this->splitTime_, false, createExecutor(createFunctor(&SplitGunProjectile::split, this)));
+ this->splitTimer_.setTimer(this->splitTime_, false, createExecutor(createFunctor(&SplitGunProjectile::split, this)));
}
else
{
Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h 2015-10-02 20:46:40 UTC (rev 10606)
@@ -27,7 +27,7 @@
*/
/**
- @file SplitGunProjectile.h
+ @file IceGunProjectile.h
@brief Definition of the SplitGunProjectile class.
*/
@@ -66,7 +66,7 @@
int numberOfChilds_;
float splitTime_;
float spread_;
- Timer textureTimer_;
+ Timer splitTimer_;
virtual void split();
};
Modified: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/CMakeLists.txt
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/CMakeLists.txt 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/CMakeLists.txt 2015-10-02 20:46:40 UTC (rev 10606)
@@ -5,6 +5,7 @@
HsW01.cc
LightningGun.cc
SplitGun.cc
+ IceGun.cc
RocketFire.cc
SimpleRocketFire.cc
)
Added: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.cc (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.cc 2015-10-02 20:46:40 UTC (rev 10606)
@@ -0,0 +1,103 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file IceGun.cc
+ @brief Implementation of the IceGun class.
+*/
+
+#include "IceGun.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/IceGunProjectile.h"
+
+namespace orxonox
+{
+ RegisterClass(IceGun);
+
+ IceGun::IceGun(Context* context) : WeaponMode(context)
+ {
+ RegisterObject(IceGun);
+
+ this->reloadTime_ = 1.0f;
+ this->damage_ = 0.0f;
+ this->speed_ = 750.0f;
+
+
+ this->setFreezeTime(3.0);
+ this->setFreezeFactor(0.5);
+
+ this->setMunitionName("LaserMunition");
+ this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
+ }
+
+ IceGun::~IceGun()
+ {
+ }
+
+ /**
+ @brief
+ XMLPort for the IceGun. You can define how often the projectiles split, how many childs should be created per split, the spread and the time between two splits.
+ */
+ void IceGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(IceGun, XMLPort, xmlelement, mode);
+
+ XMLPortParam(IceGun, "freezetime", setFreezeTime, getFreezeTime, xmlelement, mode);
+ XMLPortParam(IceGun, "freezefactor", setFreezeFactor, getFreezeFactor, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Fires the weapon. Creates a projectile and fires it.
+ */
+ void IceGun::fire()
+ {
+ IceGunProjectile* projectile = new IceGunProjectile(this->getContext());
+
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+ // Pass important information to the projectile: Freeze time and freeze factor
+ projectile->setFreezeTime(getFreezeTime());
+ projectile->setFreezeFactor(getFreezeFactor());
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+ }
+}
Added: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.h (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/IceGun.h 2015-10-02 20:46:40 UTC (rev 10606)
@@ -0,0 +1,76 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file IceGun.h
+ @brief Definition of the IceGun class.
+*/
+
+#ifndef _IceGun_H__
+#define _IceGun_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ A slow ball of lightning.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsWeaponModes
+ */
+ class _WeaponsExport IceGun : public WeaponMode
+ {
+ public:
+ IceGun(Context* context);
+ virtual ~IceGun();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void fire();
+
+
+ inline void setFreezeTime(float freezeTime)
+ { this->freezeTime_ = freezeTime; }
+ inline float getFreezeTime() const
+ { return this->freezeTime_; }
+ inline void setFreezeFactor(float freezeFactor)
+ { this->freezeFactor_ = freezeFactor; }
+ inline float getFreezeFactor() const
+ { return this->freezeFactor_; }
+
+ private:
+ float speed_; //The speed of the fired projectile.
+ float freezeTime_; //The duration of the freezing effect on a target
+ float freezeFactor_; //The strength of the freezing effect
+ };
+}
+
+#endif /* _IceGun_H__ */
Modified: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc 2015-10-02 20:46:40 UTC (rev 10606)
@@ -27,7 +27,7 @@
*/
/**
- @file SplitGun.h
+ @file SplitGun.cc
@brief Implementation of the SplitGun class.
*/
Modified: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h 2015-09-27 20:39:57 UTC (rev 10605)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h 2015-10-02 20:46:40 UTC (rev 10606)
@@ -42,7 +42,7 @@
/**
@brief
- A slow ball of lightning.
+ A WeaponMode that fires projectiles that may split up into many other projectiles, that may again split up ...
@author
Fabien Vultier
@ingroup WeaponsWeaponModes
More information about the Orxonox-commit
mailing list