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 | * Florian Zinggeler |
---|
24 | * |
---|
25 | */ |
---|
26 | |
---|
27 | #include "MiniGameTestHUDinfo.h" |
---|
28 | |
---|
29 | #include "core/CoreIncludes.h" |
---|
30 | #include "core/XMLPort.h" |
---|
31 | #include "util/Convert.h" |
---|
32 | //#include "MiniGameTest.h" |
---|
33 | |
---|
34 | namespace orxonox |
---|
35 | { |
---|
36 | RegisterClass(MiniGameTestHUDinfo); |
---|
37 | |
---|
38 | MiniGameTestHUDinfo::MiniGameTestHUDinfo(Context* context) : OverlayText(context) |
---|
39 | { |
---|
40 | RegisterObject(MiniGameTestHUDinfo); |
---|
41 | |
---|
42 | this->MiniGameTestGame = nullptr; |
---|
43 | this->bShowPoints_ = true; |
---|
44 | } |
---|
45 | |
---|
46 | void MiniGameTestHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
47 | { |
---|
48 | SUPER(MiniGameTestHUDinfo, XMLPort, xmlelement, mode); |
---|
49 | |
---|
50 | XMLPortParam(MiniGameTestHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); |
---|
51 | } |
---|
52 | |
---|
53 | void MiniGameTestHUDinfo::tick(float dt) |
---|
54 | { |
---|
55 | SUPER(MiniGameTestHUDinfo, tick, dt); |
---|
56 | |
---|
57 | |
---|
58 | if(this->bShowPoints_) |
---|
59 | { |
---|
60 | const std::string& points = multi_cast<std::string>(this->MiniGameTestGame->getPoints()); |
---|
61 | if (this->MiniGameTestGame->lives <= 0) |
---|
62 | { |
---|
63 | setTextSize(0.2); |
---|
64 | setPosition(Vector2(0.1, 0.02)); |
---|
65 | this->setCaption("Final score:\n" + points); |
---|
66 | this->setColour(ColourValue(1, 0, 0, 1)); |
---|
67 | } |
---|
68 | else |
---|
69 | { |
---|
70 | setTextSize(0.04); |
---|
71 | setPosition(Vector2(0.14, 0.02)); |
---|
72 | this->setColour(ColourValue(1, 1, 1, 1)); |
---|
73 | this->setCaption(points); |
---|
74 | } |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | void MiniGameTestHUDinfo::changedOwner() |
---|
79 | { |
---|
80 | SUPER(MiniGameTestHUDinfo, changedOwner); |
---|
81 | |
---|
82 | if (this->getOwner() && this->getOwner()->getGametype()) |
---|
83 | { |
---|
84 | this->MiniGameTestGame = orxonox_cast<MiniGameTest*>(this->getOwner()->getGametype()); |
---|
85 | } |
---|
86 | else |
---|
87 | { |
---|
88 | this->MiniGameTestGame = nullptr; |
---|
89 | } |
---|
90 | } |
---|
91 | } |
---|