Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10143


Ignore:
Timestamp:
Nov 26, 2014, 5:18:44 PM (10 years ago)
Author:
aejonas
Message:

acces to GetHealth in HUDNavigation for scaling the healthbar

Location:
code/branches/hudHS14/src/modules/overlays/hud
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hudHS14/src/modules/overlays/hud/HUDEnemyHealthBar.cc

    r10110 r10143  
    6060
    6161
    62 
    6362/*
    64         //--------------------------------------------------------------------------
     63//--------------------------------------------------------------------------
    6564        //first try to place a healthbar under the enemy ship
    6665        //getting all the parameters (direction, position, angle) to place the health bar on the screen
     
    9695
    9796        this->setTextOffset(screenCoordinates);
    98 
    99 
    100 
    101 
    102 
    10397        }
    104 
    10598        //--------------------------------------------------------------------------
    10699*/
     100
    107101
    108102
     
    121115                target = target->getParent();
    122116            pawn = orxonox_cast<Pawn*>(target);
    123 
    124 
    125 
    126             /*Vector3 tempPosition = target->getWorldPosition();
    127             Vector2 tempPos2D = Vector2(tempPosition.x, tempPosition.y);
    128                      this->pickPoint_(tempPos2D);
    129                      this->position_(tempPos2D);*/
    130117
    131118
  • code/branches/hudHS14/src/modules/overlays/hud/HUDNavigation.cc

    r10122 r10143  
    369369
    370370
     371
    371372                        // Change material only if outOfView changed
    372373                    if (it->second.wasOutOfView_)
     
    377378                        it->second.target_->setDimensions(this->aimMarkerSize_ * this->getActualSize().x, this->aimMarkerSize_ * this->getActualSize().y);
    378379
    379                         //manipulation bzw versuch !!! Jonas
     380                        //
    380381                        it->second.health_->setMaterialName(TextureGenerator::getMaterialName("bar2.png", it->first->getRadarObjectColour()));
    381                         it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x, this->healthMarkerSize_ * this->getActualSize().y);
    382 
     382                        it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x , this->healthMarkerSize_ * this->getActualSize().y);
    383383                        it->second.wasOutOfView_ = false;
    384384                    }
    385385
    386386
    387                     //i need to find the place where the amount of health is saved!!!
    388                     //this->selectedTarget_->getWorldEntity()->
    389 
    390 
    391                     // Position health (versuch !!!!)
     387                    //calculate the health of the actual selected radarViewable (while (0) is no health left, (1) is the initial health)
     388
     389                    Pawn* pawnPtr = (Pawn*) (it->first->getWorldEntity());
     390                    float health = pawnPtr->getHealth();
     391                    float initHealth = pawnPtr->getMaxHealth();
     392                    float relativHealthScale = health/initHealth;
     393
     394
     395                    // Position and Dimensions (amount) health
    392396                    it->second.health_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
    393                     it->second.health_->setLeft((pos.x + 1.0f - it->second.panel_->getWidth()) * 0.5f);
    394                     it->second.health_->setTop((-pos.y + 1.0f - it->second.panel_->getHeight()) * 0.5f);
     397                    it->second.health_->setLeft((pos.x + 0.975f - it->second.panel_->getWidth()) * 0.5f);
     398                    it->second.health_->setTop((-pos.y + 1.025f - it->second.panel_->getHeight()) * 0.5f);
     399                    it->second.health_->setDimensions(this->healthMarkerSize_ * this->getActualSize().x * relativHealthScale, this->healthMarkerSize_ * this->getActualSize().y);
     400                    orxout() << relativHealthScale << endl;
    395401
    396402
Note: See TracChangeset for help on using the changeset viewer.