Changeset 10739 for code/branches/fabienHS15/src
- Timestamp:
- Nov 1, 2015, 1:05:54 PM (9 years ago)
- Location:
- code/branches/fabienHS15/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/fabienHS15/src/modules/overlays/hud/HUDBar.cc
r9667 r10739 47 47 RegisterClass(BarColour); 48 48 49 BarColour::BarColour(Context* context) 50 : BaseObject(context) 49 BarColour::BarColour(Context* context) : BaseObject(context) 51 50 { 52 51 RegisterObject(BarColour); 53 52 54 53 this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 55 54 this->setPosition(0.0); … … 69 68 RegisterClass(HUDBar); 70 69 71 HUDBar::HUDBar(Context* context) 72 : OrxonoxOverlay(context), right2Left_(false), autoColour_(false) 70 HUDBar::HUDBar(Context* context) : OrxonoxOverlay(context), right2Left_(false), autoColour_(false) 73 71 { 74 72 RegisterObject(HUDBar); … … 88 86 this->bar_->setMaterialName(materialname); 89 87 88 this->bar_->setPosition(0.0f,0.0f); 89 this->bar_->setDimensions(1.0f,1.0f); 90 91 this->bUseIcon_ = false; 90 92 this->value_ = 1.0f; // initialize with 1.0f to trigger a change when calling setValue(0.0f) on the line below 91 93 this->setAutoColour(true); … … 95 97 96 98 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_); 97 104 } 98 105 … … 115 122 XMLPortParam(HUDBar, "autocolour", setAutoColour, getAutoColour, xmlelement, mode); 116 123 XMLPortParam(HUDBar, "bartexture", setBarTexture, getBarTexture, xmlelement, mode); 124 XMLPortParam(HUDBar, "iconmaterial", setIconMaterial, getIconMaterial, xmlelement, mode); 117 125 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlelement, mode); 118 126 } … … 161 169 } 162 170 171 float height = this->bar_->getHeight(); 172 float top = this->bar_->getTop(); 173 163 174 // set value 164 175 if (this->right2Left_) 165 176 { 166 177 // 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 } 169 188 } 170 189 else 171 190 { 172 191 // 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 176 204 if (this->value_ != 0) 177 205 this->bar_->setTiling(this->value_, 1.0); … … 208 236 return this->textureUnitState_->getTextureName(); 209 237 } 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 } 210 250 } -
code/branches/fabienHS15/src/modules/overlays/hud/HUDBar.h
r9667 r10739 37 37 #include <map> 38 38 #include <vector> 39 #include <OgrePanelOverlayElement.h> 39 40 40 41 #include "util/Math.h" … … 51 52 virtual ~BarColour() { } 52 53 53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 54 55 55 56 void setColour(const ColourValue& colour) { this->colour_ = colour; } … … 115 116 const std::string& getBarTexture() const; 116 117 118 void setIconMaterial(const std::string& iconMaterial); 119 const std::string& getIconMaterial() const; 120 117 121 inline const ColourValue& getCurrentBarColour() const 118 122 { return this->currentColour_; } 119 123 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 120 129 protected: 121 130 virtual void valueChanged(); 122 123 131 private: 124 132 void addColour(BarColour* colour); … … 129 137 float value_; //!< progress of bar 130 138 ColourValue currentColour_; 139 bool bUseIcon_; 131 140 132 141 Ogre::PanelOverlayElement* bar_; 133 142 Ogre::TextureUnitState* textureUnitState_; 143 Ogre::PanelOverlayElement* icon_; 134 144 std::map<float, ColourValue> colours_; 135 145 std::vector<BarColour*> barColours_; -
code/branches/fabienHS15/src/modules/overlays/hud/HUDBoostBar.cc
r9667 r10739 59 59 if (this->owner_->isBoostCoolingDown()) 60 60 { 61 this->setBackgroundColour(ColourValue(0.7f, 0.2f, 0.2f));61 //this->setBackgroundColour(ColourValue(0.7f, 0.2f, 0.2f)); 62 62 if (this->flashDt_ <= 0.0f) 63 63 { … … 72 72 this->flashDt_ = 0.0f; 73 73 this->show(); 74 this->setBackgroundColour(ColourValue(0.2f, 0.7f, 0.2f));74 //this->setBackgroundColour(ColourValue(0.2f, 0.7f, 0.2f)); 75 75 } 76 76 -
code/branches/fabienHS15/src/modules/overlays/hud/HUDHealthBar.cc
r9667 r10739 45 45 this->owner_ = 0; 46 46 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)); 47 52 48 53 this->textoverlay_ = new OverlayText(this->getContext()); … … 51 56 52 57 this->textoverlay_->setCaption(""); 58 this->textoverlay_->setAspectCorrection(false); 59 60 positionText(); 53 61 } 54 62 … … 58 66 { 59 67 this->textoverlay_->destroy(); 60 this->textoverlay_ = 0;68 this->textoverlay_ = NULL; 61 69 } 62 70 } … … 70 78 XMLPortParam(HUDHealthBar, "textusebarcolour", setTextUseBarColour, getTextUseBarColour, xmlelement, mode).defaultValues(false); 71 79 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);73 80 XMLPortParam(HUDHealthBar, "textalign", setTextAlignmentString, getTextAlignmentString, xmlelement, mode).defaultValues("left"); 74 81 XMLPortParam(HUDHealthBar, "textoffset", setTextOffset, getTextOffset, xmlelement, mode).defaultValues(Vector2::ZERO); 82 XMLPortParam(HUDHealthBar, "textscale", setTextScale, getTextScale, xmlelement, mode).defaultValues(1.0f); 75 83 XMLPortParam(HUDHealthBar, "textpickpoint", setTextPickPoint, getTextPickPoint, xmlelement, mode).defaultValues(Vector2::ZERO); 76 84 XMLPortParam(HUDHealthBar, "textrotation", setTextRotation, getTextRotation, xmlelement, mode).defaultValues(0.0f); 77 XMLPortParam(HUDHealthBar, "textcorrectaspect", setTextAspectCorrection, getTextAspectCorrection, xmlelement, mode).defaultValues(true);78 85 XMLPortParam(HUDHealthBar, "textspacewidth", setTextSpaceWidth, getTextSpaceWidth, xmlelement, mode).defaultValues(true); 79 86 } … … 139 146 this->textoverlay_->setColour(this->textColour_); 140 147 } 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 } 141 166 } -
code/branches/fabienHS15/src/modules/overlays/hud/HUDHealthBar.h
r10624 r10739 75 75 { return this->textoverlay_->getAlignmentString(); } 76 76 77 inline void setTextSize(float size)78 { this->textoverlay_->setTextSize(size); }79 inline float getTextSize() const80 { return this->textoverlay_->getTextSize(); }81 82 77 inline void setTextVisible(bool bVisible) 83 78 { this->textoverlay_->setVisible(bVisible); } 84 79 inline bool getTextVisible() const 85 80 { 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_; } 86 88 87 89 inline void setTextPickPoint(const Vector2& pickpoint) … … 91 93 92 94 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 } 94 98 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_; } 101 100 102 101 inline void setTextRotation(const Degree& angle) … … 112 111 inline void setHealthBarOwner(Pawn* owner) 113 112 { this->owner_ = owner; } 114 113 protected: 114 virtual void positionChanged(); 115 virtual void sizeChanged(); 115 116 private: 117 virtual void positionText(); 116 118 WeakPtr<Pawn> owner_; 117 119 StrongPtr<OverlayText> textoverlay_; 118 120 bool bUseBarColour_; 119 121 ColourValue textColour_; 122 Vector2 textOffset_; 123 float textScale_; 120 124 }; 121 125 } -
code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.cc
r10724 r10739 60 60 { 61 61 destroyHUDChilds(); 62 //this->overlayElement_->destroy();63 62 } 64 63 } … … 179 178 for (std::vector<WeakPtr<HUDWeaponMode> >::iterator it = hudWeaponModes_.begin(); it != hudWeaponModes_.end(); ++it) 180 179 { 180 (*it)->setPositionOffset(this->positionOffset_); 181 181 (*it)->setWeaponModeIndex(positionIndex); 182 182 (*it)->setWeaponIndex(this->weaponIndex_); … … 210 210 if (weaponModes_ != NULL) 211 211 { 212 this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f) );212 this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f) + this->positionOffset_); 213 213 } 214 214 } -
code/branches/fabienHS15/src/modules/overlays/hud/HUDWeapon.h
r10724 r10739 72 72 inline Vector2 getWeaponModeHUDActualSize() const 73 73 { return weaponModeHUDActualSize_; } 74 inline void setPositionOffset(Vector2 positionOffset) 75 { 76 this->positionOffset_ = positionOffset; 77 this->updatePosition(); 78 } 74 79 inline void setWeaponIndex(int index) 75 { weaponIndex_ = index; 76 this->updatePosition(); 80 { 81 weaponIndex_ = index; 82 this->updatePosition(); 77 83 } 78 84 … … 94 100 95 101 Vector2 weaponModeHUDActualSize_; 102 Vector2 positionOffset_; 96 103 int weaponIndex_; 97 104 }; -
code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.cc
r10724 r10739 102 102 if (this->isInitialized()) 103 103 { 104 //this->textOverlay_->destroy(); 104 this->textOverlayLeft_->destroy(); 105 this->textOverlayRight_->destroy(); 105 106 } 106 107 } … … 280 281 void HUDWeaponMode::updatePosition() 281 282 { 282 this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,weaponModeHUDActualSize_.y*weaponModeIndex_) );283 this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,weaponModeHUDActualSize_.y*weaponModeIndex_) + this->positionOffset_); 283 284 } 284 285 } -
code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.h
r10724 r10739 82 82 this->updatePosition(); 83 83 } 84 inline void setPositionOffset(Vector2 positionOffset) 85 { 86 this->positionOffset_ = positionOffset; 87 this->updatePosition(); 88 } 84 89 85 90 private: … … 102 107 103 108 Vector2 weaponModeHUDActualSize_; 109 Vector2 positionOffset_; 104 110 int weaponIndex_; 105 111 int weaponModeIndex_; -
code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponSystem.cc
r10724 r10739 156 156 { 157 157 int positionIndex = 0; 158 Vector2 offset = this->getPosition(); 158 159 159 160 for (std::vector<WeakPtr<HUDWeapon> >::iterator it = hudWeapons_.begin(); it != hudWeapons_.end(); ++it) 160 161 { 162 (*it)->setPositionOffset(offset); 161 163 (*it)->setWeaponIndex(positionIndex); 162 164 (*it)->setWeaponModeHUDActualSize(this->weaponModeHUDActualSize_); -
code/branches/fabienHS15/src/modules/towerdefense/TowerDefenseTower.cc
r10629 r10739 61 61 { 62 62 upgrade++; 63 float reloadrate = getReloadRate();64 float reloadwaittime = getReloadWaitTime();65 63 this->setDamageMultiplier((upgrade+1)*2); 66 64 //this->setRotationThrust(2*this->getRotationThrust()); 67 reloadrate = 0.5f*reloadrate;68 reloadwaittime = 0.5f*reloadwaittime;69 setReloadRate(reloadrate);70 setReloadWaitTime(reloadwaittime);71 65 //this->addTemplate("towerturret1"); 72 66 } -
code/branches/fabienHS15/src/modules/weapons/projectiles/BasicProjectile.cc
r10293 r10739 68 68 @brief 69 69 The function called when a projectile hits another thing. 70 Calls the hit-function, starts the reloadcountdown, displays visual hit effects defined in Pawn.70 Calls the hit-function, starts the shield recharge countdown, displays visual hit effects defined in Pawn. 71 71 Needs to be called in the collidesAgainst() function by every Class directly inheriting from BasicProjectile. 72 72 @param otherObject … … 97 97 { 98 98 victim->hit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage()); 99 victim->start ReloadCountdown();99 victim->startShieldRechargeCountdown(); 100 100 } 101 101 -
code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.cc
r10692 r10739 61 61 62 62 this->bAlive_ = true; 63 this->b Reload_ = false;63 this->bShieldRecharging_ = false; 64 64 65 65 this->health_ = 0; … … 72 72 this->shieldAbsorption_ = 0.5; 73 73 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; 77 77 78 78 this->lastHitOriginator_ = 0; … … 143 143 XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode); 144 144 145 XMLPortParam(Pawn, "reloadrate", set ReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);146 XMLPortParam(Pawn, "reloadwaittime", set ReloadWaitTime, 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); 147 147 148 148 XMLPortParam(Pawn, "explosionSound", setExplosionSound, getExplosionSound, xmlelement, mode); … … 159 159 registerVariable(this->maxShieldHealth_, VariableDirection::ToClient); 160 160 registerVariable(this->shieldAbsorption_, VariableDirection::ToClient); 161 registerVariable(this->b Reload_, VariableDirection::ToServer);161 registerVariable(this->bShieldRecharging_, VariableDirection::ToServer); 162 162 registerVariable(this->aimPosition_, VariableDirection::ToServer); // For the moment this variable gets only transfered to the server 163 163 } … … 167 167 SUPER(Pawn, tick, dt); 168 168 169 this->b Reload_ = false;169 this->bShieldRecharging_ = false; 170 170 171 171 // TODO: use the existing timer functions instead 172 if(this-> reloadWaitCountdown_ > 0)173 { 174 this->decrease ReloadCountdownTime(dt);175 } 176 else 177 { 178 this->addShieldHealth(this->get ReloadRate() * dt);179 this->reset ReloadCountdown();172 if(this->shieldRechargeWaitCountdown_ > 0) 173 { 174 this->decreaseShieldRechargeCountdownTime(dt); 175 } 176 else 177 { 178 this->addShieldHealth(this->getShieldRechargeRate() * dt); 179 this->resetShieldRechargeCountdown(); 180 180 } 181 181 … … 229 229 } 230 230 231 void Pawn::set ReloadRate(float reloadrate)232 { 233 this-> reloadRate_ = reloadrate;234 } 235 236 void Pawn::set ReloadWaitTime(float reloadwaittime)237 { 238 this-> reloadWaitTime_ = reloadwaittime;239 } 240 241 void Pawn::decrease ReloadCountdownTime(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; 244 244 } 245 245 … … 482 482 void Pawn::reload() 483 483 { 484 this->b Reload_ = true;484 this->bShieldRecharging_ = true; 485 485 } 486 486 -
code/branches/fabienHS15/src/orxonox/worldentities/pawns/Pawn.h
r10692 r10739 116 116 { return this->shieldAbsorption_; } 117 117 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); 134 133 135 134 inline ControllableEntity* getLastHitOriginator() const 136 135 { return this->lastHitOriginator_; } 137 136 138 //virtual void hit(Pawn* originator, const Vector3& force, float damage);139 //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);140 137 virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 141 138 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); … … 210 207 virtual void spawneffect(); 211 208 212 //virtual void damage(float damage, Pawn* originator = 0);213 209 virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL); 214 210 … … 229 225 float initialShieldHealth_; 230 226 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_; 234 230 235 231 float damageMultiplier_; ///< Used by the Damage Boost Pickup. … … 238 234 239 235 WeaponSystem* weaponSystem_; 240 bool b Reload_;236 bool bShieldRecharging_; 241 237 242 238 std::string spawnparticlesource_;
Note: See TracChangeset
for help on using the changeset viewer.