[Orxonox-commit 6544] r11185 - in code/branches/sagerjFS16: data/levels data/levels/includes data/overlays src/modules/overlays/hud src/modules/weapons/weaponmodes src/orxonox/weaponsystem
sagerj at orxonox.net
sagerj at orxonox.net
Thu May 12 16:03:47 CEST 2016
Author: sagerj
Date: 2016-05-12 16:03:47 +0200 (Thu, 12 May 2016)
New Revision: 11185
Added:
code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.cc
code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h
Modified:
code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscort.oxi
code/branches/sagerjFS16/data/levels/missionOne.oxw
code/branches/sagerjFS16/data/overlays/HUDTemplates3.oxo
code/branches/sagerjFS16/src/modules/overlays/hud/CMakeLists.txt
code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.cc
code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.h
code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc
code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h
Log:
fix the charging during reloadtime, the hudchargebar working so far...
Modified: code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscort.oxi
===================================================================
--- code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscort.oxi 2016-05-12 14:02:21 UTC (rev 11184)
+++ code/branches/sagerjFS16/data/levels/includes/weaponSettingsEscort.oxi 2016-05-12 14:03:47 UTC (rev 11185)
@@ -23,7 +23,7 @@
mode=0
munitionpershot=1
delay=0
- damage=9.3
+ damage=0.5
material="Flares/point_lensflare"
muzzleoffset=" 1.6, 1.3, -2.0"
projectileMesh="LaserBeam2.mesh"
@@ -35,10 +35,10 @@
</weaponpacks>
<munition>
<LaserMunition
- initialmagazines=8
- maxmagazines=8
+ initialmagazines=2
+ maxmagazines=2
munitionpermagazine=10
replenishamount=1
- replenishinterval=7.5
+ replenishinterval=2
/>
</munition>
Modified: code/branches/sagerjFS16/data/levels/missionOne.oxw
===================================================================
--- code/branches/sagerjFS16/data/levels/missionOne.oxw 2016-05-12 14:02:21 UTC (rev 11184)
+++ code/branches/sagerjFS16/data/levels/missionOne.oxw 2016-05-12 14:03:47 UTC (rev 11185)
@@ -11,6 +11,7 @@
include("HUDTemplates3.oxo")
include("templates/lodInformation.oxt")
include("templates/spaceshipAssff.oxt")
+ include("templates/spaceshipEscort.oxt")
include("templates/spaceshipPirate.oxt")
include("templates/spaceshipSpacecruiser.oxt")
include("templates/spaceshipTransporter.oxt")
@@ -56,7 +57,7 @@
<EventMultiTrigger name=spawntrigger>
<events>
<trigger>
- <TeamSpawnPoint team=0 position="800,700,600" direction="-1,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff>
+ <TeamSpawnPoint team=0 position="800,700,600" direction="-1,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort>
<EventTrigger invert=true>
<events>
<trigger>
Modified: code/branches/sagerjFS16/data/overlays/HUDTemplates3.oxo
===================================================================
--- code/branches/sagerjFS16/data/overlays/HUDTemplates3.oxo 2016-05-12 14:02:21 UTC (rev 11184)
+++ code/branches/sagerjFS16/data/overlays/HUDTemplates3.oxo 2016-05-12 14:03:47 UTC (rev 11185)
@@ -183,6 +183,20 @@
visible = "true"
weaponModeHUDSize = "0.09, 0.03"
/>
+
+ <HUDChargeBar
+ name = "ChargeBar"
+ background = "Orxonox/BarBackground"
+ size = "0.40, 0.04"
+ position = "0.0 , 0.5 "
+ pickpoint = "0, 1"
+ correctaspect = true
+ iconmaterial = "Orxonox/BarIconSpeed"
+ >
+ <BarColour position = 0.0 colour = "0.7,0.5,0.2" />
+ <BarColour position = 0.5 colour = "0.2,0.7,0.2" />
+ <BarColour position = 1.0 colour = "0.7,0.2,0.2" />
+ </HUDChargeBar>
<HUDTimer
name = "Timer"
Modified: code/branches/sagerjFS16/src/modules/overlays/hud/CMakeLists.txt
===================================================================
--- code/branches/sagerjFS16/src/modules/overlays/hud/CMakeLists.txt 2016-05-12 14:02:21 UTC (rev 11184)
+++ code/branches/sagerjFS16/src/modules/overlays/hud/CMakeLists.txt 2016-05-12 14:03:47 UTC (rev 11185)
@@ -13,6 +13,7 @@
HUDWeaponMode.cc
HUDWeapon.cc
HUDWeaponSystem.cc
+ HUDChargeBar.cc
ChatOverlay.cc
AnnounceMessage.cc
KillMessage.cc
Added: code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.cc
===================================================================
--- code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.cc (rev 0)
+++ code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.cc 2016-05-12 14:03:47 UTC (rev 11185)
@@ -0,0 +1,196 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "HUDChargeBar.h"
+
+#include "util/Convert.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "worldentities/pawns/Pawn.h"
+#include "overlays/OverlayGroup.h"
+
+
+namespace orxonox
+{
+ RegisterClass(HUDChargeBar);
+
+ HUDChargeBar::HUDChargeBar(Context* context) : HUDBar(context)
+ {
+ RegisterObject(HUDChargeBar);
+
+ this->owner_ = nullptr;
+ this->bUseBarColour_ = false;
+ this->textOffset_ = Vector2(0.0f, 0.0f);
+ this->textScale_ = 1.0f;
+ this->correspondingMode_ = nullptr;
+
+ this->setIconPosition(Vector2(0.05f,0.5f));
+ this->setIconDimensions(Vector2(0.1f,0.5f));
+
+ this->textoverlay_ = new OverlayText(this->getContext());
+
+ assert(this->textoverlay_.get());
+
+ this->textoverlay_->setCaption("");
+ this->textoverlay_->setAspectCorrection(false);
+
+ positionText();
+ }
+
+ HUDChargeBar::~HUDChargeBar()
+ {
+ if (this->isInitialized())
+ {
+ this->textoverlay_->destroy();
+ this->textoverlay_ = nullptr;
+ }
+ }
+
+ void HUDChargeBar::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(HUDChargeBar, XMLPort, xmlelement, mode);
+
+ XMLPortParam(HUDChargeBar, "showtext", setTextVisible, getTextVisible, xmlelement, mode).defaultValues(true);
+ XMLPortParam(HUDChargeBar, "textfont", setTextFont, getTextFont, xmlelement, mode).defaultValues("Monofur");
+ XMLPortParam(HUDChargeBar, "textusebarcolour", setTextUseBarColour, getTextUseBarColour, xmlelement, mode).defaultValues(false);
+ XMLPortParam(HUDChargeBar, "textcolour", setTextColour, getTextColour, xmlelement, mode).defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
+ XMLPortParam(HUDChargeBar, "textalign", setTextAlignmentString, getTextAlignmentString, xmlelement, mode).defaultValues("left");
+ XMLPortParam(HUDChargeBar, "textoffset", setTextOffset, getTextOffset, xmlelement, mode).defaultValues(Vector2::ZERO);
+ XMLPortParam(HUDChargeBar, "textscale", setTextScale, getTextScale, xmlelement, mode).defaultValues(1.0f);
+ XMLPortParam(HUDChargeBar, "textpickpoint", setTextPickPoint, getTextPickPoint, xmlelement, mode).defaultValues(Vector2::ZERO);
+ XMLPortParam(HUDChargeBar, "textrotation", setTextRotation, getTextRotation, xmlelement, mode).defaultValues(0.0f);
+ XMLPortParam(HUDChargeBar, "textspacewidth", setTextSpaceWidth, getTextSpaceWidth, xmlelement, mode).defaultValues(true);
+ }
+
+ void HUDChargeBar::tick(float dt)
+ {
+ SUPER(HUDChargeBar, tick, dt);
+
+ if (this->owner_)
+ {
+ if(correspondingMode_ != nullptr){
+ this->setValue( correspondingMode_->getCharges() * 1.0f / correspondingMode_->getMaxCharges() );
+ this->textoverlay_->setCaption(multi_cast<std::string>(static_cast<int>(this->owner_->getHealth())));
+ }
+
+
+ }
+ else
+ {
+ this->setValue(0);
+ this->textoverlay_->setCaption("0");
+ }
+
+ if (this->bUseBarColour_)
+ this->textoverlay_->setColour(this->getCurrentBarColour());
+
+
+ }
+
+ void HUDChargeBar::changedOwner()
+ {
+ SUPER(HUDChargeBar, changedOwner);
+
+ this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
+ if(this->owner_ == nullptr){
+ return;
+ }
+
+ const WeaponSystem* weaponsystem = owner_->getWeaponSystem();
+ if(weaponsystem == nullptr){
+ return;
+ }
+
+ const std::vector<WeaponPack*> weaponpacklist = weaponsystem->getAllWeaponPacks();
+ for(WeaponPack* weaponpack : weaponpacklist){
+ const std::vector<Weapon*> weaponlist = weaponpack->getAllWeapons();
+ for(Weapon* weapon : weaponlist){
+ const std::multimap<unsigned int, WeaponMode*> weaponmodelist = weapon->getAllWeaponmodes();
+ for(std::multimap<unsigned int, WeaponMode*>::const_iterator it = weaponmodelist.begin(); it != weaponmodelist.end(); ++it){
+ if(it->second->isChargeable()){
+ this->correspondingMode_ = it->second;
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ void HUDChargeBar::changedOverlayGroup()
+ {
+ SUPER(HUDChargeBar, changedOverlayGroup);
+
+ this->getOverlayGroup()->addElement(this->textoverlay_.get());
+ }
+
+ void HUDChargeBar::changedVisibility()
+ {
+ SUPER(HUDChargeBar, changedVisibility);
+
+ this->textoverlay_->setVisible(this->isVisible());
+ }
+
+ void HUDChargeBar::changedName()
+ {
+ SUPER(HUDChargeBar, changedName);
+
+ this->textoverlay_->setName(this->getName() + "text");
+ }
+
+ void HUDChargeBar::setTextColour(const ColourValue& colour)
+ {
+ this->textColour_ = colour;
+ if (!this->bUseBarColour_)
+ this->textoverlay_->setColour(colour);
+ }
+
+ void HUDChargeBar::setTextUseBarColour(bool bUseBarColour)
+ {
+ this->bUseBarColour_ = bUseBarColour;
+ if (!bUseBarColour)
+ this->textoverlay_->setColour(this->textColour_);
+ }
+
+ void HUDChargeBar::positionText()
+ {
+ this->textoverlay_->setPosition(this->getPosition() + this->textOffset_*this->getActualSize());
+ this->textoverlay_->setTextSize(this->getActualSize().y*this->textScale_);
+ }
+
+ void HUDChargeBar::positionChanged()
+ {
+ HUDBar::positionChanged();
+ positionText();
+ }
+
+ void HUDChargeBar::sizeChanged()
+ {
+ HUDBar::sizeChanged();
+ positionText();
+ }
+}
\ No newline at end of file
Added: code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h
===================================================================
--- code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h (rev 0)
+++ code/branches/sagerjFS16/src/modules/overlays/hud/HUDChargeBar.h 2016-05-12 14:03:47 UTC (rev 11185)
@@ -0,0 +1,132 @@
+
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _HUDHealthBar_H__
+#define _HUDHealthBar_H__
+
+#include "overlays/OverlaysPrereqs.h"
+
+#include "util/Math.h"
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+#include "HUDBar.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponMode.h"
+#include "weaponsystem/Weapon.h"
+
+namespace orxonox
+{
+ class _OverlaysExport HUDChargeBar : public HUDBar, public Tickable
+ {
+ public:
+ HUDChargeBar(Context* context);
+ virtual ~HUDChargeBar();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void tick(float dt) override;
+ virtual void changedOwner() override;
+ virtual void changedOverlayGroup() override;
+ virtual void changedVisibility() override;
+ virtual void changedName() override;
+
+ inline void setTextFont(const std::string& font)
+ { if (!font.empty()) { this->textoverlay_->setFont(font); } }
+ inline const std::string& getTextFont() const
+ { return this->textoverlay_->getFont(); }
+
+ void setTextColour(const ColourValue& colour);
+ inline const ColourValue& getTextColour() const
+ { return this->textoverlay_->getColour(); }
+
+ void setTextUseBarColour(bool bUseBarColour);
+ inline bool getTextUseBarColour() const
+ { return this->bUseBarColour_; }
+
+ inline void setTextAlignment(OverlayText::Alignment alignment)
+ { this->textoverlay_->setAlignment(alignment); }
+ inline OverlayText::Alignment getTextAlignment() const
+ { return this->textoverlay_->getAlignment(); }
+
+ void setTextAlignmentString(const std::string& alignment)
+ { this->textoverlay_->setAlignmentString(alignment); }
+ std::string getTextAlignmentString() const
+ { return this->textoverlay_->getAlignmentString(); }
+
+ inline void setTextVisible(bool bVisible)
+ { this->textoverlay_->setVisible(bVisible); }
+ inline bool getTextVisible() const
+ { return this->textoverlay_->isVisible(); }
+
+ inline void setTextScale(float scale)
+ { this->textScale_ = scale;
+ positionText();
+ }
+ inline float getTextScale() const
+ { return this->textScale_; }
+
+ inline void setTextPickPoint(const Vector2& pickpoint)
+ { this->textoverlay_->setPickPoint(pickpoint); }
+ inline Vector2 getTextPickPoint() const
+ { return this->textoverlay_->getPickPoint(); }
+
+ inline void setTextOffset(const Vector2& position)
+ { this->textOffset_ = position;
+ this->positionText();
+ }
+ inline Vector2 getTextOffset() const
+ { return this->textOffset_; }
+
+ inline void setTextRotation(const Degree& angle)
+ { this->textoverlay_->setRotation(angle); }
+ inline const Degree& getTextRotation() const
+ { return this->textoverlay_->getRotation(); }
+
+ inline void setTextSpaceWidth(float width)
+ { this->textoverlay_->setSpaceWidth(width); }
+ inline float getTextSpaceWidth() const
+ { return this->textoverlay_->getSpaceWidth(); }
+
+ inline void setHealthBarOwner(Pawn* owner)
+ { this->owner_ = owner; }
+ protected:
+ virtual void positionChanged() override;
+ virtual void sizeChanged() override;
+ private:
+ WeaponMode* correspondingMode_;
+ void positionText();
+ WeakPtr<Pawn> owner_;
+ StrongPtr<OverlayText> textoverlay_;
+ bool bUseBarColour_;
+ ColourValue textColour_;
+ Vector2 textOffset_;
+ float textScale_;
+ };
+}
+#endif /* _HUDChargeBar_H__ */
Modified: code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.cc
===================================================================
--- code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.cc 2016-05-12 14:02:21 UTC (rev 11184)
+++ code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.cc 2016-05-12 14:03:47 UTC (rev 11185)
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Martin Polak
+ * God of everything
* Co-authors:
- * simonmie
+ *
*
*/
@@ -50,9 +50,9 @@
{
RegisterObject(Discharger);
- this->reloadTime_ = 0.23f;
- this->damage_ = 90.01f;
- this->speed_ = 90.01f;
+ this->reloadTime_ = 3.14159f;
+ this->damage_ = 0.0f;
+ this->speed_ = 100.0f;
this->chargeable_ = true;
this->setMunitionName("LaserMunition");
@@ -64,18 +64,17 @@
void Discharger::fire()
{
- // orxout() << "release" << cTime_ << endl;
BillboardProjectile* projectile = new BillboardProjectile(this->getContext());
this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
projectile->setOrientation(this->getMuzzleOrientation());
projectile->setPosition(this->getMuzzlePosition());
- projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+ projectile->setVelocity(this->getMuzzleDirection() * this->speed_ * this->charges_ / 5);
projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
- projectile->setDamage(this->getDamage() * charges_);
- projectile->setShieldDamage(this->getShieldDamage());
- projectile->setHealthDamage(this->getHealthDamage());
- // this->charges_ = 0;
+ projectile->setDamage(this->getDamage() * this->charges_);
+ projectile->setShieldDamage(this->getShieldDamage() * this->charges_);
+ projectile->setHealthDamage(this->getHealthDamage() * this->charges_);
+ this->charges_ = 0;
}
}
\ No newline at end of file
Modified: code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.h
===================================================================
--- code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.h 2016-05-12 14:02:21 UTC (rev 11184)
+++ code/branches/sagerjFS16/src/modules/weapons/weaponmodes/Discharger.h 2016-05-12 14:03:47 UTC (rev 11185)
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Martin Polak
+ * God of everything
* Co-authors:
- * ...
+ *
*
*/
@@ -57,10 +57,8 @@
virtual void fire() override;
private:
- //bool chargeable_; // An indicator that this weapon type is chargeable.
- int charges_;
float speed_; // The speed of the fired projectile.
- float ctime_; // time the weapon has charged.
+
};
}
Modified: code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc 2016-05-12 14:02:21 UTC (rev 11184)
+++ code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.cc 2016-05-12 14:03:47 UTC (rev 11185)
@@ -63,6 +63,8 @@
this->bAutoReload_ = true;
this->bParallelReload_ = true;
this->chargeable_ = false;
+ this->charges_ = 0;
+ this->maxCharges_ = 100;
this->reloadTimer_.setTimer(0.0f, false, createExecutor(createFunctor(&WeaponMode::reloaded, this)));
this->reloadTimer_.stopTimer();
@@ -171,28 +173,24 @@
bool WeaponMode::push(float* reloadTime)
{
- orxout() << "push " << chargeable_ << endl;
+
if( this->chargeable_)
{
- // setting up a timer for knowing how long the weapon was charged
- // and passes the value to this->cTime_
- orxout() << "if " << endl;
+ if(this->charges_ < this->maxCharges_){
+ this->charges_ += 1;
+ }
return false;
} else {
- orxout() << "else " << endl;
return fire(reloadTime);
}
}
bool WeaponMode::release(float* reloadTime)
{
- orxout() << "release " << endl;
if( this->chargeable_)
{
- orxout() << "if " << endl;
return fire(reloadTime);
}else{
- orxout() << "else " << endl;
return false;
}
}
Modified: code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h
===================================================================
--- code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h 2016-05-12 14:02:21 UTC (rev 11184)
+++ code/branches/sagerjFS16/src/orxonox/weaponsystem/WeaponMode.h 2016-05-12 14:03:47 UTC (rev 11185)
@@ -109,6 +109,12 @@
// Fire
+ inline unsigned int getMaxCharges()
+ { return this->maxCharges_;}
+ inline unsigned int getCharges()
+ { return this->charges_;}
+ inline bool isChargeable()
+ { return this->chargeable_;}
inline void setDamage(float damage)
{ this->damage_ = damage;}
inline float getDamage() const
@@ -169,6 +175,8 @@
unsigned int initialMunition_;
unsigned int initialMagazines_;
unsigned int munitionPerShot_;
+ unsigned int charges_;
+ unsigned int maxCharges_;
float reloadTime_;
bool bAutoReload_; // If true, the weapon reloads the magazine automatically.
More information about the Orxonox-commit
mailing list