Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10739


Ignore:
Timestamp:
Nov 1, 2015, 1:05:54 PM (8 years ago)
Author:
fvultier
Message:

HUD improved. Corrected text rescaling. Renamed reload to shieldRecharge in Pawn.cc, … to avoid confusion with the weapon system.

Location:
code/branches/fabienHS15
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • code/branches/fabienHS15/data/gui/layouts/InGameMenu.layout

    r7801 r10739  
    99            <Property Name="Text" Value="Return to Game" />
    1010            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    11             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.3625,0},{0.6,0},{0.4125,0}}" />
     11            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.2875,0},{0.6,0},{0.3375,0}}" />
    1212            <Property Name="Alpha" Value="0.9" />
    1313            <Event Name="Clicked" Function="InGameMenu.button_return_clicked"/>
    1414        </Window>
     15        <Window Type="MenuWidgets/Button" Name="orxonox/InGameMenu_ReloadLevelButton" >
     16            <Property Name="Text" Value="Reload level" />
     17            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     18            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.3625,0},{0.6,0},{0.4125,0}}" />
     19            <Property Name="Alpha" Value="0.9" />
     20            <Event Name="Clicked" Function="InGameMenu.button_reloadLevel_clicked"/>
     21        </Window>       
    1522        <Window Type="MenuWidgets/Button" Name="orxonox/InGameMenu_MainMenuButton" >
    1623            <Property Name="Text" Value="Main Menu" />
    1724            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    18             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.4625,0},{0.6,0},{0.5125,0}}" />
     25            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.4375,0},{0.6,0},{0.4875,0}}" />
    1926            <Property Name="Alpha" Value="0.9" />
    2027            <Event Name="Clicked" Function="InGameMenu.button_mainmenu_clicked"/>
     
    2330            <Property Name="Text" Value="Settings" />
    2431            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    25             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5625,0},{0.6,0},{0.6125,0}}" />
     32            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5125,0},{0.6,0},{0.5625,0}}" />
    2633            <Property Name="Alpha" Value="0.9" />
    2734            <Event Name="Clicked" Function="InGameMenu.button_settings_clicked"/>
     
    3037            <Property Name="Text" Value="Quit" />
    3138            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    32             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
     39            <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.5875,0},{0.6,0},{0.6375,0}}" />
    3340            <Property Name="Alpha" Value="0.9" />
    3441            <Event Name="Clicked" Function="InGameMenu.button_quit_clicked"/>
  • code/branches/fabienHS15/data/gui/scripts/InGameMenu.lua

    r9016 r10739  
    77    P.multiplayerMode = "startClient"
    88
    9     --button are arranged in a 4x1 matrix, the left lower item is nil
     9    --button are arranged in a 5x1 matrix, the left lower item is nil
    1010    P:setButton(1, 1, {
    1111            ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReturnButton"),
     
    1414
    1515    P:setButton(2, 1, {
     16            ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReloadLevelButton"),
     17            ["callback"]  = P.button_reloadLevel_clicked
     18    })
     19
     20    P:setButton(3, 1, {
    1621            ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"),
    1722            ["callback"]  = P.button_mainmenu_clicked
    1823    })
    1924
    20     P:setButton(3, 1, {
     25    P:setButton(4, 1, {
    2126            ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"),
    2227            ["callback"]  = P.button_settings_clicked
    2328    })
    2429
    25     P:setButton(4, 1, {
     30    P:setButton(5, 1, {
    2631            ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"),
    2732            ["callback"]  = P.button_quit_clicked
     
    5459end
    5560
     61function P.button_reloadLevel_clicked(e)
     62    hideMenuSheet("InGameMenu")
     63    orxonox.execute("reloadLevel")
     64end
     65
    5666function P.button_return_clicked(e)
    5767    hideMenuSheet("InGameMenu")
  • code/branches/fabienHS15/data/overlays/HUDTemplates3.oxo

    r10724 r10739  
    3434     name              = "HealthBar1"
    3535     background        = "Orxonox/HealthBarBackground"
    36      size              = "0.35, 0.0875"
     36     size              = "0.40, 0.08"
    3737     position          = "0.0 , 0.9 "
    3838     pickpoint         = "0, 1"
     
    4040     textfont          = "VeraMono"
    4141     textusebarcolour  = true
    42      textsize          = 0.039
    43      textoffset        = "0.315, 0.05"
     42     textscale          = 0.4
     43     textoffset        = "0.325, -0.825"
    4444     textpickpoint     = "0, 0"
    4545     textalign         = "right"
    46      correctaspect     = false
    47      textcorrectaspect = false
     46     correctaspect     = true
     47     iconmaterial      = "Orxonox/BarIconHealth"
    4848    >
    4949      <BarColour position = 0.0 colour = "0.7,0.2,0.2" />
     
    5555     name          = "SpeedBar1"
    5656     background    = "Orxonox/BarBackground"
    57      size          = "0.35, 0.05"
     57     size          = "0.40, 0.04"
    5858     position      = "0.0 , 0.95 "
    5959     pickpoint     = "0, 1"
    60      correctaspect = false
     60     correctaspect = true
     61     iconmaterial  = "Orxonox/BarIconSpeed"
    6162    >
    6263      <BarColour position = 0.0 colour = "0.7,0.5,0.2" />
     
    6768    <HUDBoostBar
    6869     name          = "BoostBar1"
    69      backgroundtex = "bar1.png"
    70      size          = "0.35, 0.05"
     70     background    = "Orxonox/BarBackground"
     71     size          = "0.40, 0.04"
    7172     position      = "0.0 , 1.0 "
    7273     pickpoint     = "0, 1"
    73      correctaspect = false
     74     correctaspect = true
     75     iconmaterial  = "Orxonox/BarIconBoost"
    7476    >
    7577      <BarColour position = 0.0 colour = "0.7,0.2,0.2" />
     
    8183     name              = "EnemyHealthBar"
    8284     background        = "Orxonox/HealthBarBackground"
    83      size              = "0.35, 0.0875"
    84      position          = "1 ,0.1"
    85      pickpoint         = "1, 1"
     85     size              = "0.4, 0.08"
     86     position          = "1 ,0"
     87     pickpoint         = "1, 0"
    8688     bartexture        = "healthbar_bar.png"
    8789     textfont          = "VeraMono"
    8890     textusebarcolour  = true
    89      textsize          = 0.039
    90      textoffset        = "0.315, 0.05"
     91     textscale         = 0.4
     92     textoffset        = "-0.675, 0.175"
    9193     textpickpoint     = "0, 0"
    9294     textalign         = "right"
    93      correctaspect     = false
    94      textcorrectaspect = false
     95     correctaspect     = true
     96     iconmaterial      = "Orxonox/BarIconHealth"
    9597    >
    9698      <BarColour position = 0.0 colour = "0.7,0.2,0.2" />
     
    131133     name                   = "WeaponSystem"
    132134     correctaspect          = true
    133      position               = "0.0, 0.0"
     135     position               = "0.01, 0.01"
    134136     pickpoint              = "0, 0"
    135137     visible                = "true"
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDBar.cc

    r9667 r10739  
    4747    RegisterClass(BarColour);
    4848
    49     BarColour::BarColour(Context* context)
    50         : BaseObject(context)
     49    BarColour::BarColour(Context* context) : BaseObject(context)
    5150    {
    5251        RegisterObject(BarColour);
    53 
     52       
    5453        this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
    5554        this->setPosition(0.0);
     
    6968    RegisterClass(HUDBar);
    7069
    71     HUDBar::HUDBar(Context* context)
    72         : OrxonoxOverlay(context), right2Left_(false), autoColour_(false)
     70    HUDBar::HUDBar(Context* context) : OrxonoxOverlay(context), right2Left_(false), autoColour_(false)
    7371    {
    7472        RegisterObject(HUDBar);
     
    8886        this->bar_->setMaterialName(materialname);
    8987
     88        this->bar_->setPosition(0.0f,0.0f);
     89        this->bar_->setDimensions(1.0f,1.0f);
     90
     91        this->bUseIcon_ = false;
    9092        this->value_ = 1.0f;  // initialize with 1.0f to trigger a change when calling setValue(0.0f) on the line below
    9193        this->setAutoColour(true);
     
    9597
    9698        this->background_->addChild(bar_);
     99
     100        this->icon_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDBar_icon_" + getUniqueNumberString()));
     101        this->icon_->setPosition(0.06f,0.0f);
     102        this->icon_->setDimensions(0.1f,1.0f);
     103        this->background_->addChild(this->icon_);
    97104    }
    98105
     
    115122        XMLPortParam(HUDBar, "autocolour",   setAutoColour,  getAutoColour,  xmlelement, mode);
    116123        XMLPortParam(HUDBar, "bartexture",   setBarTexture,  getBarTexture, xmlelement, mode);
     124        XMLPortParam(HUDBar, "iconmaterial", setIconMaterial, getIconMaterial, xmlelement, mode);
    117125        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlelement, mode);
    118126    }
     
    161169        }
    162170
     171        float height = this->bar_->getHeight();
     172        float top = this->bar_->getTop();
     173
    163174        // set value
    164175        if (this->right2Left_)
    165176        {
    166177            // backward case
    167             this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), 0.0f);
    168             this->bar_->setDimensions(0.88f * this->value_, 1.0f);
     178            if (this->bUseIcon_)
     179            {
     180                this->bar_->setPosition(0.16f + 0.78f * (1 - this->value_), top);
     181                this->bar_->setDimensions(0.78f * this->value_, height);
     182            }
     183            else
     184            {
     185                this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), top);
     186                this->bar_->setDimensions(0.88f * this->value_, height);
     187            }
    169188        }
    170189        else
    171190        {
    172191            // default case
    173             this->bar_->setPosition(0.06f, 0.0f);
    174             this->bar_->setDimensions(0.88f * this->value_, 1.0f);
    175         }
     192            if (this->bUseIcon_)
     193            {
     194                this->bar_->setPosition(0.16f, top);
     195                this->bar_->setDimensions(0.78f * this->value_, height);
     196            }
     197            else
     198            {
     199                this->bar_->setPosition(0.06f, top);
     200                this->bar_->setDimensions(0.88f * this->value_, height);
     201            }
     202        }
     203
    176204        if (this->value_ != 0)
    177205            this->bar_->setTiling(this->value_, 1.0);
     
    208236        return this->textureUnitState_->getTextureName();
    209237    }
     238
     239    void HUDBar::setIconMaterial(const std::string& iconMaterial)
     240    {
     241        this->bUseIcon_ = true;
     242        this->icon_->setMaterialName(iconMaterial);
     243        valueChanged();
     244    }
     245
     246    const std::string& HUDBar::getIconMaterial() const
     247    {
     248        return this->icon_->getMaterialName();
     249    }
    210250}
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDBar.h

    r9667 r10739  
    3737#include <map>
    3838#include <vector>
     39#include <OgrePanelOverlayElement.h>
    3940
    4041#include "util/Math.h"
     
    5152        virtual ~BarColour() { }
    5253
    53         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     54        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);     
    5455
    5556        void setColour(const ColourValue& colour) { this->colour_ = colour; }
     
    115116        const std::string& getBarTexture() const;
    116117
     118        void setIconMaterial(const std::string& iconMaterial);
     119        const std::string& getIconMaterial() const;
     120
    117121        inline const ColourValue& getCurrentBarColour() const
    118122            { return this->currentColour_; }
    119123
     124        inline void setIconPosition(Vector2 position)
     125            { this->icon_->setPosition(position.x, position.y); }
     126        inline void setIconDimensions(Vector2 dimensions)
     127            { this->icon_->setDimensions(dimensions.x, dimensions.y); }
     128
    120129    protected:
    121130        virtual void valueChanged();
    122 
    123131    private:
    124132        void addColour(BarColour* colour);
     
    129137        float value_;                       //!< progress of bar
    130138        ColourValue currentColour_;
     139        bool bUseIcon_;
    131140
    132141        Ogre::PanelOverlayElement* bar_;
    133142        Ogre::TextureUnitState* textureUnitState_;
     143        Ogre::PanelOverlayElement* icon_;
    134144        std::map<float, ColourValue> colours_;
    135145        std::vector<BarColour*> barColours_;
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDBoostBar.cc

    r9667 r10739  
    5959            if (this->owner_->isBoostCoolingDown())
    6060            {
    61                 this->setBackgroundColour(ColourValue(0.7f, 0.2f, 0.2f));
     61                //this->setBackgroundColour(ColourValue(0.7f, 0.2f, 0.2f));
    6262                if (this->flashDt_ <= 0.0f)
    6363                {
     
    7272                this->flashDt_ = 0.0f;
    7373                this->show();
    74                 this->setBackgroundColour(ColourValue(0.2f, 0.7f, 0.2f));
     74                //this->setBackgroundColour(ColourValue(0.2f, 0.7f, 0.2f));
    7575            }
    7676
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDHealthBar.cc

    r9667 r10739  
    4545        this->owner_ = 0;
    4646        this->bUseBarColour_ = false;
     47        this->textOffset_ = Vector2(0.0f, 0.0f);
     48        this->textScale_ = 1.0f;
     49
     50        this->setIconPosition(Vector2(0.05f,0.5f));
     51        this->setIconDimensions(Vector2(0.1f,0.5f));
    4752
    4853        this->textoverlay_ = new OverlayText(this->getContext());
     
    5156
    5257        this->textoverlay_->setCaption("");
     58        this->textoverlay_->setAspectCorrection(false);
     59
     60        positionText();
    5361    }
    5462
     
    5866        {
    5967            this->textoverlay_->destroy();
    60             this->textoverlay_ = 0;
     68            this->textoverlay_ = NULL;
    6169        }
    6270    }
     
    7078        XMLPortParam(HUDHealthBar, "textusebarcolour",  setTextUseBarColour,     getTextUseBarColour,     xmlelement, mode).defaultValues(false);
    7179        XMLPortParam(HUDHealthBar, "textcolour",        setTextColour,           getTextColour,           xmlelement, mode).defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
    72         XMLPortParam(HUDHealthBar, "textsize",          setTextSize,             getTextSize,             xmlelement, mode).defaultValues(1.0f);
    7380        XMLPortParam(HUDHealthBar, "textalign",         setTextAlignmentString,  getTextAlignmentString,  xmlelement, mode).defaultValues("left");
    7481        XMLPortParam(HUDHealthBar, "textoffset",        setTextOffset,           getTextOffset,           xmlelement, mode).defaultValues(Vector2::ZERO);
     82        XMLPortParam(HUDHealthBar, "textscale",         setTextScale,            getTextScale,            xmlelement, mode).defaultValues(1.0f);
    7583        XMLPortParam(HUDHealthBar, "textpickpoint",     setTextPickPoint,        getTextPickPoint,        xmlelement, mode).defaultValues(Vector2::ZERO);
    7684        XMLPortParam(HUDHealthBar, "textrotation",      setTextRotation,         getTextRotation,         xmlelement, mode).defaultValues(0.0f);
    77         XMLPortParam(HUDHealthBar, "textcorrectaspect", setTextAspectCorrection, getTextAspectCorrection, xmlelement, mode).defaultValues(true);
    7885        XMLPortParam(HUDHealthBar, "textspacewidth",    setTextSpaceWidth,       getTextSpaceWidth,       xmlelement, mode).defaultValues(true);
    7986    }
     
    139146            this->textoverlay_->setColour(this->textColour_);
    140147    }
     148
     149    void HUDHealthBar::positionText()
     150    {
     151        this->textoverlay_->setPosition(this->getPosition() + this->textOffset_*this->getActualSize());
     152        this->textoverlay_->setTextSize(this->getActualSize().y*this->textScale_);
     153    }
     154
     155    void HUDHealthBar::positionChanged()
     156    {
     157        HUDBar::positionChanged();
     158        positionText();
     159    }
     160
     161    void HUDHealthBar::sizeChanged()
     162    {
     163        HUDBar::sizeChanged();
     164        positionText();
     165    }   
    141166}
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDHealthBar.h

    r10624 r10739  
    7575                { return this->textoverlay_->getAlignmentString(); }
    7676
    77             inline void setTextSize(float size)
    78                 { this->textoverlay_->setTextSize(size); }
    79             inline float getTextSize() const
    80                 { return this->textoverlay_->getTextSize(); }
    81 
    8277            inline void setTextVisible(bool bVisible)
    8378                { this->textoverlay_->setVisible(bVisible); }
    8479            inline bool getTextVisible() const
    8580                { return this->textoverlay_->isVisible(); }
     81
     82            inline void setTextScale(float scale)
     83                { this->textScale_ = scale;
     84                  positionText();
     85                }
     86            inline float getTextScale() const
     87                { return this->textScale_; }
    8688
    8789            inline void setTextPickPoint(const Vector2& pickpoint)
     
    9193
    9294            inline void setTextOffset(const Vector2& position)
    93                 { this->textoverlay_->setPosition(this->getPosition() + (position - this->getPickPoint()) * this->getSize()); }
     95                { this->textOffset_ = position;
     96                  this->positionText();
     97                }
    9498            inline Vector2 getTextOffset() const
    95                 { return (this->textoverlay_->getPosition() - this->getPosition()) / this->getSize() + this->getPickPoint(); }
    96 
    97             inline void setTextAspectCorrection(bool correct)
    98                 { this->textoverlay_->setAspectCorrection(correct); }
    99             inline bool getTextAspectCorrection() const
    100                 { return this->textoverlay_->getAspectCorrection(); }
     99                { return this->textOffset_; }
    101100
    102101            inline void setTextRotation(const Degree& angle)
     
    112111            inline void setHealthBarOwner(Pawn* owner)
    113112                { this->owner_ = owner; }
    114 
     113        protected:
     114            virtual void positionChanged();
     115            virtual void sizeChanged();
    115116        private:
     117            virtual void positionText();
    116118            WeakPtr<Pawn> owner_;
    117119            StrongPtr<OverlayText> textoverlay_;
    118120            bool bUseBarColour_;
    119121            ColourValue textColour_;
     122            Vector2 textOffset_;
     123            float textScale_;
    120124    };
    121125}
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.cc

    r10724 r10739  
    6060        {
    6161            destroyHUDChilds();
    62             //this->overlayElement_->destroy();           
    6362        }
    6463    }
     
    179178        for (std::vector<WeakPtr<HUDWeaponMode> >::iterator it = hudWeaponModes_.begin(); it != hudWeaponModes_.end(); ++it)
    180179        {
     180            (*it)->setPositionOffset(this->positionOffset_);
    181181            (*it)->setWeaponModeIndex(positionIndex);
    182182            (*it)->setWeaponIndex(this->weaponIndex_);
     
    210210        if (weaponModes_ != NULL)
    211211        {
    212             this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f));
     212            this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f) + this->positionOffset_);
    213213        }       
    214214    }       
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.h

    r10724 r10739  
    7272        inline Vector2 getWeaponModeHUDActualSize() const
    7373            { return weaponModeHUDActualSize_; }
     74        inline void setPositionOffset(Vector2 positionOffset)
     75            {
     76                this->positionOffset_ = positionOffset;
     77                this->updatePosition();
     78            }           
    7479        inline void setWeaponIndex(int index)
    75             { weaponIndex_ = index;
    76               this->updatePosition();
     80            {
     81                weaponIndex_ = index;
     82                this->updatePosition();
    7783            }       
    7884
     
    94100
    95101        Vector2 weaponModeHUDActualSize_;
     102        Vector2 positionOffset_;
    96103        int weaponIndex_;
    97104    };
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.cc

    r10724 r10739  
    102102        if (this->isInitialized())
    103103        {
    104             //this->textOverlay_->destroy();
     104            this->textOverlayLeft_->destroy();
     105            this->textOverlayRight_->destroy();
    105106        }
    106107    }
     
    280281    void HUDWeaponMode::updatePosition()
    281282    {
    282         this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,weaponModeHUDActualSize_.y*weaponModeIndex_));
     283        this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,weaponModeHUDActualSize_.y*weaponModeIndex_) + this->positionOffset_);
    283284    }     
    284285}
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.h

    r10724 r10739  
    8282              this->updatePosition();
    8383            }
     84        inline void setPositionOffset(Vector2 positionOffset)
     85            {
     86                this->positionOffset_ = positionOffset;
     87                this->updatePosition();
     88            }
    8489
    8590    private:
     
    102107
    103108        Vector2 weaponModeHUDActualSize_;
     109        Vector2 positionOffset_;
    104110        int weaponIndex_;
    105111        int weaponModeIndex_;
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponSystem.cc

    r10724 r10739  
    156156    {
    157157        int positionIndex = 0;
     158        Vector2 offset = this->getPosition();
    158159
    159160        for (std::vector<WeakPtr<HUDWeapon> >::iterator it = hudWeapons_.begin(); it != hudWeapons_.end(); ++it)
    160161        {
     162            (*it)->setPositionOffset(offset);
    161163            (*it)->setWeaponIndex(positionIndex);
    162164            (*it)->setWeaponModeHUDActualSize(this->weaponModeHUDActualSize_);
  • code/branches/fabienHS15/src/modules/towerdefense/TowerDefenseTower.cc

    r10629 r10739  
    6161        {
    6262            upgrade++;
    63             float reloadrate = getReloadRate();
    64             float reloadwaittime = getReloadWaitTime();
    6563            this->setDamageMultiplier((upgrade+1)*2);
    6664            //this->setRotationThrust(2*this->getRotationThrust());
    67             reloadrate = 0.5f*reloadrate;
    68             reloadwaittime = 0.5f*reloadwaittime;
    69             setReloadRate(reloadrate);
    70             setReloadWaitTime(reloadwaittime);
    7165            //this->addTemplate("towerturret1");
    7266        }
  • code/branches/fabienHS15/src/modules/weapons/projectiles/BasicProjectile.cc

    r10293 r10739  
    6868    @brief
    6969        The function called when a projectile hits another thing.
    70         Calls the hit-function, starts the reload countdown, displays visual hit effects defined in Pawn.
     70        Calls the hit-function, starts the shield recharge countdown, displays visual hit effects defined in Pawn.
    7171        Needs to be called in the collidesAgainst() function by every Class directly inheriting from BasicProjectile.
    7272    @param otherObject
     
    9797            {
    9898                victim->hit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());
    99                 victim->startReloadCountdown();
     99                victim->startShieldRechargeCountdown();
    100100            }
    101101
  • code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc

    r10692 r10739  
    6161
    6262        this->bAlive_ = true;
    63         this->bReload_ = false;
     63        this->bShieldRecharging_ = false;
    6464
    6565        this->health_ = 0;
     
    7272        this->shieldAbsorption_ = 0.5;
    7373
    74         this->reloadRate_ = 0;
    75         this->reloadWaitTime_ = 1.0f;
    76         this->reloadWaitCountdown_ = 0;
     74        this->shieldRechargeRate_ = 0;
     75        this->shieldRechargeWaitTime_ = 1.0f;
     76        this->shieldRechargeWaitCountdown_ = 0;
    7777
    7878        this->lastHitOriginator_ = 0;
     
    143143        XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
    144144
    145         XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
    146         XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
     145        XMLPortParam(Pawn, "reloadrate", setShieldRechargeRate, getShieldRechargeRate, xmlelement, mode).defaultValues(0);
     146        XMLPortParam(Pawn, "reloadwaittime", setShieldRechargeWaitTime, getShieldRechargeWaitTime, xmlelement, mode).defaultValues(1.0f);
    147147
    148148        XMLPortParam(Pawn, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
     
    159159        registerVariable(this->maxShieldHealth_,  VariableDirection::ToClient);
    160160        registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
    161         registerVariable(this->bReload_,          VariableDirection::ToServer);
     161        registerVariable(this->bShieldRecharging_,          VariableDirection::ToServer);
    162162        registerVariable(this->aimPosition_,      VariableDirection::ToServer);  // For the moment this variable gets only transfered to the server
    163163    }
     
    167167        SUPER(Pawn, tick, dt);
    168168
    169         this->bReload_ = false;
     169        this->bShieldRecharging_ = false;
    170170
    171171        // 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();
     172        if(this->shieldRechargeWaitCountdown_ > 0)
     173        {
     174            this->decreaseShieldRechargeCountdownTime(dt);
     175        }
     176        else
     177        {
     178            this->addShieldHealth(this->getShieldRechargeRate() * dt);
     179            this->resetShieldRechargeCountdown();
    180180        }
    181181
     
    229229    }
    230230
    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;
     231    void Pawn::setShieldRechargeRate(float shieldRechargeRate)
     232    {
     233        this->shieldRechargeRate_ = shieldRechargeRate;
     234    }
     235
     236    void Pawn::setShieldRechargeWaitTime(float shieldRechargeWaitTime)
     237    {
     238        this->shieldRechargeWaitTime_ = shieldRechargeWaitTime;
     239    }
     240
     241    void Pawn::decreaseShieldRechargeCountdownTime(float dt)
     242    {
     243        this->shieldRechargeWaitCountdown_ -= dt;
    244244    }
    245245
     
    482482    void Pawn::reload()
    483483    {
    484         this->bReload_ = true;
     484        this->bShieldRecharging_ = true;
    485485    }
    486486
  • code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h

    r10692 r10739  
    116116                { return this->shieldAbsorption_; }
    117117
    118             // TODO: Rename to shieldRechargeRate
    119             virtual void setReloadRate(float reloadrate);
    120             inline float getReloadRate() const
    121                 { return this->reloadRate_; }
    122 
    123             virtual void setReloadWaitTime(float reloadwaittime);
    124             inline float getReloadWaitTime() const
    125                 { return this->reloadWaitTime_; }
    126 
    127             inline void resetReloadCountdown()
    128                 { this->reloadWaitCountdown_ = 0; }
    129 
    130             inline void startReloadCountdown()
    131                 { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
    132 
    133             virtual void decreaseReloadCountdownTime(float dt);
     118            virtual void setShieldRechargeRate(float shieldRechargeRate);
     119            inline float getShieldRechargeRate() const
     120                { return this->shieldRechargeRate_; }
     121
     122            virtual void setShieldRechargeWaitTime(float shieldRechargeWaitTime);
     123            inline float getShieldRechargeWaitTime() const
     124                { return this->shieldRechargeWaitTime_; }
     125
     126            inline void resetShieldRechargeCountdown()
     127                { this->shieldRechargeWaitCountdown_ = 0; }
     128
     129            inline void startShieldRechargeCountdown()
     130                { this->shieldRechargeWaitCountdown_ = this->getShieldRechargeWaitTime(); } // TODO: Implement in Projectile.cc
     131
     132            virtual void decreaseShieldRechargeCountdownTime(float dt);
    134133
    135134            inline ControllableEntity* getLastHitOriginator() const
    136135                { return this->lastHitOriginator_; }
    137136
    138             //virtual void hit(Pawn* originator, const Vector3& force, float damage);
    139             //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
    140137            virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
    141138            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
     
    210207            virtual void spawneffect();
    211208
    212             //virtual void damage(float damage, Pawn* originator = 0);
    213209            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
    214210
     
    229225            float initialShieldHealth_;
    230226            float shieldAbsorption_; ///< Has to be between 0 and 1
    231             float reloadRate_;
    232             float reloadWaitTime_;
    233             float reloadWaitCountdown_;
     227            float shieldRechargeRate_;
     228            float shieldRechargeWaitTime_;
     229            float shieldRechargeWaitCountdown_;
    234230
    235231            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
     
    238234
    239235            WeaponSystem* weaponSystem_;
    240             bool bReload_;
     236            bool bShieldRecharging_;
    241237
    242238            std::string spawnparticlesource_;
Note: See TracChangeset for help on using the changeset viewer.