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 JumpScore.cc |
---|
31 | @brief HUD of thejump minigame. If showScore_ is set, it displays the score. If showMessages_ is set, it displays the game over message. |
---|
32 | */ |
---|
33 | |
---|
34 | #include "JumpScore.h" |
---|
35 | #include "core/CoreIncludes.h" |
---|
36 | #include "core/XMLPort.h" |
---|
37 | #include "util/Convert.h" |
---|
38 | #include "infos/PlayerInfo.h" |
---|
39 | #include "Jump.h" |
---|
40 | #include "sound/WorldSound.h" |
---|
41 | |
---|
42 | namespace orxonox |
---|
43 | { |
---|
44 | RegisterClass(JumpScore); |
---|
45 | |
---|
46 | JumpScore::JumpScore(Context* context) : OverlayText(context) |
---|
47 | { |
---|
48 | RegisterObject(JumpScore); |
---|
49 | |
---|
50 | owner_ = NULL; |
---|
51 | showScore_ = false; |
---|
52 | showFuel_ = false; |
---|
53 | showMessages_ = false; |
---|
54 | } |
---|
55 | |
---|
56 | JumpScore::~JumpScore() |
---|
57 | { |
---|
58 | |
---|
59 | } |
---|
60 | |
---|
61 | void JumpScore::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
62 | { |
---|
63 | SUPER(JumpScore, XMLPort, xmlelement, mode); |
---|
64 | |
---|
65 | XMLPortParam(JumpScore, "showScore", setShowScore, getShowScore, xmlelement, mode); |
---|
66 | XMLPortParam(JumpScore, "showFuel", setShowFuel, getShowFuel, xmlelement, mode); |
---|
67 | XMLPortParam(JumpScore, "showMessages", setShowMessages, getShowMessages, xmlelement, mode); |
---|
68 | XMLPortParam(JumpScore, "gameOverText", setGameOverText, getGameOverText, xmlelement, mode); |
---|
69 | } |
---|
70 | |
---|
71 | void JumpScore::tick(float dt) |
---|
72 | { |
---|
73 | SUPER(JumpScore, tick, dt); |
---|
74 | |
---|
75 | if (owner_ != NULL) |
---|
76 | { |
---|
77 | if (!owner_->hasEnded()) |
---|
78 | { |
---|
79 | player_ = owner_->getPlayer(); |
---|
80 | |
---|
81 | if (player_ != NULL) |
---|
82 | { |
---|
83 | if (showScore_ == true) |
---|
84 | { |
---|
85 | int score = owner_->getScore(player_); |
---|
86 | |
---|
87 | std::string str = multi_cast<std::string>(score); |
---|
88 | setCaption(str); |
---|
89 | } |
---|
90 | else if (showFuel_ == true) |
---|
91 | { |
---|
92 | float fuel = owner_->getFuel(); |
---|
93 | orxout() << fuel << endl; |
---|
94 | std::string str; |
---|
95 | |
---|
96 | if (fuel <= 0.0) |
---|
97 | { |
---|
98 | str = ""; |
---|
99 | } |
---|
100 | else |
---|
101 | { |
---|
102 | str = multi_cast<std::string>(fuel); |
---|
103 | } |
---|
104 | setCaption(str); |
---|
105 | } |
---|
106 | else if (showMessages_ == true) |
---|
107 | { |
---|
108 | setCaption(owner_->getDead(player_) == true ? gameOverText_ : ""); |
---|
109 | } |
---|
110 | } |
---|
111 | } |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | void JumpScore::changedOwner() |
---|
116 | { |
---|
117 | SUPER(JumpScore, changedOwner); |
---|
118 | |
---|
119 | if (this->getOwner() != NULL && this->getOwner()->getGametype()) |
---|
120 | { |
---|
121 | this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype()); |
---|
122 | } |
---|
123 | else |
---|
124 | { |
---|
125 | this->owner_ = NULL; |
---|
126 | } |
---|
127 | } |
---|
128 | } |
---|