[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 | |
---|
[8301] | 29 | /* TODO: - Sobald Bots im Spiel sind, stürzt das Programm relativ bald ab!!! |
---|
[8201] | 30 | */ |
---|
[8281] | 31 | |
---|
| 32 | |
---|
| 33 | /* REALISIERUNGSIDEEN: |
---|
| 34 | |
---|
| 35 | Mehrere Instanzen: |
---|
| 36 | Im Konstruktor schauen, wer innerhalb der eigenen Grenzen ist und diese in eine Liste geben, die in jeder tick-Funktion |
---|
| 37 | durchgearbeitet wird. |
---|
| 38 | Moeglichkeit bereitstellen, ein Pawn durch ein Portal einer anderen Instanz von SpaceBoundaries zuzuweisen. |
---|
| 39 | Schauen, wie es zu handhaben ist, wenn ein neuer Spieler oder Bot nachtraeglich ins Spiel kommt. |
---|
| 40 | |
---|
| 41 | */ |
---|
[8087] | 42 | |
---|
| 43 | #ifndef _SpaceBoundaries_H__ |
---|
| 44 | #define _SpaceBoundaries_H__ |
---|
| 45 | |
---|
| 46 | /* Einige, spezifische include-Statements */ |
---|
[8110] | 47 | #include "core/CoreIncludes.h" |
---|
| 48 | #include "tools/interfaces/Tickable.h" |
---|
[8201] | 49 | #include "interfaces/RadarViewable.h" |
---|
[8110] | 50 | #include "worldentities/StaticEntity.h" |
---|
| 51 | #include "worldentities/WorldEntity.h" |
---|
[8087] | 52 | |
---|
[8164] | 53 | #include <string> |
---|
[8281] | 54 | #include <list> |
---|
[8301] | 55 | #include <map> |
---|
| 56 | #include <vector> |
---|
[8164] | 57 | |
---|
[8201] | 58 | /** |
---|
| 59 | @brief SpaceBoundaries gives level creators the possibility to bar Pawns from leaving a defined area. |
---|
[8164] | 60 | |
---|
[8244] | 61 | Five attributes can/should be defined in the XML-File: |
---|
| 62 | - 'position' : absolute position of the SpaceBoundaries class. 'warnDistance' and 'maxDistance' refer to this 'position'. |
---|
[8237] | 63 | - 'warnDistance' : If the distance between the pawn of the human player and 'position' is bigger than 'warnDistance', a message is displayed to |
---|
| 64 | inform the player that he'll soon be leaving the allowed area. |
---|
| 65 | - 'maxDistance' : defines the area, where a pawn is allowed to be (radius of a ball). |
---|
[8244] | 66 | - 'showDistance' : If the distance between the pawn and the boundary of the allowed area is smaller than 'showDistance', the boundary is shown. |
---|
[8237] | 67 | - 'healthDecrease' : a measure to define how fast the health of a pawn should decrease after leaving the allowed area. |
---|
| 68 | Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung) |
---|
[8201] | 69 | */ |
---|
| 70 | |
---|
[8087] | 71 | namespace orxonox |
---|
| 72 | { |
---|
| 73 | class _OrxonoxExport SpaceBoundaries : public StaticEntity, public Tickable |
---|
| 74 | { |
---|
| 75 | public: |
---|
| 76 | SpaceBoundaries(BaseObject* creator); |
---|
[8110] | 77 | ~SpaceBoundaries(); |
---|
| 78 | |
---|
[8301] | 79 | void checkWhoIsIn(); //!< Update the list 'pawnsIn_'. |
---|
[8281] | 80 | |
---|
[8301] | 81 | void positionBillboard(const Vector3 position); |
---|
| 82 | void setBillboardOptions(Billboard *billy); |
---|
| 83 | void removeAllBillboards(); |
---|
| 84 | |
---|
[8244] | 85 | void setMaxDistance(float r); |
---|
[8110] | 86 | float getMaxDistance(); |
---|
| 87 | |
---|
| 88 | void setWarnDistance(float r); |
---|
| 89 | float getWarnDistance(); |
---|
[8201] | 90 | |
---|
[8244] | 91 | void setShowDistance(float r); |
---|
| 92 | float getShowDistance(); |
---|
| 93 | |
---|
[8201] | 94 | void setHealthDecrease(float amount); |
---|
| 95 | float getHealthDecrease(); |
---|
[8087] | 96 | |
---|
[8110] | 97 | void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
| 98 | |
---|
| 99 | void tick(float dt); |
---|
[8087] | 100 | |
---|
| 101 | private: |
---|
[8301] | 102 | struct billboardAdministration{ bool usedYet; Billboard* billy; }; |
---|
| 103 | |
---|
| 104 | std::list<Pawn*> pawnsIn_; //!< List of the pawns that this instance of SpaceBoundaries has to handle. |
---|
| 105 | |
---|
| 106 | std::vector<billboardAdministration> billboards_; |
---|
[8281] | 107 | |
---|
[8201] | 108 | float maxDistance_; //!< maximal zulaessige Entfernung von 'this->getPosition()'. |
---|
| 109 | float warnDistance_; //!< Entfernung von 'this->getPosition()', ab der eine Warnung angezeigt wird, dass man bald das zulaessige Areal verlaesst. |
---|
[8244] | 110 | float showDistance_; //!< Definiert, wann die Grenzen visualisiert werden sollen. |
---|
[8201] | 111 | |
---|
| 112 | float healthDecrease_; //!< Mass fuer die Anzahl Health-Points, die nach ueberschreiten der Entfernung 'maxDistance_' von 'this->getPosition()' abgezogen werden. |
---|
| 113 | //!< Empfohlene Werte: 0.1 (langsame Health-Verminderung) bis 5 (sehr schnelle Health-Verminderung) |
---|
| 114 | |
---|
[8244] | 115 | Billboard *boundary_; |
---|
| 116 | |
---|
[8237] | 117 | RadarViewable* centerRadar_; //!< Repraesentation von SpaceBoundaries auf dem Radar. |
---|
[8087] | 118 | |
---|
[8201] | 119 | float computeDistance(WorldEntity *item); //!< Auf den Mittelpunkt 'this->getPosition()' bezogen. |
---|
[8164] | 120 | void displayWarning(const std::string warnText); |
---|
[8244] | 121 | void displayBoundaries(Pawn *item); |
---|
| 122 | void bounceBack(Pawn *item); |
---|
[8164] | 123 | bool isHumanPlayer(Pawn *item); |
---|
[8201] | 124 | |
---|
[8087] | 125 | }; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | #endif /* _SpaceBoundaries_H__ */ |
---|