Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Merge_HS18/src/modules/towerdefense/TowerDefenseSelecter.cc @ 12180

Last change on this file since 12180 was 12180, checked in by merholzl, 5 years ago

World Map merging

  • Property svn:eol-style set to native
File size: 4.6 KB
Line 
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
39namespace 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;
52        boostPressed_ = false;
53        buildTower_ = false;
54        setSelectedPosition(0,0);     
55    }
56
57    TowerDefenseSelecter::~TowerDefenseSelecter()
58    {
59
60    }
61
62    void TowerDefenseSelecter::tick(float dt)
63    {
64        SUPER(TowerDefenseSelecter, tick, dt);
65
66        time_ += dt;
67
68        if (hasLocalController() && time_ >= 0.25)
69        {   
70            time_ = 0;
71
72            int selecterPosX = selectedPos_->GetX();
73            int selecterPosY = selectedPos_->GetY();
74
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;
84                selectedPos_->Set(selecterPosX, selecterPosY - 1);
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;
96                selectedPos_->Set(selecterPosX + 1, selecterPosY);
97                updatePosition();
98            }
99            if (boostPressed_ == true)
100            {
101                boostPressed_ = false;
102                buildTower_ = true;
103            }
104        }         
105    }
106
107
108    void TowerDefenseSelecter::moveFrontBack(const Vector2& value)
109    {
110       
111        if (value.x > 0)
112        {
113            moveUpPressed_ = true;
114            moveDownPressed_ = false;
115        }
116        else
117        {
118            moveUpPressed_ = false;
119            moveDownPressed_ = true;
120        }
121    }
122
123    void TowerDefenseSelecter::moveRightLeft(const Vector2& value)
124    {
125        if (value.x > 0)
126        {
127            moveLeftPressed_ = false;
128            moveRightPressed_ = true;
129        }
130        else
131        {
132            moveLeftPressed_ = true;
133            moveRightPressed_ = false;
134        }
135    }
136
137    void TowerDefenseSelecter::rotateYaw(const Vector2& value)
138    {
139    }
140
141    void TowerDefenseSelecter::rotatePitch(const Vector2& value)
142    {
143    }
144
145    void TowerDefenseSelecter::rotateRoll(const Vector2& value)
146    {
147    }
148
149    void TowerDefenseSelecter::fire(unsigned int firemode)
150    {
151    }
152
153    void TowerDefenseSelecter::fired(unsigned int firemode)
154    {
155       
156    }
157
158    void TowerDefenseSelecter::boost(bool bBoost)
159    {
160        if (bBoost == true)
161        {
162            boostPressed_ = true;
163        }
164    }
165
166    void TowerDefenseSelecter::updatePosition()
167    {
168        setPosition(selectedPos_->get3dcoordinate());
169    }
170
171    void TowerDefenseSelecter::setSelectedPosition(TDCoordinate* newPos)
172    {
173        selectedPos_ = newPos;
174        updatePosition();
175    }
176
177    void TowerDefenseSelecter::setSelectedPosition(int x,  int y)
178    {
179        setSelectedPosition(new TDCoordinate(x,y));
180    }
181}
Note: See TracBrowser for help on using the repository browser.