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 | * ... |
---|
24 | * Co-authors: |
---|
25 | * ... |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | @file TixyTaxyTorxy |
---|
31 | TixyTaxyTorxyCenterpoint.cc |
---|
32 | @brief Implementation of the TixyTaxyTorxy |
---|
33 | TixyTaxyTorxyCenterpoint class. |
---|
34 | */ |
---|
35 | |
---|
36 | #include "TixyTaxyTorxyCenterpoint.h" |
---|
37 | |
---|
38 | #include "core/CoreIncludes.h" |
---|
39 | #include "core/XMLPort.h" |
---|
40 | #include "core/class/Super.h" |
---|
41 | |
---|
42 | #include "TixyTaxyTorxy.h" |
---|
43 | |
---|
44 | namespace orxonox |
---|
45 | { |
---|
46 | RegisterClass(TixyTaxyTorxyCenterpoint); |
---|
47 | |
---|
48 | /** |
---|
49 | @brief |
---|
50 | Constructor. Registers and initializes the object and checks whether the gametype is actually TixyTaxyTorxy |
---|
51 | TixyTaxyTorxy. |
---|
52 | */ |
---|
53 | |
---|
54 | TixyTaxyTorxyCenterpoint::TixyTaxyTorxyCenterpoint(Context* context) : MobileEntity(context) |
---|
55 | { |
---|
56 | RegisterObject(TixyTaxyTorxyCenterpoint); |
---|
57 | |
---|
58 | this->width_ = 10; |
---|
59 | this->height_ = 10; |
---|
60 | |
---|
61 | //this->setCollisionType(Static); |
---|
62 | |
---|
63 | this->checkGametype(); |
---|
64 | |
---|
65 | } |
---|
66 | |
---|
67 | /** |
---|
68 | @brief |
---|
69 | Method to create a TixyTaxyTorxy |
---|
70 | TixyTaxyTorxyCenterpoint through XML. |
---|
71 | */ |
---|
72 | void TixyTaxyTorxyCenterpoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
73 | { |
---|
74 | SUPER(TixyTaxyTorxyCenterpoint, XMLPort, xmlelement, mode); |
---|
75 | |
---|
76 | XMLPortParam(TixyTaxyTorxyCenterpoint, "width", setWidth, getWidth, xmlelement, mode); |
---|
77 | XMLPortParam(TixyTaxyTorxyCenterpoint, "height", setHeight, getHeight, xmlelement, mode); |
---|
78 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode); |
---|
79 | XMLPortParam(TixyTaxyTorxyCenterpoint, "selecterTemplate", setSelecterTemplate, getSelecterTemplate, xmlelement, mode); |
---|
80 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower1Template", setTower1Template, getTower1Template, xmlelement, mode); |
---|
81 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower2Template", setTower2Template, getTower2Template, xmlelement, mode); |
---|
82 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower3Template", setTower3Template, getTower3Template, xmlelement, mode); |
---|
83 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower4Template", setTower4Template, getTower4Template, xmlelement, mode); |
---|
84 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower5Template", setTower5Template, getTower5Template, xmlelement, mode); |
---|
85 | XMLPortParam(TixyTaxyTorxyCenterpoint, "fields", setFields, getFields, xmlelement, mode); |
---|
86 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower1Cost", setTower1Cost, getTower1Cost, xmlelement, mode); |
---|
87 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower2Cost", setTower2Cost, getTower2Cost, xmlelement, mode); |
---|
88 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower3Cost", setTower3Cost, getTower3Cost, xmlelement, mode); |
---|
89 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower4Cost", setTower4Cost, getTower4Cost, xmlelement, mode); |
---|
90 | XMLPortParam(TixyTaxyTorxyCenterpoint, "tower5Cost", setTower5Cost, getTower5Cost, xmlelement, mode); |
---|
91 | } |
---|
92 | |
---|
93 | /** |
---|
94 | @brief |
---|
95 | Checks whether the gametype is TixyTaxyTorxy |
---|
96 | TixyTaxyTorxy and if it is, sets its centerpoint. |
---|
97 | */ |
---|
98 | void TixyTaxyTorxyCenterpoint::checkGametype() |
---|
99 | { |
---|
100 | if (this->getGametype() != nullptr && this->getGametype()->isA(Class(TixyTaxyTorxy))) |
---|
101 | { |
---|
102 | // Sets the centerpoint of the gametype. The gametype uses this to later spawn in towers, he needs the tower template stored in the center point |
---|
103 | TixyTaxyTorxy* TixyTaxyTorxyGametype = orxonox_cast<TixyTaxyTorxy*>(this->getGametype()); |
---|
104 | TixyTaxyTorxyGametype->setCenterpoint(this); |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | /** |
---|
109 | @brief |
---|
110 | Removes all blanks, tabs and returns from the string passed. |
---|
111 | */ |
---|
112 | void TixyTaxyTorxyCenterpoint::trimString(std::string* str) |
---|
113 | { |
---|
114 | std::string* trimmed = new std::string(""); |
---|
115 | int length = str->size(); |
---|
116 | char temp; |
---|
117 | for (int i = 0; i < length; ++ i) |
---|
118 | { |
---|
119 | temp = str->at(i); |
---|
120 | if (temp != ' ' && temp != '\t' && temp != '\n') |
---|
121 | { |
---|
122 | trimmed->push_back(temp); |
---|
123 | } |
---|
124 | } |
---|
125 | |
---|
126 | *str = *trimmed; |
---|
127 | } |
---|
128 | |
---|
129 | const int TixyTaxyTorxyCenterpoint::getTowerCost(int upgrade) const |
---|
130 | { |
---|
131 | return towerCosts_[(upgrade%5)]; |
---|
132 | } |
---|
133 | } |
---|