Commit b6d3cf30 authored by AL's avatar AL

overlay pulses at low hp

parent 68a5c857
......@@ -117,7 +117,7 @@ public:
Ghoul::Ghoul()
{
HP = 1u;
HP = 75u;
maxHP = 75u;
speed = 1.0f;
block = 0u;
......
......@@ -30,7 +30,7 @@ HUD::HUD(const Menu& menu, FrameCommander& fc, DXGraphics& gfx, const ActionBox&
elements.emplace(std::make_pair(Element::InitiativeBar, std::make_unique<InitiativeBar>(gfx, cm.GetCombatDataReference())));
elements.emplace(std::make_pair(Element::RewardMenu, std::make_unique<RewardMenu>(gfx, cm, menu)));
elements.emplace(std::make_pair(Element::AchievementsScreen, std::make_unique<AchievementsScreen>(gfx)));
elements.emplace(std::make_pair(Element::Overlay, std::make_unique<HudOverlay>(gfx)));
elements.emplace(std::make_pair(Element::Overlay, std::make_unique<HudOverlay>(gfx, cm.GetCombatDataReference())));
}
void HUD::Submit() const
......
......@@ -4,9 +4,10 @@
#include "Framework\PixelShader.h"
HudOverlay::HudOverlay(DXGraphics& gfx):
HudOverlay::HudOverlay(DXGraphics& gfx, const CombatData& cd):
overlay(L"Media//Sprites//statusBar_bleedAct.png",gfx),
gfx(gfx)
gfx(gfx),
cd(cd)
{
auto& s = overlay.GetTechniquesReference()[0].GetSteps()[0];
s.DeleteBindableByUID(L"class Bind::PixelShader#HudPS.cso");
......@@ -33,11 +34,36 @@ void HudOverlay::SmartSubmit(FrameCommander& fc) const
}
void HudOverlay::Animate(float dt) //animated by HUD
{
{
Pulse(dt);
pendingPower = std::min(pendingPower * (falloff * dt), pendingPower * 0.99999f);
float coeff = changeSensitivity * dt;
currentPower = currentPower * (1.0f - coeff) + pendingPower * coeff;
if (currentPower <= 0.001f)currentPower = 0.0f;
}
void HudOverlay::Pulse(float dt)
{
if (cd.isValid)
{
const float health = (float)cd.playerHP / (float)cd.playerMaxHP;
if (health <= 0.1f)
{
curPulseTime += dt;
if (curPulseTime >= pulseTime)
{
curPulseTime -= pulseTime;
if (health >= 0.05f) //if between 10% and 5%
{
BoostOverlay(0.3f);
}
else //if between 0 and 5%
{
BoostOverlay(0.5f);
}
}
}
}
}
float HudOverlay::pendingPower = 0.0f;
\ No newline at end of file
#pragma once
#include "Framework\HudElement.h"
#include "CombatManager.h"
class HudOverlay : public HudElement
{
public:
HudOverlay(DXGraphics& gfx);
HudOverlay(DXGraphics& gfx, const CombatData& cd);
static void BoostOverlay(float boost); //1.0f - a lot of boost
void SmartSubmit(FrameCommander& fc)const override;
void Animate(float dt) override;
......@@ -15,6 +16,7 @@ private:
float pad1;
float pad2;
};
void Pulse(float dt); // when player is at low hp overlay begins to pulse
HudElement overlay;
float currentPower = 0.0f;
std::vector<PositionData> pos;
......@@ -23,4 +25,7 @@ private:
static constexpr float falloff = 58.5f;
static constexpr float changeSensitivity = 5.99f;
DXGraphics& gfx;
const CombatData& cd;
float curPulseTime = 0.0f;
static constexpr float pulseTime = 1.0f;
};
......@@ -9,19 +9,7 @@
PlayerManager::PlayerManager():
actionBox(skillPool)
{
HP = 300u;
maxHP = 300u;
block = 0u;
activeStatusEffects[StatusEffects::CritChance].first = baseCrit;
activeStatusEffects[StatusEffects::Dodge].first = baseDodge;
skillPool.push_back(std::make_unique<Cut>(this));
skillPool.push_back(std::make_unique<Cut>(this));
skillPool.push_back(std::make_unique<Cut>(this));
skillPool.push_back(std::make_unique<Deflect>(this));
skillPool.push_back(std::make_unique<SandStorm>(this));
skillPool.push_back(std::make_unique<SharpenTheBlade>(this));
skillPool.push_back(std::make_unique<SandsOfTime>(this));
skillPool.push_back(std::make_unique<DustThrow>(this));
Reset();
}
void PlayerManager::BeginBattle()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment