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" |
---|
33 | #include "objects/weaponsystem/projectiles/ParticleProjectile.h" |
---|
34 | #include "objects/worldentities/Model.h" |
---|
35 | #include "objects/weaponsystem/MuzzleFlash.h" |
---|
36 | |
---|
37 | #include "objects/weaponsystem/Weapon.h" |
---|
38 | #include "objects/weaponsystem/WeaponPack.h" |
---|
39 | #include "objects/weaponsystem/WeaponSystem.h" |
---|
40 | |
---|
41 | namespace orxonox |
---|
42 | { |
---|
43 | CreateFactory(EnergyDrink); |
---|
44 | |
---|
45 | EnergyDrink::EnergyDrink(BaseObject* creator) : WeaponMode(creator) |
---|
46 | { |
---|
47 | RegisterObject(EnergyDrink); |
---|
48 | |
---|
49 | this->reloadTime_ = 0.25; |
---|
50 | this->damage_ = 15; |
---|
51 | this->speed_ = 2500; |
---|
52 | this->delay_ = 0; |
---|
53 | this->setMunitionName("FusionMunition"); |
---|
54 | |
---|
55 | this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&EnergyDrink::shot))); |
---|
56 | this->delayTimer_.stopTimer(); |
---|
57 | } |
---|
58 | |
---|
59 | void EnergyDrink::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
60 | { |
---|
61 | SUPER(EnergyDrink, XMLPort, xmlelement, mode); |
---|
62 | |
---|
63 | XMLPortParam(EnergyDrink, "delay", setDelay, getDelay, xmlelement, mode); |
---|
64 | XMLPortParam(EnergyDrink, "material", setMaterial, getMaterial, xmlelement, mode); |
---|
65 | |
---|
66 | } |
---|
67 | |
---|
68 | void EnergyDrink::setMaterial(const std::string& material) |
---|
69 | { |
---|
70 | this->material_ = material; |
---|
71 | } |
---|
72 | |
---|
73 | std::string& EnergyDrink::getMaterial() |
---|
74 | { |
---|
75 | return this->material_; |
---|
76 | } |
---|
77 | |
---|
78 | void EnergyDrink::setDelay(float d) |
---|
79 | { |
---|
80 | this->delay_ = d; |
---|
81 | this->delayTimer_.setInterval(this->delay_); |
---|
82 | } |
---|
83 | |
---|
84 | float EnergyDrink::getDelay() const |
---|
85 | { |
---|
86 | return this->delay_; |
---|
87 | } |
---|
88 | |
---|
89 | void EnergyDrink::fire() |
---|
90 | { |
---|
91 | this->delayTimer_.startTimer(); |
---|
92 | } |
---|
93 | |
---|
94 | void EnergyDrink::muendungsfeuer() |
---|
95 | { |
---|
96 | MuzzleFlash *muzzleFlash = new MuzzleFlash(this); |
---|
97 | this->getWeapon()->attach(muzzleFlash); |
---|
98 | muzzleFlash->setPosition(this->getMuzzleOffset()); |
---|
99 | muzzleFlash->setMaterial(this->material_); |
---|
100 | } |
---|
101 | |
---|
102 | void EnergyDrink::shot() |
---|
103 | { |
---|
104 | Projectile* projectile = new Projectile(this); |
---|
105 | Model* model = new Model(projectile); |
---|
106 | model->setMeshSource("can.mesh"); |
---|
107 | model->setCastShadows(false); |
---|
108 | projectile->attach(model); |
---|
109 | model->setScale(5); |
---|
110 | |
---|
111 | projectile->setOrientation(this->getMuzzleOrientation()); |
---|
112 | projectile->setPosition(this->getMuzzlePosition()); |
---|
113 | projectile->setVelocity(this->getMuzzleDirection() * this->speed_); |
---|
114 | |
---|
115 | projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); |
---|
116 | projectile->setDamage(this->getDamage()); |
---|
117 | |
---|
118 | EnergyDrink::muendungsfeuer(); |
---|
119 | } |
---|
120 | } |
---|