[3053] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Hagen Seifert |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "EnergyDrink.h" |
---|
| 30 | |
---|
| 31 | #include "core/CoreIncludes.h" |
---|
| 32 | #include "core/XMLPort.h" |
---|
[7284] | 33 | #include "core/command/Executor.h" |
---|
[5737] | 34 | #include "graphics/Model.h" |
---|
[3196] | 35 | |
---|
[5724] | 36 | #include "weapons/projectiles/Projectile.h" |
---|
| 37 | #include "weapons/MuzzleFlash.h" |
---|
[5735] | 38 | #include "weaponsystem/Weapon.h" |
---|
| 39 | #include "weaponsystem/WeaponPack.h" |
---|
| 40 | #include "weaponsystem/WeaponSystem.h" |
---|
[6732] | 41 | #include "worldentities/pawns/Pawn.h" |
---|
[3053] | 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | CreateFactory(EnergyDrink); |
---|
| 46 | |
---|
| 47 | EnergyDrink::EnergyDrink(BaseObject* creator) : WeaponMode(creator) |
---|
| 48 | { |
---|
| 49 | RegisterObject(EnergyDrink); |
---|
| 50 | |
---|
| 51 | this->reloadTime_ = 0.25; |
---|
| 52 | this->damage_ = 15; |
---|
| 53 | this->speed_ = 2500; |
---|
| 54 | this->delay_ = 0; |
---|
| 55 | this->setMunitionName("FusionMunition"); |
---|
| 56 | |
---|
[5929] | 57 | this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this))); |
---|
[3053] | 58 | this->delayTimer_.stopTimer(); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | void EnergyDrink::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 62 | { |
---|
| 63 | SUPER(EnergyDrink, XMLPort, xmlelement, mode); |
---|
| 64 | |
---|
| 65 | XMLPortParam(EnergyDrink, "delay", setDelay, getDelay, xmlelement, mode); |
---|
| 66 | XMLPortParam(EnergyDrink, "material", setMaterial, getMaterial, xmlelement, mode); |
---|
| 67 | |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | void EnergyDrink::setMaterial(const std::string& material) |
---|
| 71 | { |
---|
| 72 | this->material_ = material; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | void EnergyDrink::setDelay(float d) |
---|
| 76 | { |
---|
| 77 | this->delay_ = d; |
---|
| 78 | this->delayTimer_.setInterval(this->delay_); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | float EnergyDrink::getDelay() const |
---|
| 82 | { |
---|
| 83 | return this->delay_; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | void EnergyDrink::fire() |
---|
| 87 | { |
---|
| 88 | this->delayTimer_.startTimer(); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | void EnergyDrink::muendungsfeuer() |
---|
| 92 | { |
---|
| 93 | MuzzleFlash *muzzleFlash = new MuzzleFlash(this); |
---|
| 94 | this->getWeapon()->attach(muzzleFlash); |
---|
| 95 | muzzleFlash->setPosition(this->getMuzzleOffset()); |
---|
| 96 | muzzleFlash->setMaterial(this->material_); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | void EnergyDrink::shot() |
---|
| 100 | { |
---|
| 101 | Projectile* projectile = new Projectile(this); |
---|
| 102 | Model* model = new Model(projectile); |
---|
| 103 | model->setMeshSource("can.mesh"); |
---|
| 104 | model->setCastShadows(false); |
---|
| 105 | projectile->attach(model); |
---|
| 106 | model->setScale(5); |
---|
| 107 | |
---|
| 108 | projectile->setOrientation(this->getMuzzleOrientation()); |
---|
| 109 | projectile->setPosition(this->getMuzzlePosition()); |
---|
[6732] | 110 | projectile->setVelocity(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity() + this->getMuzzleDirection() * this->speed_); |
---|
[3053] | 111 | |
---|
| 112 | projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); |
---|
| 113 | projectile->setDamage(this->getDamage()); |
---|
| 114 | |
---|
| 115 | EnergyDrink::muendungsfeuer(); |
---|
| 116 | } |
---|
| 117 | } |
---|