Commit 68a5c857 authored by AL's avatar AL

added bloody overlay

parent 7bfe885b
......@@ -2,6 +2,7 @@
#include "AchievementManager.h"
#include <iostream>
#include "Framework\ChiliUtil.h"
#include "HudOverlay.h"
using namespace std::string_literals;
......@@ -9,11 +10,19 @@ void CombatEntity::SufferPureDamage(size_t incDmg)
{
if (incDmg < HP) //if does not kill
{
if (ToWide(typeid(*this).name()) == L"class PlayerManager"s)
{
HudOverlay::BoostOverlay(std::max(0.4f, 0.02857f * (float)incDmg));
}
HP -= incDmg;
}
else
{
if (ToWide(typeid(*this).name()) == L"class PlayerManager"s)AM::Alert(AM::Event::PlayerDiedToBloodloss);
if (ToWide(typeid(*this).name()) == L"class PlayerManager"s)
{
HudOverlay::BoostOverlay(1.5f);
AM::Alert(AM::Event::PlayerDiedToBloodloss);
}
HP = 0;
OnDeath();
}
......
......@@ -13,6 +13,7 @@
#include "EffectHandler.h"
#include "CameraManager.h"
#include "BlurManager.h"
#include "HudOverlay.h"
......@@ -127,20 +128,19 @@ int CombatManager::ProcessInput(Keyboard::Event in_event) //why does it return
//}
if (in_event.GetCode() == 'H') //for testing
{
BlurManager::AddBlur(0.2f);
HudOverlay::BoostOverlay(0.2f);
}
if (in_event.GetCode() == 'J') //for testing
{
BlurManager::AddBlur(0.7f);
}
HudOverlay::BoostOverlay(0.7f);
}
if (in_event.GetCode() == 'K') //for testing
{
EH::AddEffect3D(EH::Effect::GhoulHowl);
HudOverlay::BoostOverlay(1.0f);
}
if (in_event.GetCode() == 'L') //for testing
{
BlurManager::AddBlur(1.9f);
HudOverlay::BoostOverlay(1.5f);
}
//if (in_event.GetCode() == 'T') //for testing
//{
......
......@@ -246,6 +246,7 @@
<ClInclude Include="Framework\VertexBuffer.h" />
<ClInclude Include="Framework\VertexShader.h" />
<ClInclude Include="Framework\WindowsThrowMacros.h" />
<ClInclude Include="HudOverlay.h" />
<ClInclude Include="HudTranslucent.h" />
<ClInclude Include="imgui\imconfig.h" />
<ClInclude Include="imgui\imgui.h" />
......@@ -454,6 +455,7 @@
<ClCompile Include="Game.cpp" />
<ClCompile Include="Ghoul.cpp" />
<ClCompile Include="HUD.cpp" />
<ClCompile Include="HudOverlay.cpp" />
<ClCompile Include="HudTranslucent.cpp" />
<ClCompile Include="imgui\imgui.cpp" />
<ClCompile Include="imgui\ImguiManager.cpp" />
......
......@@ -603,6 +603,9 @@
<ClInclude Include="BlurPack.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HudOverlay.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Game.cpp">
......@@ -926,6 +929,9 @@
<ClCompile Include="GraphicsResource.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HudOverlay.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="PhongVSNormalMap.hlsl">
......
......@@ -9,6 +9,7 @@
#include "InitiativeBar.h"
#include "WASDPanels.h"
#include "AchievementsScreen.h"
#include "HudOverlay.h"
HUD::HUD(const Menu& menu, FrameCommander& fc, DXGraphics& gfx, const ActionBox& abox, const CombatManager& cm) : //will require a rework to support any number of skills other than 4
menu(menu), fc(fc), gfx(gfx), cd(cm.GetCombatDataReference())
......@@ -29,10 +30,12 @@ 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)));
}
void HUD::Submit() const
{
elements.at(Element::Overlay)->SmartSubmit(fc);
prevState = ms;
ms = menu.GetMenuState();
switch (ms)
......@@ -117,6 +120,7 @@ void HUD::Submit() const
void HUD::Animate(float dt)
{
elements.at(Element::Overlay)->Animate(dt);
ms = menu.GetMenuState();
if (ms == Menu::MenuState::Inactive || ms == Menu::MenuState::ChoosingReward)
{
......
......@@ -24,7 +24,8 @@ class HUD //responsible for drawing hud
IntentIcon,
RewardMenu,
InitiativeBar,
AchievementsScreen
AchievementsScreen,
Overlay
};
public:
HUD(const Menu& menu,FrameCommander& fc, DXGraphics& gfx, const ActionBox& abox,const CombatManager& cm);
......
#include "HudOverlay.h"
#include <algorithm>
#include "Framework\ConstantBuffersEx.h"
#include "Framework\PixelShader.h"
HudOverlay::HudOverlay(DXGraphics& gfx):
overlay(L"Media//Sprites//statusBar_bleedAct.png",gfx),
gfx(gfx)
{
auto& s = overlay.GetTechniquesReference()[0].GetSteps()[0];
s.DeleteBindableByUID(L"class Bind::PixelShader#HudPS.cso");
s.AddBindable(Bind::PixelShader::Resolve(gfx, L"HUDEffectPS.cso"));
auto pcb = std::make_shared<Bind::PixelConstantBuffer<Opac>>(gfx, 3);
cbuf = pcb;
s.AddBindable(pcb);
pos.emplace_back(0.0f, 0.0f, 1.0f, 0.0f);
overlay.BindPositionData(&pos);
}
void HudOverlay::BoostOverlay(float boost) //is called from PlayerManager::SufferPhysicalDamage, EntityManager::SufferPureDamage
{
pendingPower += boost;
}
void HudOverlay::SmartSubmit(FrameCommander& fc) const
{
if (currentPower != 0.0f)
{
cbuf->Update(gfx, { currentPower,0.0f,0.0f,0.0f });
overlay.SmartSubmit(fc);
}
}
void HudOverlay::Animate(float dt) //animated by HUD
{
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;
}
float HudOverlay::pendingPower = 0.0f;
\ No newline at end of file
#pragma once
#include "Framework\HudElement.h"
class HudOverlay : public HudElement
{
public:
HudOverlay(DXGraphics& gfx);
static void BoostOverlay(float boost); //1.0f - a lot of boost
void SmartSubmit(FrameCommander& fc)const override;
void Animate(float dt) override;
private:
struct Opac
{
float val;
float pad0;
float pad1;
float pad2;
};
HudElement overlay;
float currentPower = 0.0f;
std::vector<PositionData> pos;
std::shared_ptr <Bind::PixelConstantBuffer<Opac>> cbuf = nullptr;
static float pendingPower;
static constexpr float falloff = 58.5f;
static constexpr float changeSensitivity = 5.99f;
DXGraphics& gfx;
};
......@@ -4,6 +4,7 @@
#include "SoundPlayerInterface.h"
#include "Skills0.h"
#include "AchievementManager.h"
#include "HudOverlay.h"
PlayerManager::PlayerManager():
actionBox(skillPool)
......@@ -101,6 +102,7 @@ size_t PlayerManager::SufferPhysicalDamage(size_t incDmg)
if (block) SPI::Play(Sounds::Player_Block, 1.0f, (std::max)(0.1f, (std::min)(0.8f, block*0.015f)));
SPI::Play(Sounds::Player_Hit, 1.0f, (std::max)(0.1f, (std::min)(0.9f, incDmg*0.09f))); //not sure if this works
AM::Alert(AM::Event::PlayerLostHP);
HudOverlay::BoostOverlay(std::max(0.45f, 0.03857f * (float)incDmg));
return incDmg;
}
}
......@@ -110,6 +112,7 @@ size_t PlayerManager::SufferPhysicalDamage(size_t incDmg)
HP = 0;
OnDeath();
AM::Alert(AM::Event::PlayerLostHP);
HudOverlay::BoostOverlay(1.5f);
return dmg;
}
}
......
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