Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11189


Ignore:
Timestamp:
May 19, 2016, 5:04:41 PM (9 years ago)
Author:
sagerj
Message:

done/fixed everything, weaponmode/discharger fully commented only hudchargebar left

Location:
code/branches/sagerjFS16
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sagerjFS16/data/levels/emptyLevel.oxw

    r11052 r11189  
    1313
    1414<?lua
    15   include("templates/spaceshipEscort.oxt")
     15  include("templates/spaceshipEscortDischarger.oxt")
    1616?>
    1717
     
    2828
    2929    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
    30     <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
     30    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescortdischarger />
    3131   
    3232  </Scene>
  • code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscort.oxi

    r11185 r11189  
    2424            munitionpershot=1
    2525            delay=0
    26             damage=0.5
     26            damage=0.8
    2727            material="Flares/point_lensflare"
    2828            muzzleoffset=" 1.6, 1.3, -2.0"
  • code/branches/sagerjFS16/data/overlays/HUDTemplates3.oxo

    r11185 r11189  
    192192     pickpoint     = "0, 1"
    193193     correctaspect = true
    194      iconmaterial  = "Orxonox/BarIconSpeed"
     194     iconmaterial  = "Orxonox/BarIconCharge"
    195195    >
    196196      <BarColour position = 0.0 colour = "0.7,0.5,0.2" />
  • code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.cc

    r11185 r11189  
    3131#include "util/Convert.h"
    3232#include "core/CoreIncludes.h"
    33 #include "core/XMLPort.h"
    3433#include "worldentities/pawns/Pawn.h"
    3534#include "overlays/OverlayGroup.h"
     
    4544
    4645        this->owner_ = nullptr;
    47         this->bUseBarColour_ = false;
    48         this->textOffset_ = Vector2(0.0f, 0.0f);
    49         this->textScale_ = 1.0f;
    50         this->correspondingMode_ = nullptr;
    51 
    52         this->setIconPosition(Vector2(0.05f,0.5f));
    53         this->setIconDimensions(Vector2(0.1f,0.5f));
    54 
    55         this->textoverlay_ = new OverlayText(this->getContext());
    56 
    57         assert(this->textoverlay_.get());
    58 
    59         this->textoverlay_->setCaption("");
    60         this->textoverlay_->setAspectCorrection(false);
    61 
    62         positionText();
     46        this->correspondingMode_ = nullptr;             // usually no chargeable weapon equipped
    6347    }
    6448
    65     HUDChargeBar::~HUDChargeBar()
    66     {
    67         if (this->isInitialized())
    68         {
    69             this->textoverlay_->destroy();
    70             this->textoverlay_ = nullptr;
    71         }
    72     }
    73 
    74     void HUDChargeBar::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    75     {
    76         SUPER(HUDChargeBar, XMLPort, xmlelement, mode);
    77 
    78         XMLPortParam(HUDChargeBar, "showtext",          setTextVisible,          getTextVisible,          xmlelement, mode).defaultValues(true);
    79         XMLPortParam(HUDChargeBar, "textfont",          setTextFont,             getTextFont,             xmlelement, mode).defaultValues("Monofur");
    80         XMLPortParam(HUDChargeBar, "textusebarcolour",  setTextUseBarColour,     getTextUseBarColour,     xmlelement, mode).defaultValues(false);
    81         XMLPortParam(HUDChargeBar, "textcolour",        setTextColour,           getTextColour,           xmlelement, mode).defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
    82         XMLPortParam(HUDChargeBar, "textalign",         setTextAlignmentString,  getTextAlignmentString,  xmlelement, mode).defaultValues("left");
    83         XMLPortParam(HUDChargeBar, "textoffset",        setTextOffset,           getTextOffset,           xmlelement, mode).defaultValues(Vector2::ZERO);
    84         XMLPortParam(HUDChargeBar, "textscale",         setTextScale,            getTextScale,            xmlelement, mode).defaultValues(1.0f);
    85         XMLPortParam(HUDChargeBar, "textpickpoint",     setTextPickPoint,        getTextPickPoint,        xmlelement, mode).defaultValues(Vector2::ZERO);
    86         XMLPortParam(HUDChargeBar, "textrotation",      setTextRotation,         getTextRotation,         xmlelement, mode).defaultValues(0.0f);
    87         XMLPortParam(HUDChargeBar, "textspacewidth",    setTextSpaceWidth,       getTextSpaceWidth,       xmlelement, mode).defaultValues(true);
    88     }
     49    HUDChargeBar::~HUDChargeBar() { }
    8950
    9051    void HUDChargeBar::tick(float dt)
     
    9455        if (this->owner_)
    9556        {
    96             if(correspondingMode_ != nullptr){
    97                 this->setValue( correspondingMode_->getCharges() * 1.0f / correspondingMode_->getMaxCharges() );
    98                 this->textoverlay_->setCaption(multi_cast<std::string>(static_cast<int>(this->owner_->getHealth())));
     57            if(correspondingMode_ != nullptr)                                                                       // if there is a chargeable weapon equipped we want to show the charged amount with a HUDBar
     58            {
     59                this->setValue( correspondingMode_->getCharges() * 1.0f / correspondingMode_->getMaxCharges() );    // The Value of the HUDBar is the ratio of current Charges and the maximum Charges possible
     60               
     61                if(this->correspondingMode_->getCharges() > 0)                                                      // The HUDBar should only be visible when we are charging up
     62                    this->setVisible(true);
     63                }
     64                else
     65                {
     66                    this->setVisible(false);
     67                }
    9968            }
    100 
    101            
    10269        }
    10370        else
    10471        {
    10572            this->setValue(0);
    106             this->textoverlay_->setCaption("0");
    10773        }
    108 
    109         if (this->bUseBarColour_)
    110             this->textoverlay_->setColour(this->getCurrentBarColour());
    111 
    11274
    11375    }
     
    11678    {
    11779        SUPER(HUDChargeBar, changedOwner);
     80
     81        this->setVisible(false);
     82        this->correspondingMode_ = nullptr;
    11883
    11984        this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
     
    141106        }
    142107    }
    143 
    144     void HUDChargeBar::changedOverlayGroup()
    145     {
    146         SUPER(HUDChargeBar, changedOverlayGroup);
    147 
    148         this->getOverlayGroup()->addElement(this->textoverlay_.get());
    149     }
    150 
    151     void HUDChargeBar::changedVisibility()
    152     {
    153         SUPER(HUDChargeBar, changedVisibility);
    154 
    155         this->textoverlay_->setVisible(this->isVisible());
    156     }
    157 
    158     void HUDChargeBar::changedName()
    159     {
    160         SUPER(HUDChargeBar, changedName);
    161 
    162         this->textoverlay_->setName(this->getName() + "text");
    163     }
    164 
    165     void HUDChargeBar::setTextColour(const ColourValue& colour)
    166     {
    167         this->textColour_ = colour;
    168         if (!this->bUseBarColour_)
    169             this->textoverlay_->setColour(colour);
    170     }
    171 
    172     void HUDChargeBar::setTextUseBarColour(bool bUseBarColour)
    173     {
    174         this->bUseBarColour_ = bUseBarColour;
    175         if (!bUseBarColour)
    176             this->textoverlay_->setColour(this->textColour_);
    177     }
    178 
    179     void HUDChargeBar::positionText()
    180     {
    181         this->textoverlay_->setPosition(this->getPosition() + this->textOffset_*this->getActualSize());
    182         this->textoverlay_->setTextSize(this->getActualSize().y*this->textScale_);
    183     }
    184 
    185     void HUDChargeBar::positionChanged()
    186     {
    187         HUDBar::positionChanged();
    188         positionText();
    189     }
    190 
    191     void HUDChargeBar::sizeChanged()
    192     {
    193         HUDBar::sizeChanged();
    194         positionText();
    195     }   
    196108}
  • code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h

    r11185 r11189  
    2222 *
    2323 *   Author:
    24  *      Fabian 'x3n' Landau
     24 *      Johannes Sager
    2525 *   Co-authors:
    2626 *      ...
     
    2828 */
    2929
    30 #ifndef _HUDHealthBar_H__
    31 #define _HUDHealthBar_H__
     30#ifndef _HUDChargeBar_H__
     31#define _HUDChargeBar_H__
    3232
    3333#include "overlays/OverlaysPrereqs.h"
    34 
    3534#include "util/Math.h"
    3635#include "tools/interfaces/Tickable.h"
    3736#include "overlays/OverlayText.h"
    3837#include "HUDBar.h"
     38
    3939#include "weaponsystem/WeaponSystem.h"
    4040#include "weaponsystem/WeaponPack.h"
     
    4444namespace orxonox
    4545{
     46    /**
     47    @brief
     48        The HUDChargeBar displays the amount of charges of its owner (a @ref Pawn).
     49        The length of the bar is given by the ratio of the current charges and the maximal charges of the @ref Pawn.
     50    */
     51
    4652    class _OverlaysExport HUDChargeBar : public HUDBar, public Tickable
    4753    {
     
    5056            virtual ~HUDChargeBar();
    5157
    52             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
    5358            virtual void tick(float dt) override;
    5459            virtual void changedOwner() override;
    55             virtual void changedOverlayGroup() override;
    56             virtual void changedVisibility() override;
    57             virtual void changedName() override;
    58 
    59             inline void setTextFont(const std::string& font)
    60                 { if (!font.empty()) { this->textoverlay_->setFont(font); } }
    61             inline const std::string& getTextFont() const
    62                 { return this->textoverlay_->getFont(); }
    63 
    64             void setTextColour(const ColourValue& colour);
    65             inline const ColourValue& getTextColour() const
    66                 { return this->textoverlay_->getColour(); }
    67 
    68             void setTextUseBarColour(bool bUseBarColour);
    69             inline bool getTextUseBarColour() const
    70                 { return this->bUseBarColour_; }
    71 
    72             inline void setTextAlignment(OverlayText::Alignment alignment)
    73                 { this->textoverlay_->setAlignment(alignment); }
    74             inline OverlayText::Alignment getTextAlignment() const
    75                 { return this->textoverlay_->getAlignment(); }
    76 
    77             void setTextAlignmentString(const std::string& alignment)
    78                 { this->textoverlay_->setAlignmentString(alignment); }
    79             std::string getTextAlignmentString() const
    80                 { return this->textoverlay_->getAlignmentString(); }
    81 
    82             inline void setTextVisible(bool bVisible)
    83                 { this->textoverlay_->setVisible(bVisible); }
    84             inline bool getTextVisible() const
    85                 { return this->textoverlay_->isVisible(); }
    86 
    87             inline void setTextScale(float scale)
    88                 { this->textScale_ = scale;
    89                   positionText();
    90                 }
    91             inline float getTextScale() const
    92                 { return this->textScale_; }
    93 
    94             inline void setTextPickPoint(const Vector2& pickpoint)
    95                 { this->textoverlay_->setPickPoint(pickpoint); }
    96             inline Vector2 getTextPickPoint() const
    97                 { return this->textoverlay_->getPickPoint(); }
    98 
    99             inline void setTextOffset(const Vector2& position)
    100                 { this->textOffset_ = position;
    101                   this->positionText();
    102                 }
    103             inline Vector2 getTextOffset() const
    104                 { return this->textOffset_; }
    105 
    106             inline void setTextRotation(const Degree& angle)
    107                 { this->textoverlay_->setRotation(angle); }
    108             inline const Degree& getTextRotation() const
    109                 { return this->textoverlay_->getRotation(); }
    110 
    111             inline void setTextSpaceWidth(float width)
    112                 { this->textoverlay_->setSpaceWidth(width); }
    113             inline float getTextSpaceWidth() const
    114                 { return this->textoverlay_->getSpaceWidth(); }
    11560
    11661            inline void setHealthBarOwner(Pawn* owner)
    11762                { this->owner_ = owner; }
    118         protected:
    119             virtual void positionChanged() override;
    120             virtual void sizeChanged() override;
     63       
    12164        private:
    122             WeaponMode* correspondingMode_;
    123             void positionText();
     65            WeaponMode* correspondingMode_;         // pointer on the chargeable weaponmode (=nullptr if no chargeable weapons equipped)
    12466            WeakPtr<Pawn> owner_;
    125             StrongPtr<OverlayText> textoverlay_;
    126             bool bUseBarColour_;
    127             ColourValue textColour_;
    128             Vector2 textOffset_;
    129             float textScale_;
    13067    };
    13168}
  • code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.cc

    r11185 r11189  
    2121 *
    2222 *   Author:
    23  *      God of everything
     23 *      Johannes Sager
    2424 *   Co-authors:
    2525 *   
     
    5151        RegisterObject(Discharger);
    5252
    53         this->reloadTime_ = 3.14159f;
    54         this->damage_ = 0.0f;
    55         this->speed_ = 100.0f;
    56         this->chargeable_ = true;
     53        this->reloadTime_ = 3.14159f;           // how long you cannot charge after fire
     54        this->damage_ = 0.0f;                   // if 0.0f then it uses weaponsettings.oxi
     55        this->speed_ = 100.0f;                  // base projectile speed
     56        this->chargeable_ = true;               // true if weapon chargeable
    5757
    5858        this->setMunitionName("LaserMunition");
     
    7070        projectile->setOrientation(this->getMuzzleOrientation());
    7171        projectile->setPosition(this->getMuzzlePosition());
    72         projectile->setVelocity(this->getMuzzleDirection() * this->speed_ * this->charges_ / 5);
    73 
     72        projectile->setVelocity(this->getMuzzleDirection() * this->speed_ * this->charges_ / 5);// we scale the projectile speed with the current charges / 5
    7473        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    7574        projectile->setDamage(this->getDamage() * this->charges_);
    76         projectile->setShieldDamage(this->getShieldDamage() * this->charges_);
    77         projectile->setHealthDamage(this->getHealthDamage() * this->charges_);
    78         this->charges_ = 0;
     75        projectile->setShieldDamage(this->getShieldDamage() * this->charges_);                  // we scale both types of damage with the current charges as
     76        projectile->setHealthDamage(this->getHealthDamage() * this->charges_);                  // well since this is the whole purpose of a chareable weapon
     77        this->charges_ = 0;                                                                     // firing "consumes" the current charges (reset after fire)
    7978    }
    8079}
  • code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.h

    r11185 r11189  
    2121 *
    2222 *   Author:
    23  *       God of everything
     23 *       Johannes Sager
    2424 *   Co-authors:
    2525 *     
  • code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc

    r11185 r11189  
    2424 *      Fabian 'x3n' Landau
    2525 *   Co-authors:
    26  *      ...
     26 *      Johannes Sager
    2727 *
    2828 */
     
    6363        this->bAutoReload_ = true;
    6464        this->bParallelReload_ = true;
    65         this->chargeable_ = false;
    66         this->charges_ = 0;
    67         this->maxCharges_ = 100;
     65        this->chargeable_ = false;              // most weapons are not chargeable
     66        this->charges_ = 0;                     // always start with no charges
     67        this->maxCharges_ = 100;                // default maximum charges one can have are 100
    6868
    6969        this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&WeaponMode::reloaded, this)));
     
    123123    bool WeaponMode::fire(float* reloadTime)
    124124    {
    125         orxout() << "--- " << endl;
    126125        (*reloadTime) = this->reloadTime_;
    127126        // Fireing is only possible if this weapon mode is not reloading and there is enough munition
     
    175174    {
    176175
    177         if( this->chargeable_)
    178         {
    179             if(this->charges_ < this->maxCharges_){
    180                 this->charges_ += 1;
    181             }
     176        if( this->chargeable_)                                                                                                          // chargeable weapons are supposed to charge on push
     177        {
     178            this->munition_ = this->weapon_->getWeaponPack()->getWeaponSystem()->getMunition(&this->munitiontype_);                     // updates the pointer to the munition(which we use in the next step)
     179            if(this->charges_ < this->maxCharges_ && this->bReloading_ == false && this->munition_->canTakeMunition(1, this))           // charges up unless:
     180            {                                                                                                                           // - we are fully charged
     181                this->charges_ += 1;                                                                                                    // - we are reloading
     182            }                                                                                                                           // - we have no munition
    182183            return false;
    183         } else {
     184        }
     185        else                                                                                                                            // normal (not chargeable) weapons are supposed to fire on push
     186        {
    184187            return fire(reloadTime);
    185188        }
    186189    }
    187190
    188     bool WeaponMode::release(float* reloadTime)
    189     {
    190         if( this->chargeable_)
     191    bool WeaponMode::release(float* reloadTime)                 
     192    {
     193        if( this->chargeable_)                                                                                                          // chargeable weapons are supposed to fire on release
    191194        {
    192195            return fire(reloadTime);
    193         }else{
     196        }
     197        else                                                                                                                            // normal (not chargeable) weapons should do nothing on release
     198        {
    194199            return false;
    195200        }
  • code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h

    r11185 r11189  
    2424 *      Fabian 'x3n' Landau
    2525 *   Co-authors:
    26  *      ...
     26 *      Johannes Sager
    2727 *
    2828 */
     
    110110
    111111            // Fire
    112             inline unsigned int getMaxCharges()
     112            inline unsigned int getMaxCharges()                 // get the maximum of charges one can have
    113113                { return this->maxCharges_;}
    114             inline unsigned int getCharges()
     114            inline unsigned int getCharges()                    // get the current amount of charges
    115115                { return this->charges_;}
    116             inline bool isChargeable()
     116            inline bool isChargeable()                          // returns if the weaponmode is chargeable
    117117                { return this->chargeable_;}
    118118            inline void setDamage(float damage)
     
    176176            unsigned int initialMagazines_;
    177177            unsigned int munitionPerShot_;
    178             unsigned int charges_;
    179             unsigned int maxCharges_;
     178            unsigned int charges_;                  // current amount of charges only matters for chargeable weapons(chargeable == true)
     179            unsigned int maxCharges_;               // maximum amount of charges (is initialized with 100 in weaponmode.cc) only matters for chargeable weapons(chargeable == true)
    180180
    181181            float reloadTime_;
    182             bool bAutoReload_; // If true, the weapon reloads the magazine automatically.
    183             bool bParallelReload_; // If true, the weapon reloads in parallel to the magazine reloading.
    184             bool chargeable_; // If true, the weapon fires at release instead at push(where he charges up)
     182            bool bAutoReload_;                      // If true, the weapon reloads the magazine automatically.
     183            bool bParallelReload_;                  // If true, the weapon reloads in parallel to the magazine reloading.
     184            bool chargeable_;                       // If true, the weapon charges up on push and fires on release
    185185
    186186            float damage_;
     
    202202
    203203            Timer reloadTimer_;
    204             bool bReloading_; // If true, this weapon mode is marked as reloading.
     204            bool bReloading_;                       // If true, this weapon mode is marked as reloading.
    205205
    206206            Vector3 muzzlePosition_;
    207207            Quaternion muzzleOrientation_;
    208208
    209             std::string fireSoundPath_; // The path of the sound played when fireing
    210             float fireSoundVolume_; // The volume of the sound played when fireing
    211             std::vector<WorldSound*> fireSounds_; // List of sounds used by the weapon mode. Because multiple sounds may overlap, we need mor than one WorldSound instance.
    212             std::string reloadSoundPath_; // The path of the sound played when reloading
    213             float reloadSoundVolume_; // The volume of the sound played when reloading
     209            std::string fireSoundPath_;             // The path of the sound played when fireing
     210            float fireSoundVolume_;                 // The volume of the sound played when fireing
     211            std::vector<WorldSound*> fireSounds_;   // List of sounds used by the weapon mode. Because multiple sounds may overlap, we need mor than one WorldSound instance.
     212            std::string reloadSoundPath_;           // The path of the sound played when reloading
     213            float reloadSoundVolume_;               // The volume of the sound played when reloading
    214214            WorldSound* reloadSound_;
    215215    };
Note: See TracChangeset for help on using the changeset viewer.