[8087] | 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 | * Maurus Kaufmann |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
[8201] | 28 | |
---|
[8244] | 29 | /* TODO: - Markiere SpaceBoundaries-Position mit einem schoenen Objekt |
---|
| 30 | - Reflexion an Grenze mit Quaternionen machen (--> vgl. Funktion bounceBack() ) |
---|
[8201] | 31 | */ |
---|
[8087] | 32 | |
---|
| 33 | #ifndef _SpaceBoundaries_H__ |
---|
| 34 | #define _SpaceBoundaries_H__ |
---|
| 35 | |
---|
| 36 | /* Einige, spezifische include-Statements */ |
---|
[8110] | 37 | #include "core/CoreIncludes.h" |
---|
| 38 | #include "tools/interfaces/Tickable.h" |
---|
[8201] | 39 | #include "interfaces/RadarViewable.h" |
---|
[8110] | 40 | #include "worldentities/StaticEntity.h" |
---|
| 41 | #include "worldentities/WorldEntity.h" |
---|
[8087] | 42 | |
---|
[8166] | 43 | //#include <ColoredTextAreaOverlayElementFactory.h> |
---|
[8087] | 44 | |
---|
[8164] | 45 | #include <string> |
---|
| 46 | |
---|
[8201] | 47 | /** |
---|
| 48 | @brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area. |
---|
[8164] | 49 | |
---|
[8244] | 50 | Five attributes can/should be defined in the XML-File: |
---|
| 51 | - 'position' : absolute position of the SpaceBoundaries class. 'warnDistance' and 'maxDistance' refer to this 'position'. |
---|
[8237] | 52 | - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to |
---|
| 53 | inform the player that he'll soon be leaving the allowed area. |
---|
| 54 | - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball). |
---|
[8244] | 55 | - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown. |
---|
[8237] | 56 | - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area. |
---|
| 57 | Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung) |
---|
[8201] | 58 | */ |
---|
| 59 | |
---|
[8087] | 60 | namespace orxonox |
---|
| 61 | { |
---|
| 62 | class _OrxonoxExport SpaceBoundaries : public StaticEntity, public Tickable |
---|
| 63 | { |
---|
| 64 | public: |
---|
| 65 | SpaceBoundaries(BaseObject* creator); |
---|
[8110] | 66 | ~SpaceBoundaries(); |
---|
| 67 | |
---|
[8244] | 68 | void setMaxDistance(float r); |
---|
[8110] | 69 | float getMaxDistance(); |
---|
| 70 | |
---|
| 71 | void setWarnDistance(float r); |
---|
| 72 | float getWarnDistance(); |
---|
[8201] | 73 | |
---|
[8244] | 74 | void setShowDistance(float r); |
---|
| 75 | float getShowDistance(); |
---|
| 76 | |
---|
[8201] | 77 | void setHealthDecrease(float amount); |
---|
| 78 | float getHealthDecrease(); |
---|
[8087] | 79 | |
---|
[8110] | 80 | void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 81 | |
---|
| 82 | void tick(float dt); |
---|
[8087] | 83 | |
---|
| 84 | private: |
---|
[8201] | 85 | float maxDistance_; //!< maximal zulaessige Entfernung von 'this->getPosition()'. |
---|
| 86 | float warnDistance_; //!< Entfernung von 'this->getPosition()', ab der eine Warnung angezeigt wird, dass man bald das zulaessige Areal verlaesst. |
---|
[8244] | 87 | float showDistance_; //!< Definiert, wann die Grenzen visualisiert werden sollen. |
---|
[8201] | 88 | |
---|
| 89 | float healthDecrease_; //!< Mass fuer die Anzahl Health-Points, die nach ueberschreiten der Entfernung 'maxDistance_' von 'this->getPosition()' abgezogen werden. |
---|
| 90 | //!< Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung) |
---|
| 91 | |
---|
[8244] | 92 | Billboard *boundary_; |
---|
| 93 | |
---|
[8237] | 94 | RadarViewable* centerRadar_; //!< Repraesentation von SpaceBoundaries auf dem Radar. |
---|
[8087] | 95 | |
---|
[8201] | 96 | float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'this->getPosition()' bezogen. |
---|
[8164] | 97 | void displayWarning(const std::string warnText); |
---|
[8244] | 98 | void displayBoundaries(Pawn *item); |
---|
| 99 | void bounceBack(Pawn *item); |
---|
[8164] | 100 | bool isHumanPlayer(Pawn *item); |
---|
[8201] | 101 | |
---|
[8166] | 102 | // ColoredTextAreaOverlayElementFactory* pColoredTextAreaOverlayElementFactory; |
---|
[8087] | 103 | }; |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | #endif /* _SpaceBoundaries_H__ */ |
---|