[10394] | 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 "graphics/Model.h" |
---|
| 38 | |
---|
| 39 | namespace orxonox |
---|
| 40 | { |
---|
| 41 | RegisterClass(TowerDefenseSelecter); |
---|
| 42 | |
---|
| 43 | TowerDefenseSelecter::TowerDefenseSelecter(Context* context) : ControllableEntity(context) |
---|
| 44 | { |
---|
| 45 | RegisterObject(TowerDefenseSelecter); |
---|
| 46 | |
---|
| 47 | // initialize variables |
---|
| 48 | moveUpPressed_ = false; |
---|
| 49 | moveDownPressed_ = false; |
---|
| 50 | moveLeftPressed_ = false; |
---|
| 51 | moveRightPressed_ = false; |
---|
[10629] | 52 | boostPressed_ = false; |
---|
| 53 | buildTower_ = false; |
---|
| 54 | setSelectedPosition(0,0); |
---|
[10394] | 55 | } |
---|
| 56 | |
---|
| 57 | TowerDefenseSelecter::~TowerDefenseSelecter() |
---|
| 58 | { |
---|
| 59 | |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | void TowerDefenseSelecter::tick(float dt) |
---|
| 63 | { |
---|
| 64 | SUPER(TowerDefenseSelecter, tick, dt); |
---|
| 65 | |
---|
[10629] | 66 | time_ += dt; |
---|
[10408] | 67 | |
---|
[10629] | 68 | if (hasLocalController() && time_ >= 0.25) |
---|
| 69 | { |
---|
| 70 | time_ = 0; |
---|
[10394] | 71 | |
---|
[10629] | 72 | int selecterPosX = selectedPos_->GetX(); |
---|
| 73 | int selecterPosY = selectedPos_->GetY(); |
---|
[10394] | 74 | |
---|
[10629] | 75 | if (moveUpPressed_ == true) |
---|
| 76 | { |
---|
| 77 | moveUpPressed_ = false; |
---|
| 78 | selectedPos_->Set(selecterPosX, selecterPosY + 1); |
---|
| 79 | updatePosition(); |
---|
| 80 | } |
---|
| 81 | if (moveDownPressed_ == true) |
---|
| 82 | { |
---|
| 83 | moveDownPressed_ = false; |
---|
[11052] | 84 | selectedPos_->Set(selecterPosX, selecterPosY - 1); |
---|
[10629] | 85 | updatePosition(); |
---|
| 86 | } |
---|
| 87 | if (moveLeftPressed_ == true) |
---|
| 88 | { |
---|
| 89 | moveLeftPressed_ = false; |
---|
| 90 | selectedPos_->Set(selecterPosX - 1, selecterPosY); |
---|
| 91 | updatePosition(); |
---|
| 92 | } |
---|
| 93 | if (moveRightPressed_ == true) |
---|
| 94 | { |
---|
| 95 | moveRightPressed_ = false; |
---|
[11052] | 96 | selectedPos_->Set(selecterPosX + 1, selecterPosY); |
---|
[10629] | 97 | updatePosition(); |
---|
| 98 | } |
---|
| 99 | if (boostPressed_ == true) |
---|
| 100 | { |
---|
| 101 | boostPressed_ = false; |
---|
| 102 | buildTower_ = true; |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | } |
---|
[10394] | 106 | |
---|
[10408] | 107 | |
---|
[10394] | 108 | void TowerDefenseSelecter::moveFrontBack(const Vector2& value) |
---|
| 109 | { |
---|
| 110 | if (value.x > 0) |
---|
| 111 | { |
---|
| 112 | moveUpPressed_ = true; |
---|
| 113 | moveDownPressed_ = false; |
---|
| 114 | } |
---|
| 115 | else |
---|
| 116 | { |
---|
| 117 | moveUpPressed_ = false; |
---|
| 118 | moveDownPressed_ = true; |
---|
| 119 | } |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | void TowerDefenseSelecter::moveRightLeft(const Vector2& value) |
---|
| 123 | { |
---|
| 124 | if (value.x > 0) |
---|
| 125 | { |
---|
| 126 | moveLeftPressed_ = false; |
---|
| 127 | moveRightPressed_ = true; |
---|
| 128 | } |
---|
| 129 | else |
---|
| 130 | { |
---|
| 131 | moveLeftPressed_ = true; |
---|
| 132 | moveRightPressed_ = false; |
---|
| 133 | } |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | void TowerDefenseSelecter::rotateYaw(const Vector2& value) |
---|
| 137 | { |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | void TowerDefenseSelecter::rotatePitch(const Vector2& value) |
---|
| 141 | { |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | void TowerDefenseSelecter::rotateRoll(const Vector2& value) |
---|
| 145 | { |
---|
| 146 | } |
---|
| 147 | |
---|
[10629] | 148 | void TowerDefenseSelecter::fire(unsigned int firemode) |
---|
| 149 | { |
---|
| 150 | } |
---|
[10394] | 151 | |
---|
[10629] | 152 | void TowerDefenseSelecter::fired(unsigned int firemode) |
---|
| 153 | { |
---|
| 154 | |
---|
| 155 | } |
---|
| 156 | |
---|
[10408] | 157 | void TowerDefenseSelecter::boost(bool bBoost) |
---|
[10394] | 158 | { |
---|
[10629] | 159 | if (bBoost == true) |
---|
| 160 | { |
---|
| 161 | boostPressed_ = true; |
---|
| 162 | } |
---|
[10394] | 163 | } |
---|
[10406] | 164 | |
---|
| 165 | void TowerDefenseSelecter::updatePosition() |
---|
| 166 | { |
---|
| 167 | setPosition(selectedPos_->get3dcoordinate()); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | void TowerDefenseSelecter::setSelectedPosition(TDCoordinate* newPos) |
---|
| 171 | { |
---|
| 172 | selectedPos_ = newPos; |
---|
| 173 | updatePosition(); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | void TowerDefenseSelecter::setSelectedPosition(int x, int y) |
---|
| 177 | { |
---|
| 178 | setSelectedPosition(new TDCoordinate(x,y)); |
---|
| 179 | } |
---|
[10394] | 180 | } |
---|