Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2015, 2:45:58 PM (8 years ago)
Author:
maxima
Message:

Merged presentation and fabiens branch. Had to modify hoverHUD and invaderHUD, because the text of the healthbar wasn't correctly displayed and the weapon settings of the hovership.

Location:
code/branches/presentationHS15
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentationHS15

  • code/branches/presentationHS15/src/orxonox/worldentities/pawns/Pawn.cc

    r10650 r10961  
    4646#include "weaponsystem/WeaponPack.h"
    4747#include "weaponsystem/WeaponSet.h"
     48#include "weaponsystem/Munition.h"
    4849#include "sound/WorldSound.h"
    4950
     
    6162
    6263        this->bAlive_ = true;
    63         this->bReload_ = false;
    6464
    6565        this->health_ = 0;
     
    7171        this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max
    7272        this->shieldAbsorption_ = 0.5;
    73 
    74         this->reloadRate_ = 0;
    75         this->reloadWaitTime_ = 1.0f;
    76         this->reloadWaitCountdown_ = 0;
     73        this->shieldRechargeRate_ = 0;
     74        this->shieldRechargeWaitTime_ = 1.0f;
     75        this->shieldRechargeWaitCountdown_ = 0;
    7776
    7877        this->lastHitOriginator_ = 0;
     
    141140        XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
    142141        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
    143         XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
    144 
    145         XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
    146         XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
     142        XMLPortObject(Pawn, WeaponPack, "weaponpacks", addWeaponPackXML, getWeaponPack, xmlelement, mode);
     143        XMLPortObject(Pawn, Munition, "munition", addMunitionXML, getMunitionXML, xmlelement, mode);
     144
     145        XMLPortParam(Pawn, "shieldrechargerate", setShieldRechargeRate, getShieldRechargeRate, xmlelement, mode).defaultValues(0);
     146        XMLPortParam(Pawn, "shieldrechargewaittime", setShieldRechargeWaitTime, getShieldRechargeWaitTime, xmlelement, mode).defaultValues(1.0f);
    147147
    148148        XMLPortParam(Pawn, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
     
    153153    void Pawn::registerVariables()
    154154    {
    155         registerVariable(this->bAlive_,           VariableDirection::ToClient);
    156         registerVariable(this->health_,           VariableDirection::ToClient);
    157         registerVariable(this->maxHealth_,        VariableDirection::ToClient);
    158         registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
    159         registerVariable(this->maxShieldHealth_,  VariableDirection::ToClient);
    160         registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
    161         registerVariable(this->bReload_,          VariableDirection::ToServer);
    162         registerVariable(this->aimPosition_,      VariableDirection::ToServer);  // For the moment this variable gets only transfered to the server
     155        registerVariable(this->bAlive_,            VariableDirection::ToClient);
     156        registerVariable(this->health_,            VariableDirection::ToClient);
     157        registerVariable(this->maxHealth_,         VariableDirection::ToClient);
     158        registerVariable(this->shieldHealth_,      VariableDirection::ToClient);
     159        registerVariable(this->maxShieldHealth_,   VariableDirection::ToClient);
     160        registerVariable(this->shieldAbsorption_,  VariableDirection::ToClient);
     161        registerVariable(this->aimPosition_,       VariableDirection::ToServer);  // For the moment this variable gets only transfered to the server
    163162    }
    164163
     
    167166        SUPER(Pawn, tick, dt);
    168167
    169         this->bReload_ = false;
    170 
     168        // Recharge the shield
    171169        // TODO: use the existing timer functions instead
    172         if(this->reloadWaitCountdown_ > 0)
    173         {
    174             this->decreaseReloadCountdownTime(dt);
    175         }
    176         else
    177         {
    178             this->addShieldHealth(this->getReloadRate() * dt);
    179             this->resetReloadCountdown();
     170        if(this->shieldRechargeWaitCountdown_ > 0)
     171        {
     172            this->decreaseShieldRechargeCountdownTime(dt);
     173        }
     174        else
     175        {
     176            this->addShieldHealth(this->getShieldRechargeRate() * dt);
     177            this->resetShieldRechargeCountdown();
    180178        }
    181179
     
    229227    }
    230228
    231     void Pawn::setReloadRate(float reloadrate)
    232     {
    233         this->reloadRate_ = reloadrate;
    234     }
    235 
    236     void Pawn::setReloadWaitTime(float reloadwaittime)
    237     {
    238         this->reloadWaitTime_ = reloadwaittime;
    239     }
    240 
    241     void Pawn::decreaseReloadCountdownTime(float dt)
    242     {
    243         this->reloadWaitCountdown_ -= dt;
     229    void Pawn::setShieldRechargeRate(float shieldRechargeRate)
     230    {
     231        this->shieldRechargeRate_ = shieldRechargeRate;
     232    }
     233
     234    void Pawn::setShieldRechargeWaitTime(float shieldRechargeWaitTime)
     235    {
     236        this->shieldRechargeWaitTime_ = shieldRechargeWaitTime;
     237    }
     238
     239    void Pawn::decreaseShieldRechargeCountdownTime(float dt)
     240    {
     241        this->shieldRechargeWaitCountdown_ -= dt;
    244242    }
    245243
     
    252250        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
    253251        {
     252            // Health-damage cannot be absorbed by shields.
     253            // Shield-damage only reduces shield health.
     254            // Normal damage can be (partially) absorbed by shields.
     255
    254256            if (shielddamage >= this->getShieldHealth())
    255257            {
     
    480482    }
    481483
    482     void Pawn::reload()
    483     {
    484         this->bReload_ = true;
    485     }
    486 
    487484    void Pawn::postSpawn()
    488485    {
     
    554551    }
    555552
     553    std::vector<WeaponPack *> * Pawn::getAllWeaponPacks()
     554    {
     555        if (this->weaponSystem_)
     556            return this->weaponSystem_->getAllWeaponPacks();
     557        else
     558            return 0;       
     559    }
     560
     561    void Pawn::addMunitionXML(Munition* munition)
     562    {
     563        if (this->weaponSystem_ && munition)
     564        {
     565            this->weaponSystem_->addMunition(munition);
     566        }
     567    }
     568
     569    Munition* Pawn::getMunitionXML() const
     570    {
     571        return NULL;
     572    }
     573
     574    Munition* Pawn::getMunition(SubclassIdentifier<Munition> * identifier)
     575    {
     576        if (weaponSystem_)
     577        {
     578            return weaponSystem_->getMunition(identifier);
     579        }
     580
     581        return NULL;
     582    }
     583
    556584    //Tell the Map (RadarViewable), if this is a playership
    557585    void Pawn::startLocalHumanControl()
    558586    {
    559 //        SUPER(ControllableEntity, changedPlayer());
     587//        SUPER(ControllableEntity, startLocalHumanControl());
    560588        ControllableEntity::startLocalHumanControl();
    561589        this->isHumanShip_ = true;
Note: See TracChangeset for help on using the changeset viewer.