[Orxonox-commit 5480] r10143 - code/branches/hudHS14/src/modules/overlays/hud
aejonas at orxonox.net
aejonas at orxonox.net
Wed Nov 26 17:18:44 CET 2014
Author: aejonas
Date: 2014-11-26 17:18:44 +0100 (Wed, 26 Nov 2014)
New Revision: 10143
Modified:
code/branches/hudHS14/src/modules/overlays/hud/HUDEnemyHealthBar.cc
code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc
Log:
acces to GetHealth in HUDNavigation for scaling the healthbar
Modified: code/branches/hudHS14/src/modules/overlays/hud/HUDEnemyHealthBar.cc
===================================================================
--- code/branches/hudHS14/src/modules/overlays/hud/HUDEnemyHealthBar.cc 2014-11-26 16:14:33 UTC (rev 10142)
+++ code/branches/hudHS14/src/modules/overlays/hud/HUDEnemyHealthBar.cc 2014-11-26 16:18:44 UTC (rev 10143)
@@ -59,9 +59,8 @@
-
/*
- //--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
//first try to place a healthbar under the enemy ship
//getting all the parameters (direction, position, angle) to place the health bar on the screen
@@ -95,17 +94,12 @@
this->setPosition(screenCoordinates);
this->setTextOffset(screenCoordinates);
-
-
-
-
-
}
-
//--------------------------------------------------------------------------
*/
+
SUPER(HUDEnemyHealthBar, tick, dt);
}
@@ -122,13 +116,6 @@
pawn = orxonox_cast<Pawn*>(target);
-
- /*Vector3 tempPosition = target->getWorldPosition();
- Vector2 tempPos2D = Vector2(tempPosition.x, tempPosition.y);
- this->pickPoint_(tempPos2D);
- this->position_(tempPos2D);*/
-
-
// Don't show the HealthBar if the pawn is invisible
if (pawn && !pawn->isVisible())
pawn = NULL;
Modified: code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc 2014-11-26 16:14:33 UTC (rev 10142)
+++ code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc 2014-11-26 16:18:44 UTC (rev 10143)
@@ -368,6 +368,7 @@
+
// Change material only if outOfView changed
if (it->second.wasOutOfView_)
{
@@ -376,22 +377,27 @@
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);
- //manipulation bzw versuch !!! Jonas
+ //
it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2.png", it->first->getRadarObjectColour()));
- it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x, this->healthMarkerSize_ * this->getActualSize().y);
-
+ it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , this->healthMarkerSize_ * this->getActualSize().y);
it->second.wasOutOfView_ = false;
}
- //i need to find the place where the amount of health is saved!!!
- //this->selectedTarget_->getWorldEntity()->
+ //calculate the health of the actual selected radarViewable (while (0) is no health left, (1) is the initial health)
+ Pawn* pawnPtr = (Pawn*) (it->first->getWorldEntity());
+ float health = pawnPtr->getHealth();
+ float initHealth = pawnPtr->getMaxHealth();
+ float relativHealthScale = health/initHealth;
- // Position health (versuch !!!!)
+
+ // Position and Dimensions (amount) health
it->second.health_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
- it->second.health_->setLeft((pos.x + 1.0f - it->second.panel_->getWidth()) * 0.5f);
- it->second.health_->setTop((-pos.y + 1.0f - it->second.panel_->getHeight()) * 0.5f);
+ it->second.health_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
+ it->second.health_->setTop((-pos.y + 1.025f - it->second.panel_->getHeight()) * 0.5f);
+ it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x * relativHealthScale, this->healthMarkerSize_ * this->getActualSize().y);
+ orxout() << relativHealthScale << endl;
// Position marker
More information about the Orxonox-commit
mailing list