[Orxonox-commit 7533] r12136 - in code/branches/wagnis_HS18: data/levels data/levels/templates data/overlays src/modules/wagnis src/modules/weapons/projectiles src/modules/weapons/weaponmodes
kunzro at orxonox.net
kunzro at orxonox.net
Wed Dec 5 09:26:18 CET 2018
Author: kunzro
Date: 2018-12-05 09:26:18 +0100 (Wed, 05 Dec 2018)
New Revision: 12136
Added:
code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUD.cc
code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUD.h
Modified:
code/branches/wagnis_HS18/data/levels/Wagnis_testlevel.oxw
code/branches/wagnis_HS18/data/levels/templates/wagnisCursor.oxt
code/branches/wagnis_HS18/data/overlays/WagnisHUD.oxo
code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt
code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h
code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.cc
code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.cc
Log:
HUD fixed
Modified: code/branches/wagnis_HS18/data/levels/Wagnis_testlevel.oxw
===================================================================
--- code/branches/wagnis_HS18/data/levels/Wagnis_testlevel.oxw 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/data/levels/Wagnis_testlevel.oxw 2018-12-05 08:26:18 UTC (rev 12136)
@@ -36,39 +36,84 @@
<Provinces>
- <WagnisProvince ID="1" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=dynamic mass=100 continent="1" position="0,<?lua print((50))?>,<?lua print((70))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
+ <WagnisProvince ID="1" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=kinematic mass=100 continent="1" position="0,<?lua print((50))?>,<?lua print((70))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
<attached>
<Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
</attached>
<collisionShapes>
- <SphereCollisionShape position="0,0,0" radius="2" />
+ <BoxCollisionShape position="0,0,0" halfExtents="3,3,3" />
</collisionShapes>
</WagnisProvince>
- <WagnisProvince ID="2" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=dynamic mass=100 continent="1" position="0,<?lua print((40))?>,<?lua print((70))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
+ <WagnisProvince ID="2" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=kinematic mass=100 continent="1" position="0,<?lua print((40))?>,<?lua print((70))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
<attached>
<Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
</attached>
<collisionShapes>
- <SphereCollisionShape position="0,0,0" radius="2" />
+ <BoxCollisionShape position="0,0,0" halfExtents="3,3,3" />
</collisionShapes>
</WagnisProvince>
- <WagnisProvince ID="3" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=dynamic mass=100 continent="1" position="0,<?lua print((50))?>,<?lua print((80))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
+ <WagnisProvince ID="3" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=kinematic mass=100 continent="1" position="0,<?lua print((40))?>,<?lua print((60))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
<attached>
<Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
</attached>
<collisionShapes>
- <SphereCollisionShape position="0,0,0" radius="2" />
+ <BoxCollisionShape position="0,0,0" halfExtents="3,3,3" />
</collisionShapes>
</WagnisProvince>
- <WagnisProvince ID="1000" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=dynamic mass=100 continent="1" position="0,<?lua print((50+7))?>,<?lua print((135-6))?>" pitch=90 rotationrate="0" rotationaxis="0,0,0">
+ <WagnisProvince ID="4" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=kinematic mass=100 continent="1" position="0,<?lua print((50))?>,<?lua print((60))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
<attached>
+ <Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="3,3,3" />
+ </collisionShapes>
+ </WagnisProvince>
+
+ <WagnisProvince ID="5" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=kinematic mass=100 continent="1" position="0,<?lua print((50))?>,<?lua print((100))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
+ <attached>
+ <Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="3,3,3" />
+ </collisionShapes>
+ </WagnisProvince>
+
+ <WagnisProvince ID="6" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=kinematic mass=100 continent="1" position="0,<?lua print((50))?>,<?lua print((110))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
+ <attached>
+ <Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="3,3,3" />
+ </collisionShapes>
+ </WagnisProvince>
+
+ <WagnisProvince ID="7" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=kinematic mass=100 continent="1" position="0,<?lua print((50))?>,<?lua print((120))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
+ <attached>
+ <Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="3,3,3" />
+ </collisionShapes>
+ </WagnisProvince>
+
+ <WagnisProvince ID="8" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=kinematic mass=100 continent="1" position="0,<?lua print((40))?>,<?lua print((130))?>" rotationrate="<?lua print(math.random() * 50) ?>" rotationaxis="<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>,<?lua print((math.random()-1)*5)?>">
+ <attached>
+ <Model position="0,0,0" mesh="ast1.mesh" scale3D="1.4,1.4,1.4" />
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0,0,0" halfExtents="3,3,3" />
+ </collisionShapes>
+ </WagnisProvince>
+
+ <WagnisProvince ID="1000" health = 10000000 maxhealth = 10000000 initialhealth = 10000000 collisionType=kinematic mass=100 continent="1" position="0,<?lua print((50+7))?>,<?lua print((135-6))?>" pitch=90 rotationrate="0" rotationaxis="0,0,0">
+ <attached>
<Model position="0,0,0" mesh="broke-satellite.mesh" scale3D="3,3,3" />
</attached>
<collisionShapes>
- <SphereCollisionShape position="0,0,0" radius="4" />
+ <BoxCollisionShape position="0,0,0" halfExtents="3,3,3" />
</collisionShapes>
</WagnisProvince>
Modified: code/branches/wagnis_HS18/data/levels/templates/wagnisCursor.oxt
===================================================================
--- code/branches/wagnis_HS18/data/levels/templates/wagnisCursor.oxt 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/data/levels/templates/wagnisCursor.oxt 2018-12-05 08:26:18 UTC (rev 12136)
@@ -1,42 +1,6 @@
<Template name=wagnisCursor>
<SpaceShip
hudtemplate = WagnisHUD
- camerapositiontemplate = spaceshipassffcameras
- spawnparticlesource = "Orxonox/fairytwirl"
- spawnparticleduration = 3
-
- health = 100
- maxhealth = 200
- initialhealth = 100
-
- shieldhealth = 30
- initialshieldhealth = 30
- maxshieldhealth = 50
- shieldabsorption = 0.8f
- shieldrechargerate = 1
- shieldrechargewaittime = 1
-
- primaryThrust = 0
- auxilaryThrust = 0
- rotationThrust = 0
-
- lift = 1;
- stallSpeed = 0;
-
- boostPower = 0
- boostPowerRate = 0
- boostRate = 0
- boostCooldownDuration = 0
-
- shakeFrequency = 15
- shakeAmplitude = 9
-
- collisionType = "dynamic"
- mass = 100
- linearDamping = 0.7
- angularDamping = 0.9999999
-
- explosionSound = "sounds/Explosion2.ogg"
>
Modified: code/branches/wagnis_HS18/data/overlays/WagnisHUD.oxo
===================================================================
--- code/branches/wagnis_HS18/data/overlays/WagnisHUD.oxo 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/data/overlays/WagnisHUD.oxo 2018-12-05 08:26:18 UTC (rev 12136)
@@ -1,7 +1,7 @@
<Template name="WagnisHUD">
- <OverlayGroup name = "WagnisHuD" scale = "1, 1">
+ <OverlayGroup name = "WagnisHuD" scale = "100, 100">
- <HUDNavigation
+ <WagnisHUD
name = "Navigation"
correctaspect = true
font = "Monofur"
Modified: code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/src/modules/wagnis/CMakeLists.txt 2018-12-05 08:26:18 UTC (rev 12136)
@@ -3,6 +3,7 @@
WagnisGameboard.cc
WagnisPlayer.cc
Wagnis.cc
+ WagnisHUD.cc
)
ORXONOX_ADD_LIBRARY(wagnis
Modified: code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/src/modules/wagnis/Wagnis.cc 2018-12-05 08:26:18 UTC (rev 12136)
@@ -16,7 +16,7 @@
this->gameStage = NOT_READY;
this->active_player = 1;
- int n = 3;
+ int n = 8;
for(int i = 0;i < n;i++){
WagnisPlayer* p = new WagnisPlayer(context);
p->Player_ID = i+1;
Added: code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUD.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUD.cc (rev 0)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUD.cc 2018-12-05 08:26:18 UTC (rev 12136)
@@ -0,0 +1,705 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Felix Schulthess
+ * Co-authors:
+ * Reto Grieder
+ * Oliver Scheuss
+ * Matthias Spalinger
+ *
+ */
+
+#include "WagnisHUD.h"
+
+#include <OgreCamera.h>
+
+#if OGRE_VERSION >= 0x010900
+# include <Overlay/OgreFontManager.h>
+# include <Overlay/OgreOverlayManager.h>
+# include <Overlay/OgreTextAreaOverlayElement.h>
+# include <Overlay/OgrePanelOverlayElement.h>
+#else
+# include <OgreFontManager.h>
+# include <OgreOverlayManager.h>
+# include <OgreTextAreaOverlayElement.h>
+# include <OgrePanelOverlayElement.h>
+#endif
+
+#include <typeinfo>
+
+#include "util/Math.h"
+#include "util/Convert.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "CameraManager.h"
+#include "Scene.h"
+#include "Radar.h"
+#include "graphics/Camera.h"
+#include "controllers/HumanController.h"
+#include "worldentities/pawns/Pawn.h"
+#include "worldentities/WorldEntity.h"
+#include "core/config/ConfigValueIncludes.h"
+#include "tools/TextureGenerator.h"
+
+
+namespace orxonox
+{
+
+ SetConsoleCommand("WagnisHUD","selectClosest", &WagnisHUD::selectClosestTarget).addShortcut().keybindMode(KeybindMode::OnPress);
+ SetConsoleCommand("WagnisHUD","selectNext", &WagnisHUD::selectNextTarget).addShortcut().keybindMode(KeybindMode::OnPress);
+
+ static bool compareDistance(std::pair<RadarViewable*, unsigned int> a,
+ std::pair<RadarViewable*, unsigned int> b)
+ {
+ return a.second < b.second;
+ }
+ RegisterClass ( WagnisHUD );
+
+ WagnisHUD* WagnisHUD::localHUD_s = nullptr;
+
+ WagnisHUD::WagnisHUD(Context* context) :
+ OrxonoxOverlay(context)
+ {
+ RegisterObject(WagnisHUD);
+ this->setConfigValues();
+
+ // Set default values
+ this->setFont("Monofur");
+ this->setTextSize(0.05f);
+ this->setNavMarkerSize(0.03f);
+ this->setAimMarkerSize(0.02f);
+ this->setHealthMarkerSize(0.06f);
+ this->setHealthLevelMarkerSize(0.06f);
+ markerLimit_ = 200;
+
+ this->setDetectionLimit(10000.0f);
+ this->currentMunitionSpeed_ = 750.0f;
+
+ this->closestTarget_ = true;
+ this->nextTarget_ = false;
+ WagnisHUD::localHUD_s = this;
+ }
+
+ WagnisHUD::~WagnisHUD()
+ {
+ if (this->isInitialized())
+ {
+ for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end();)
+ removeObject((it++)->first);
+ }
+ this->sortedObjectList_.clear();
+ }
+
+ void WagnisHUD::setConfigValues()
+ {
+ SetConfigValue(markerLimit_, 3);
+ SetConfigValue(showDistance_, false);
+ }
+
+ void WagnisHUD::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(WagnisHUD, XMLPort, xmlelement, mode);
+
+ XMLPortParam(WagnisHUD, "font", setFont, getFont, xmlelement, mode);
+ XMLPortParam(WagnisHUD, "textSize", setTextSize, getTextSize, xmlelement, mode);
+ XMLPortParam(WagnisHUD, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode);
+ XMLPortParam(WagnisHUD, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode);
+ XMLPortParam(WagnisHUD, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlelement, mode);
+ XMLPortParam(WagnisHUD, "healthMarkerSize", setHealthMarkerSize, getHealthMarkerSize, xmlelement, mode);
+ XMLPortParam(WagnisHUD, "healthLevelMarkerSize", setHealthLevelMarkerSize, getHealthLevelMarkerSize, xmlelement, mode);
+
+ }
+
+ void WagnisHUD::setFont(const std::string& font)
+ {
+ const Ogre::ResourcePtr& fontPtr = Ogre::FontManager::getSingleton().getByName(font);
+ if (fontPtr.isNull())
+ {
+ orxout(internal_warning) << "WagnisHUD: Font '" << font << "' not found" << endl;
+ return;
+ }
+ this->fontName_ = font;
+ for (const auto& mapEntry : this->activeObjectList_)
+ {
+ if (mapEntry.second.text_ != nullptr)
+ mapEntry.second.text_->setFontName(this->fontName_);
+ }
+ }
+
+ const std::string& WagnisHUD::getFont() const
+ {
+ return this->fontName_;
+ }
+
+ void WagnisHUD::setTextSize(float size)
+ {
+ if (size <= 0.0f)
+ {
+ orxout(internal_warning) << "WagnisHUD: Negative font size not allowed" << endl;
+ return;
+ }
+ this->textSize_ = size;
+ for (const auto& mapEntry : this->activeObjectList_)
+ {
+ if (mapEntry.second.text_)
+ mapEntry.second.text_->setCharHeight(size);
+ }
+ }
+
+ float WagnisHUD::getTextSize() const
+ {
+ return this->textSize_;
+ }
+
+ float WagnisHUD::getArrowSizeX(int dist) const
+ {
+ if (dist < 600)
+ dist = 600;
+ return this->getActualSize().x * 900 * this->navMarkerSize_ / dist;
+ }
+
+ float WagnisHUD::getArrowSizeY(int dist) const
+ {
+ if (dist < 600)
+ dist = 600;
+ return this->getActualSize().y * 900 * this->navMarkerSize_ / dist;
+ }
+
+ void WagnisHUD::tick(float dt)
+ {
+ SUPER(WagnisHUD, tick, dt);
+
+ Camera* cam = CameraManager::getInstance().getActiveCamera();
+ if (cam == nullptr)
+ return;
+ const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
+
+ for (std::pair<RadarViewable*, unsigned int>& pair : this->sortedObjectList_)
+ pair.second = (int)((pair.first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f);
+
+ this->sortedObjectList_.sort(compareDistance);
+
+ unsigned int markerCount = 0;
+ bool closeEnough = false; // only display objects that are close enough to be relevant for the player
+
+ // if the selected object doesn't exist any more or is now out of range select the closest object
+ std::map<RadarViewable*, ObjectInfo>::iterator selectedActiveObject = this->activeObjectList_.find(this->selectedTarget_);
+ if(selectedActiveObject == this->activeObjectList_.end())
+ {
+ this->closestTarget_ = true;
+ }
+ else if(this->detectionLimit_ < (this->selectedTarget_->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f)
+ {
+ this->closestTarget_ = true;
+ selectedActiveObject->second.selected_ = false;
+ }
+
+ bool nextHasToBeSelected = false;
+
+ for (std::list<std::pair<RadarViewable*, unsigned int>>::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++markerCount, ++listIt)
+ {
+
+ std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.find(listIt->first);
+ closeEnough = listIt->second < this->detectionLimit_;
+ // display radarviewables on HUD if the marker limit and max-distance is not exceeded
+ if (markerCount < this->markerLimit_ && (closeEnough || this->detectionLimit_ < 0))
+ {
+ // Get Distance to HumanController and save it in the TextAreaOverlayElement.
+ int dist = listIt->second;
+ float textLength = 0.0f;
+
+ if (this->showDistance_)
+ {
+ //display distance next to cursor
+ it->second.text_->setCaption(multi_cast<std::string>(dist));
+ textLength = multi_cast<std::string>(dist).size() * it->second.text_->getCharHeight() * 0.3f;
+ }
+ else
+ {
+ //display name next to cursor
+ it->second.text_->setCaption(it->first->getRadarName());
+ textLength = it->first->getRadarName().size() * it->second.text_->getCharHeight() * 0.3f;
+ }
+
+ // select the object that aim-assistant indicates
+ if(this->closestTarget_)
+ // select the closest object
+ {
+ if(listIt == this->sortedObjectList_.begin())
+ {
+ it->second.selected_ = true;
+ this->selectedTarget_ = it->first;
+ }
+ else if(it->second.selected_)
+ {
+ it->second.selected_ = false;
+ }
+
+ }
+ else if(this->nextTarget_)
+ // select the next object in sortedObjectList
+ {
+ if(nextHasToBeSelected){
+ it->second.selected_ = true;
+ this->selectedTarget_ = it->first;
+ nextHasToBeSelected = false;
+ }
+ else if(it->second.selected_)
+ {
+ nextHasToBeSelected = true;
+ it->second.selected_ = false;
+
+ // check if there's a next object
+ listIt++;
+ if(listIt != this->sortedObjectList_.end())
+ {
+ // and if the marker limit and max-distance are not exceeded for it
+ if (markerCount + 1 >= this->markerLimit_ ||
+ (listIt->second > this->detectionLimit_ && detectionLimit_ >= 0))
+ {
+ // otherwise select the closest object
+ this->activeObjectList_.find(this->sortedObjectList_.begin()->first)->second.selected_ = true;
+ this->selectedTarget_ = it->first;
+ nextHasToBeSelected = false;
+ }
+ }
+ listIt--;
+ }
+ }
+
+
+
+
+ // Transform to screen coordinates
+ Vector3 pos = camTransform * it->first->getRVWorldPosition();
+
+ bool outOfView = true;
+ if (pos.z > 1.0)
+ {
+ // z > 1.0 means that the object is behind the camera
+ outOfView = true;
+ // we have to switch all coordinates (if you don't know why,
+ // try linear algebra lectures, because I can't explain..)
+ pos.x = -pos.x;
+ pos.y = -pos.y;
+ }
+ else
+ outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
+
+ if (outOfView)
+ {
+ // Object is not in view
+
+ // Change material only if outOfView changed
+ if (!it->second.wasOutOfView_)
+ {
+ it->second.health_->hide();
+ it->second.healthLevel_->hide();
+ it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("arrows.png", it->first->getRadarObjectColour()));
+ it->second.wasOutOfView_ = true;
+ it->second.target_->hide();
+ }
+
+ //float xDistScale = this->getActualSize().x * 1000.0f * this->navMarkerSize_ / dist;
+ //float yDistScale = this->getActualSize().y * 1000.0f * this->navMarkerSize_ / dist;
+
+ // Adjust Arrowsize according to distance
+ it->second.panel_->setDimensions(getArrowSizeX(dist), getArrowSizeY(dist));
+
+ // Switch between top, bottom, left and right position of the arrow at the screen border
+ if (pos.x < pos.y)
+ {
+ if (pos.y > -pos.x)
+ {
+ // Top
+ float position = pos.x / pos.y + 1.0f;
+ it->second.panel_->setPosition((position - it->second.panel_->getWidth()) * 0.5f, 0.0f);
+ it->second.panel_->setUV(0.5f, 0.0f, 1.0f, 0.5f);
+ it->second.text_->setLeft((position - textLength) * 0.5f);
+ it->second.text_->setTop(it->second.panel_->getHeight());
+ }
+ else
+ {
+ // Left
+ float position = pos.y / pos.x + 1.0f;
+ it->second.panel_->setPosition(0.0f, (position - it->second.panel_->getWidth()) * 0.5f);
+ it->second.panel_->setUV(0.0f, 0.0f, 0.5f, 0.5f);
+ it->second.text_->setLeft(it->second.panel_->getWidth() + 0.01f);
+ it->second.text_->setTop((position - it->second.text_->getCharHeight()) * 0.5f);
+ }
+ }
+ else
+ {
+ if (pos.y < -pos.x)
+ {
+ // Bottom
+ float position = -pos.x / pos.y + 1.0f;
+ it->second.panel_->setPosition((position - it->second.panel_->getWidth()) * 0.5f, 1.0f - it->second.panel_->getHeight());
+ it->second.panel_->setUV(0.0f, 0.5f, 0.5f, 1.0f );
+ it->second.text_->setLeft((position - textLength) * 0.5f);
+ it->second.text_->setTop(1.0f - it->second.panel_->getHeight() - it->second.text_->getCharHeight());
+ }
+ else
+ {
+ // Right
+ float position = -pos.y / pos.x + 1.0f;
+ it->second.panel_->setPosition(1.0f - it->second.panel_->getWidth(), (position - it->second.panel_->getHeight()) * 0.5f);
+ it->second.panel_->setUV(0.5f, 0.5f, 1.0f, 1.0f);
+ it->second.text_->setLeft(1.0f - it->second.panel_->getWidth() - textLength - 0.01f);
+ it->second.text_->setTop((position - it->second.text_->getCharHeight()) * 0.5f);
+ }
+ }
+ }
+ else
+ {
+ // Object is in view
+
+ //calculate the health of the actual selected radarViewable (relativHealthScale: while (0) is no health left, (1) is the initial health)
+ const Pawn* pawnPtr = orxonox_cast<const Pawn*>(it->first->getWorldEntity());
+ if (pawnPtr)
+ {
+ float health = pawnPtr->getHealth();
+ float initHealth = pawnPtr->getMaxHealth();
+ float relativHealthScale = health/initHealth;
+
+ //integer values from 0 to 10 (0 is no health and 10 is full health)
+ int discreteHealthScale = (int)(10*relativHealthScale);
+
+ //calculate the HealthLevel (= OponentLevel or Strength) there are 5 Levels
+ //Level 1, Level 2,... , Level 5
+ int HealthLevel = 1;
+
+ if(initHealth < 200)
+ HealthLevel = 1;
+ if(200 <= initHealth && initHealth < 500)
+ HealthLevel = 2;
+ if(500 <= initHealth && initHealth < 1000)
+ HealthLevel = 3;
+ if(1000 <= initHealth && initHealth < 2500)
+ HealthLevel = 4;
+ if(2500 <= initHealth)
+ HealthLevel = 5;
+
+ // Change material only if outOfView changed
+ if (it->second.wasOutOfView_)
+ {
+ //it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2_1.png", it->first->getRadarObjectColour()));
+ it->second.health_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
+ it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , 0.75f*this->healthMarkerSize_ * this->getActualSize().y);
+
+ // because as soon as relative health drops below 10% (0.1) the descrete value is 0 but as long as the
+ // spaceship is still intact there should be at least one part of the bar left.
+ if(1<=discreteHealthScale){
+ it->second.health_->setTiling((float)discreteHealthScale , 1 ,0);
+ it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1f*discreteHealthScale, 0.75f*this->healthMarkerSize_ * this->getActualSize().y);
+ }
+
+ //healthLevel
+ it->second.healthLevel_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
+ it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x , 0.75f*this->healthLevelMarkerSize_ * this->getActualSize().y);
+ it->second.healthLevel_->setTiling((float)HealthLevel , 1 ,0);
+ it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x *0.1f*HealthLevel, 0.25f*this->healthLevelMarkerSize_ * this->getActualSize().y);
+ }
+
+ // sets Position and Dimensions (amount) health
+ it->second.health_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
+ it->second.health_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
+ it->second.health_->setTop((-pos.y + 1.04f - it->second.panel_->getHeight()) * 0.5f);
+
+ // because as soon as relative health drops below 10% (0.1) the descrete value is 0 but as long as the
+ // spaceship is still intact there should be at least one part of the bar left.
+ if(1<=discreteHealthScale){
+ it->second.health_->setTiling((float)discreteHealthScale , 1 ,0);
+ it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x *0.1f*discreteHealthScale, 0.75f*this->healthMarkerSize_ * this->getActualSize().y);
+ }
+
+ //sets Position and Dimensions (level) of healthLevel
+ it->second.healthLevel_->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", it->first->getRadarObjectColour()));
+ it->second.healthLevel_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
+ it->second.healthLevel_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
+ it->second.healthLevel_->setTop((-pos.y + 1.125f - it->second.panel_->getHeight()) * 0.5f);
+
+ it->second.healthLevel_->setTiling((float)HealthLevel , 1 ,0);
+ it->second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * this->getActualSize().x *0.1f*HealthLevel, 0.25f*this->healthLevelMarkerSize_ * this->getActualSize().y);
+
+ // Make sure the overlays are shown
+ it->second.health_->show();
+ it->second.healthLevel_->show();
+ }
+
+
+ // Change material only if outOfView changed
+ if (it->second.wasOutOfView_)
+ {
+ //it->second.panel_->setMaterialName("Orxonox/NavTDC");
+ it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("tdc.png", it->first->getRadarObjectColour()));
+ it->second.panel_->setDimensions(this->navMarkerSize_ * this->getActualSize().x, this->navMarkerSize_ * this->getActualSize().y);
+ it->second.target_->setDimensions(this->aimMarkerSize_ * this->getActualSize().x, this->aimMarkerSize_ * this->getActualSize().y);
+ it->second.wasOutOfView_ = false;
+ }
+
+ // Position marker
+ it->second.panel_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
+ it->second.panel_->setLeft((pos.x + 1.0f - it->second.panel_->getWidth()) * 0.5f);
+ it->second.panel_->setTop((-pos.y + 1.0f - it->second.panel_->getHeight()) * 0.5f);
+
+ // Position text
+ it->second.text_->setLeft((pos.x + 1.0f + it->second.panel_->getWidth()) * 0.5f);
+ it->second.text_->setTop((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f);
+
+ // Make sure the overlays are shown
+ it->second.panel_->show();
+ it->second.text_->show();
+
+ // Target marker
+ const Pawn* pawn = dynamic_cast<const Pawn*>(it->first->getWorldEntity());
+ /* Pawn* humanPawn = HumanController::getLocalControllerEntityAsPawn();*/
+ if(!it->second.selected_
+ || it->first->getRVVelocity().squaredLength() == 0
+ || pawn == nullptr
+ /* TODO : improve getTeam in such a way that it works
+ * || humanPawn == nullptr
+ * || pawn->getTeam() == humanPawn->getTeam()*/)
+ {
+ // don't show marker for not selected enemies nor if the selected doesn't move
+ it->second.target_->hide();
+ }
+ else // object is selected and moves
+ {
+ // get the aim position
+ const Vector3& targetPos = this->toAimPosition(it->first);
+ // Transform to screen coordinates
+ Vector3 screenPos = camTransform * targetPos;
+ // Check if the target marker is in view too
+ if(screenPos.z > 1 || screenPos.x < -1.0 || screenPos.x > 1.0
+ || screenPos.y < -1.0 || screenPos.y > 1.0)
+ {
+ it->second.target_->hide();
+ }
+ else
+ {
+ it->second.target_->setLeft((screenPos.x + 1.0f - it->second.target_->getWidth()) * 0.5f);
+ it->second.target_->setTop((-screenPos.y + 1.0f - it->second.target_->getHeight()) * 0.5f);
+ it->second.target_->show();
+ }
+ }
+
+ }
+ }
+ else // do not display on HUD
+
+ {
+ it->second.health_->hide();
+ it->second.healthLevel_->hide();
+ it->second.panel_->hide();
+ it->second.text_->hide();
+ it->second.target_->hide();
+ }
+ }
+
+ this->closestTarget_ = false;
+ this->nextTarget_ = false;
+ }
+
+ /** Overridden method of OrxonoxOverlay.
+ @details
+ Usually the entire overlay scales with scale().
+ Here we obviously have to adjust this.
+ */
+ void WagnisHUD::sizeChanged()
+ {
+ // Use size to compensate for aspect ratio if enabled.
+ float xScale = this->getActualSize().x;
+ float yScale = this->getActualSize().y;
+
+ for (const auto& mapEntry : this->activeObjectList_)
+ {
+ if (mapEntry.second.health_ != nullptr)
+ mapEntry.second.health_->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale);
+ if (mapEntry.second.healthLevel_ != nullptr)
+ mapEntry.second.healthLevel_->setDimensions(this->healthLevelMarkerSize_ * xScale, this->healthLevelMarkerSize_ * yScale);
+ if (mapEntry.second.panel_ != nullptr)
+ mapEntry.second.panel_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
+ if (mapEntry.second.text_ != nullptr)
+ mapEntry.second.text_->setCharHeight(this->textSize_ * yScale);
+ if (mapEntry.second.target_ != nullptr)
+ mapEntry.second.target_->setDimensions(this->aimMarkerSize_ * xScale, this->aimMarkerSize_ * yScale);
+ }
+ }
+
+ void WagnisHUD::addObject(RadarViewable* object)
+ {
+ if (showObject(object) == false)
+ return;
+
+ if (this->activeObjectList_.size() >= this->markerLimit_)
+ if (object == nullptr)
+ return;
+
+ // Object hasn't been added yet (we know that)
+ assert(this->activeObjectList_.find(object) == this->activeObjectList_.end());
+
+ // Scales used for dimensions and text size
+ float xScale = this->getActualSize().x;
+ float yScale = this->getActualSize().y;
+
+ // Create everything needed to display the object on the radar and add it to the map
+
+ // Create health
+ Ogre::PanelOverlayElement* health = static_cast<Ogre::PanelOverlayElement*>( Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "WagnisHUD_healthMarker_" + getUniqueNumberString()));
+ //panel->setMaterialName("Orxonox/NavTDC");
+ health->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", object->getRadarObjectColour()));
+ health->setDimensions(this->healthMarkerSize_ * xScale, this->healthMarkerSize_ * yScale);
+ //panel->setColour(object->getRadarObjectColour());
+
+ // Create healthLevel
+ Ogre::PanelOverlayElement* healthLevel = static_cast<Ogre::PanelOverlayElement*>( Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "WagnisHUD_healthLevelMarker_" + getUniqueNumberString()));
+ //panel->setMaterialName("Orxonox/NavTDC");
+ health->setMaterialName(TextureGenerator::getMaterialName("barSquare.png", object->getRadarObjectColour()));
+ health->setDimensions(this->healthLevelMarkerSize_ * xScale, this->healthLevelMarkerSize_ * yScale);
+
+
+ // Create arrow/marker
+ Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>( Ogre::OverlayManager::getSingleton()
+ .createOverlayElement("Panel", "WagnisHUD_navMarker_" + getUniqueNumberString()));
+ //panel->setMaterialName("Orxonox/NavTDC");
+ panel->setMaterialName(TextureGenerator::getMaterialName("tdc.png", object->getRadarObjectColour()));
+ panel->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
+ //panel->setColour(object->getRadarObjectColour());
+
+ // Create target marker
+ Ogre::PanelOverlayElement* target = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+ .createOverlayElement("Panel", "WagnisHUD_targetMarker_" + getUniqueNumberString()));
+ target->setMaterialName(TextureGenerator::getMaterialName("target.png", object->getRadarObjectColour()));
+ target->setDimensions(this->aimMarkerSize_ * xScale, this->aimMarkerSize_ * yScale);
+
+ // Create text
+ Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>( Ogre::OverlayManager::getSingleton()
+ .createOverlayElement("TextArea", "WagnisHUD_navText_" + getUniqueNumberString()));
+ text->setFontName(this->fontName_);
+ text->setCharHeight(this->textSize_ * yScale);
+ text->setColour(object->getRadarObjectColour());
+
+ health->hide();
+ healthLevel->hide();
+ panel->hide();
+ target->hide();
+ text->hide();
+
+ ObjectInfo tempStruct =
+ { health, healthLevel, panel, target, text, false, false, false};
+ this->activeObjectList_[object] = tempStruct;
+
+ this->background_->addChild(health);
+ this->background_->addChild(healthLevel);
+ this->background_->addChild(panel);
+ this->background_->addChild(target);
+ this->background_->addChild(text);
+
+ this->sortedObjectList_.push_front(std::make_pair(object, (unsigned int)0));
+ }
+
+ void WagnisHUD::removeObject(RadarViewable* viewable)
+ {
+ std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.find(viewable);
+
+ if (this->activeObjectList_.find(viewable) != this->activeObjectList_.end())
+ {
+ // Detach overlays
+ this->background_->removeChild(it->second.health_->getName());
+ this->background_->removeChild(it->second.healthLevel_->getName());
+ this->background_->removeChild(it->second.panel_->getName());
+ this->background_->removeChild(it->second.target_->getName());
+ this->background_->removeChild(it->second.text_->getName());
+ // Properly destroy the overlay elements (do not use delete!)
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.health_);
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.healthLevel_);
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.panel_);
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.target_);
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.text_);
+ // Remove from the list
+ this->activeObjectList_.erase(viewable);
+ }
+
+ for (std::list<std::pair<RadarViewable*, unsigned int>>::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++listIt)
+ {
+ if ((listIt->first) == viewable)
+ {
+ this->sortedObjectList_.erase(listIt);
+ break;
+ }
+ }
+ }
+
+ void WagnisHUD::objectChanged(RadarViewable* viewable)
+ {
+ // TODO: niceification neccessary ;)
+ removeObject(viewable);
+ addObject(viewable);
+ }
+
+ bool WagnisHUD::showObject(RadarViewable* rv)
+ {
+ if (rv == orxonox_cast<RadarViewable*>(this->getOwner()))
+ return false;
+ assert(rv->getWorldEntity());
+ if (rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() == false)
+ return false;
+ return true;
+ }
+
+ void WagnisHUD::changedOwner()
+ {
+ const std::set<RadarViewable*>& respawnObjects = this->getOwner()->getScene()->getRadar()->getRadarObjects();
+ for (RadarViewable* respawnObject : respawnObjects)
+ {
+ if (!respawnObject->isHumanShip_)
+ this->addObject(respawnObject);
+ }
+ }
+
+ Vector3 WagnisHUD::toAimPosition(RadarViewable* target) const
+ {
+ Vector3 wePosition = HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition();
+ Vector3 targetPosition = target->getRVWorldPosition();
+ Vector3 targetSpeed = target->getRVVelocity();
+
+ return getPredictedPosition(wePosition, this->currentMunitionSpeed_, targetPosition, targetSpeed);
+ }
+
+ void WagnisHUD::selectClosestTarget()
+ {
+ if(WagnisHUD::localHUD_s)
+ {
+ WagnisHUD::localHUD_s->closestTarget_ = true;
+ }
+ }
+
+ void WagnisHUD::selectNextTarget()
+ {
+ if(WagnisHUD::localHUD_s)
+ {
+ WagnisHUD::localHUD_s->nextTarget_ = true;
+ }
+ }
+}
Added: code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUD.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUD.h (rev 0)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisHUD.h 2018-12-05 08:26:18 UTC (rev 12136)
@@ -0,0 +1,168 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Felix Schulthess
+ * Co-authors:
+ * Reto Grieder
+ * Matthias Spalinger
+ *
+ */
+
+#ifndef _WagnisHUD_H__
+#define _WagnisHUD_H__
+
+#include "overlays/OverlaysPrereqs.h"
+
+#include <map>
+#include <string>
+
+#include "util/OgreForwardRefs.h"
+#include "tools/interfaces/Tickable.h"
+#include "interfaces/RadarListener.h"
+#include "overlays/OrxonoxOverlay.h"
+
+namespace orxonox
+{
+ class _OverlaysExport WagnisHUD : public OrxonoxOverlay, public Tickable, public RadarListener
+ {
+ public:
+ WagnisHUD(Context* context);
+ virtual ~WagnisHUD();
+
+ void setConfigValues();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void tick(float dt) override;
+
+ // RadarListener interface
+ virtual void addObject(RadarViewable* object) override;
+ virtual void removeObject(RadarViewable* viewable) override;
+ virtual void objectChanged(RadarViewable* viewable) override;
+
+ virtual void changedOwner() override;
+ virtual void sizeChanged() override;
+ virtual void angleChanged() override { }
+ virtual void positionChanged() override { }
+ virtual void radarTick(float dt) override {}
+
+ virtual inline float getRadarSensitivity() const override
+ { return 1.0f; }
+
+ inline unsigned int getMarkerLimit() const
+ { return this->markerLimit_; }
+
+ static void selectClosestTarget();
+ static void selectNextTarget();
+
+ private:
+ struct ObjectInfo
+ {
+
+
+
+ Ogre::PanelOverlayElement* health_;
+ Ogre::PanelOverlayElement* healthLevel_;
+ Ogre::PanelOverlayElement* panel_;
+ Ogre::PanelOverlayElement* target_;
+ Ogre::TextAreaOverlayElement* text_;
+ bool outOfView_;
+ bool wasOutOfView_;
+ bool selected_;
+ };
+
+ bool showObject(RadarViewable* rv);
+
+ // XMLPort accessors
+ inline void setHealthMarkerSize(float size)
+ {
+ this->healthMarkerSize_ = size;
+ this->sizeChanged();
+ }
+ inline float getHealthMarkerSize() const
+ { return healthMarkerSize_; }
+
+ inline void setHealthLevelMarkerSize(float size)
+ {
+ this->healthLevelMarkerSize_ = size;
+ this->sizeChanged();
+ }
+ inline float getHealthLevelMarkerSize() const
+ { return healthLevelMarkerSize_; }
+
+ inline void setNavMarkerSize(float size)
+ {
+ this->navMarkerSize_ = size;
+ this->sizeChanged();
+ }
+ inline float getNavMarkerSize() const
+ { return navMarkerSize_; }
+ inline void setAimMarkerSize(float size)
+ {
+ this->aimMarkerSize_ = size;
+ this->sizeChanged();
+ }
+
+ inline float getAimMarkerSize() const
+ { return aimMarkerSize_; }
+ inline void setDetectionLimit(float limit)
+ { this->detectionLimit_ = limit; }
+ inline float getDetectionLimit() const
+ { return this->detectionLimit_; }
+
+ void setTextSize(float size);
+ float getTextSize() const;
+
+ void setFont(const std::string& font);
+ const std::string& getFont() const;
+
+ float getArrowSizeX(int dist) const;
+ float getArrowSizeY(int dist) const;
+
+ Vector3 toAimPosition(RadarViewable* target) const;
+
+ std::map<RadarViewable*, ObjectInfo> activeObjectList_;
+ std::list<std::pair<RadarViewable*, unsigned int>> sortedObjectList_;
+
+ float healthMarkerSize_;
+ float healthLevelMarkerSize_;
+ float navMarkerSize_;
+ float aimMarkerSize_;
+ std::string fontName_;
+ float textSize_;
+ bool showDistance_;
+
+ RadarViewable* selectedTarget_;
+
+ bool closestTarget_;
+ bool nextTarget_;
+
+ static WagnisHUD* localHUD_s; //!< This is used as a filter. Only the local HUD should be influenced by the static Console Command functions.
+
+
+ float currentMunitionSpeed_;
+
+ unsigned int markerLimit_;
+ float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value.
+ };
+}
+
+#endif /* _WagnisHUD_H__ */
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.cc 2018-12-05 08:26:18 UTC (rev 12136)
@@ -30,8 +30,7 @@
SUPER(WagnisPlayer, tick, dt);
if(this->is_active)
- {
-
+ {
for(WagnisProvince* prov:this->gameBoard->provs){
//orxout()<<"province health: "<<prov->getHealth()<<endl;
if(prov->getHealth() < prov->getMaxHealth()){
@@ -75,18 +74,14 @@
case REINFORCEMENT_STAGE:
{
- int i = reinforcementCounter(); //i tells how many troops player gets
- while (i > 0)
+ if ( reinforcements > 0)
{
if (checkMove(SET_TROOPS))
{
this->target_province->setTroops(this->target_province->getTroops()+1);
orxout()<<"Province "<<this->target_province->getID()<<" owned by Player "<<this->target_province->getOwner_ID()<<" troops: "<<this->target_province->getTroops()<<endl;
- --i;
}
- }
-
- master->playerFinishedStageCallback(this);
+ }
break;
}
@@ -358,10 +353,11 @@
return b;
}
- int WagnisPlayer::reinforcementCounter() //calculates how many troops a player gets at beginning of his turn
+ int WagnisPlayer::reinforcementCounter() //calculates and sets reeinforcements how many troops a player gets at beginning of his turn
{
- return 10;
+ reinforcements = 10;
+ orxout()<<"derp"<<endl;
/*
int counter = 0;
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisPlayer.h 2018-12-05 08:26:18 UTC (rev 12136)
@@ -46,6 +46,7 @@
WagnisGameboard* gameBoard;
WagnisProvince* origin_province;
WagnisProvince* target_province;
+ int reinforcements;
bool isNeighbour(WagnisProvince*, WagnisProvince*);
bool existPath(WagnisProvince*, WagnisProvince*);
int dice();
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.cc 2018-12-05 08:26:18 UTC (rev 12136)
@@ -20,6 +20,7 @@
this->owner_ID = -1;
this->troops = 0;
this->setRadarName(std::to_string(0));
+ this->setRadarObjectColour(colour({128,128,128}, 100.0f));
this->ID = -1;
this->continent = -1;
this->neighbors = std::vector<WagnisProvince*>();
@@ -49,6 +50,27 @@
//set owner_ID
void WagnisProvince::setOwner_ID(int owner){
this->owner_ID = owner;
+ switch(owner){
+ case 1: this->setRadarObjectColour( colour({255,0,0}, 100.0f) );
+ break;
+ case 2: this->setRadarObjectColour( colour({0,255,0}, 100.0f) );
+ break;
+ case 3: this->setRadarObjectColour( colour({0,0,255}, 100.0f) );
+ break;
+ case 4: this->setRadarObjectColour( colour({255,255,0}, 100.0f) );
+ break;
+ case 5: this->setRadarObjectColour( colour({255,0,255}, 100.0f) );
+ break;
+ case 6: this->setRadarObjectColour( colour({128,128,0}, 40.0f) );
+ break;
+ case 7: this->setRadarObjectColour( colour({0,255,255}, 100.0f) );
+ break;
+ case 8: this->setRadarObjectColour( colour({153,255,204}, 100.0f) );
+ break;
+ case 9: this->setRadarObjectColour( colour({102,51,0}, 100.0f) );
+ break;
+ }
+
}
//set troops
void WagnisProvince::setTroops(int troops){
Modified: code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h
===================================================================
--- code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/src/modules/wagnis/WagnisProvince.h 2018-12-05 08:26:18 UTC (rev 12136)
@@ -41,12 +41,12 @@
std::vector<WagnisProvince*> neighbors;
- int owner_ID;
int ID;
int continent;
private:
int troops;
+ int owner_ID;
};
}
Modified: code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.cc 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/src/modules/weapons/projectiles/WagnisProjectile.cc 2018-12-05 08:26:18 UTC (rev 12136)
@@ -49,7 +49,7 @@
// Create a sphere collision shape and attach it to the projectile.
collisionShape_ = new SphereCollisionShape(this->getContext());
- setCollisionShapeRadius(2.0f);
+ setCollisionShapeRadius(3.0f);
this->attachCollisionShape(collisionShape_);
this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this)));
Modified: code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.cc
===================================================================
--- code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.cc 2018-12-04 12:56:55 UTC (rev 12135)
+++ code/branches/wagnis_HS18/src/modules/weapons/weaponmodes/WagnisGun.cc 2018-12-05 08:26:18 UTC (rev 12136)
@@ -50,7 +50,7 @@
this->reloadTime_ = 0.1f;
this->damage_ = 0.0f; //default 15
- this->speed_ = 1000.0f;
+ this->speed_ = 800.0f;
this->delay_ = 0.0f;
this->setMunitionName("LaserMunition");
More information about the Orxonox-commit
mailing list