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 | * Fabien Vultier |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | @file MineProjectile.h |
---|
31 | @brief Implementation of the MineProjectile class. |
---|
32 | */ |
---|
33 | |
---|
34 | #include "MineProjectile.h" |
---|
35 | |
---|
36 | #include "core/CoreIncludes.h" |
---|
37 | #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 | |
---|
48 | namespace orxonox |
---|
49 | { |
---|
50 | RegisterClass(MineProjectile); |
---|
51 | |
---|
52 | MineProjectile::MineProjectile(Context* context) : Projectile(context) |
---|
53 | { |
---|
54 | RegisterObject(MineProjectile); |
---|
55 | |
---|
56 | this->lifeTime_ = 1.0f; |
---|
57 | |
---|
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)); |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | /** |
---|
67 | @brief |
---|
68 | This function starts a timer that will cause the projectile to Mine after a time defined by the argument @param LifeTime. |
---|
69 | */ |
---|
70 | void MineProjectile::setLifeTime(float lifeTime) |
---|
71 | { |
---|
72 | orxout() << lifeTime << endl; |
---|
73 | |
---|
74 | if (lifeTime >= 0) |
---|
75 | { |
---|
76 | this->lifeTime_ = lifeTime; |
---|
77 | this->explodeTimer.setTimer(this->lifeTime_, false, createExecutor(createFunctor(&MineProjectile::Explode, this))); |
---|
78 | } |
---|
79 | else |
---|
80 | { |
---|
81 | this->lifeTime_ = 0; |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | /** |
---|
87 | @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. |
---|
95 | */ |
---|
96 | void MineProjectile::Explode() |
---|
97 | { |
---|
98 | orxout() << "Explode" << endl; |
---|
99 | |
---|
100 | this->destroyLater(); |
---|
101 | |
---|
102 | |
---|
103 | } |
---|
104 | } |
---|