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 TowerDefenseSelecter.cc |
---|
31 | @brief This class represents your figure when you play the minigame. Here the movement of the figure, activating items, ... are handled. |
---|
32 | */ |
---|
33 | |
---|
34 | #include "TowerDefenseSelecter.h" |
---|
35 | |
---|
36 | #include "core/CoreIncludes.h" |
---|
37 | #include "core/XMLPort.h" |
---|
38 | #include "graphics/Model.h" |
---|
39 | |
---|
40 | namespace orxonox |
---|
41 | { |
---|
42 | RegisterClass(TowerDefenseSelecter); |
---|
43 | |
---|
44 | TowerDefenseSelecter::TowerDefenseSelecter(Context* context) : ControllableEntity(context) |
---|
45 | { |
---|
46 | RegisterObject(TowerDefenseSelecter); |
---|
47 | |
---|
48 | // initialize variables |
---|
49 | moveUpPressed_ = false; |
---|
50 | moveDownPressed_ = false; |
---|
51 | moveLeftPressed_ = false; |
---|
52 | moveRightPressed_ = false; |
---|
53 | selectedPos_ = new TDCoordinate(0,0); |
---|
54 | |
---|
55 | Model* selecterModel = new Model(context); |
---|
56 | selecterModel->setMeshSource("cube.mesh"); |
---|
57 | selecterModel->setScale(45); |
---|
58 | |
---|
59 | } |
---|
60 | |
---|
61 | TowerDefenseSelecter::~TowerDefenseSelecter() |
---|
62 | { |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | void TowerDefenseSelecter::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
67 | { |
---|
68 | SUPER(TowerDefenseSelecter, XMLPort, xmlelement, mode); |
---|
69 | // Beispielport // XMLPortParam(TowerDefenseSelecter, "mouseFactor", setMouseFactor, getMouseFactor, xmlelement, mode); |
---|
70 | |
---|
71 | } |
---|
72 | |
---|
73 | void TowerDefenseSelecter::tick(float dt) |
---|
74 | { |
---|
75 | SUPER(TowerDefenseSelecter, tick, dt); |
---|
76 | |
---|
77 | if (hasLocalController()) |
---|
78 | { |
---|
79 | |
---|
80 | if (moveUpPressed_ == true) |
---|
81 | { |
---|
82 | if(this->selectedPos_->y >= 15) |
---|
83 | { |
---|
84 | } |
---|
85 | else |
---|
86 | { |
---|
87 | this->selectedPos_->y +=1; |
---|
88 | this->setPosition(selectedPos_->get3dcoordinate()); |
---|
89 | } |
---|
90 | |
---|
91 | } |
---|
92 | if (moveDownPressed_ == true) |
---|
93 | { |
---|
94 | if(this->selectedPos_->y <= 0) |
---|
95 | { |
---|
96 | } |
---|
97 | else |
---|
98 | { |
---|
99 | this->selectedPos_->y -= 1; |
---|
100 | this->setPosition(selectedPos_->get3dcoordinate()); |
---|
101 | } |
---|
102 | |
---|
103 | moveDownPressed_ = false; |
---|
104 | } |
---|
105 | |
---|
106 | if (moveLeftPressed_ == true) |
---|
107 | { |
---|
108 | if(this->selectedPos_->x <= 0) |
---|
109 | { |
---|
110 | } |
---|
111 | else |
---|
112 | { |
---|
113 | this->selectedPos_->x -=1; |
---|
114 | this->setPosition(selectedPos_->get3dcoordinate()); |
---|
115 | } |
---|
116 | |
---|
117 | } |
---|
118 | if (moveRightPressed_ == true) |
---|
119 | { |
---|
120 | if(this->selectedPos_->x >= 15) |
---|
121 | { |
---|
122 | } |
---|
123 | else |
---|
124 | { |
---|
125 | this->selectedPos_->x += 1; |
---|
126 | this->setPosition(selectedPos_->get3dcoordinate()); |
---|
127 | } |
---|
128 | |
---|
129 | moveDownPressed_ = false; |
---|
130 | } |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | /* |
---|
135 | if (firePressed_ && timeSinceLastFire_ >= maxFireRate_) |
---|
136 | { |
---|
137 | firePressed_ = false; |
---|
138 | timeSinceLastFire_ = 0.0; |
---|
139 | fireSignal_ = true; |
---|
140 | } |
---|
141 | */ |
---|
142 | } |
---|
143 | |
---|
144 | // Reset key variables |
---|
145 | moveUpPressed_ = false; |
---|
146 | moveDownPressed_ = false; |
---|
147 | moveLeftPressed_ = false; |
---|
148 | moveDownPressed_ = false; |
---|
149 | //firePressed_ = false; |
---|
150 | } |
---|
151 | |
---|
152 | |
---|
153 | void TowerDefenseSelecter::moveFrontBack(const Vector2& value) |
---|
154 | { |
---|
155 | if (value.x > 0) |
---|
156 | { |
---|
157 | moveUpPressed_ = true; |
---|
158 | moveDownPressed_ = false; |
---|
159 | } |
---|
160 | else |
---|
161 | { |
---|
162 | moveUpPressed_ = false; |
---|
163 | moveDownPressed_ = true; |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | void TowerDefenseSelecter::moveRightLeft(const Vector2& value) |
---|
168 | { |
---|
169 | if (value.x > 0) |
---|
170 | { |
---|
171 | moveLeftPressed_ = false; |
---|
172 | moveRightPressed_ = true; |
---|
173 | } |
---|
174 | else |
---|
175 | { |
---|
176 | moveLeftPressed_ = true; |
---|
177 | moveRightPressed_ = false; |
---|
178 | } |
---|
179 | } |
---|
180 | |
---|
181 | void TowerDefenseSelecter::rotateYaw(const Vector2& value) |
---|
182 | { |
---|
183 | } |
---|
184 | |
---|
185 | void TowerDefenseSelecter::rotatePitch(const Vector2& value) |
---|
186 | { |
---|
187 | } |
---|
188 | |
---|
189 | void TowerDefenseSelecter::rotateRoll(const Vector2& value) |
---|
190 | { |
---|
191 | } |
---|
192 | |
---|
193 | void TowerDefenseSelecter::fire(unsigned int firemode) |
---|
194 | { |
---|
195 | } |
---|
196 | |
---|
197 | void TowerDefenseSelecter::fired(unsigned int firemode) |
---|
198 | { |
---|
199 | //firePressed_ = true; |
---|
200 | } |
---|
201 | } |
---|