Cast bar display implementation
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
f48f0b4a3c
commit
40c576eb17
BIN
Crawler/Crawler
BIN
Crawler/Crawler
Binary file not shown.
@ -699,6 +699,20 @@ void Crawler::RenderHud(){
|
|||||||
}
|
}
|
||||||
offset-=6;
|
offset-=6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(GetPlayer()->GetCastInfo().castTimer>0){
|
||||||
|
FillRectDecal(vf2d{ScreenWidth()/2-92.f,ScreenHeight()-90.f},{184,20},BLACK);
|
||||||
|
FillRectDecal(vf2d{ScreenWidth()/2-90.f,ScreenHeight()-88.f},{180,16},DARK_GREY);
|
||||||
|
float timer=GetPlayer()->GetCastInfo().castTimer;
|
||||||
|
float totalTime=GetPlayer()->GetCastInfo().castTotalTime;
|
||||||
|
std::string castText=GetPlayer()->GetCastInfo().name;
|
||||||
|
GradientFillRectDecal(vf2d{ScreenWidth()/2-90.f,ScreenHeight()-88.f},{(timer/totalTime)*180,16},{247,125,37},{247,125,37},{247,184,37},{247,184,37});
|
||||||
|
std::stringstream castTimeDisplay;
|
||||||
|
castTimeDisplay<<std::fixed<<std::setprecision(1)<<timer;
|
||||||
|
DrawShadowStringPropDecal(vf2d{ScreenWidth()/2+90.f,ScreenHeight()-88.f}-vf2d{float(GetTextSizeProp(castTimeDisplay.str()).x),0},castTimeDisplay.str(),WHITE,BLACK);
|
||||||
|
DrawShadowStringPropDecal(vf2d{ScreenWidth()/2.f-GetTextSizeProp(castText).x*2/2,ScreenHeight()-64.f},castText,WHITE,BLACK,{2,3},2.f);
|
||||||
|
}
|
||||||
|
|
||||||
DrawDecal({2,2},GFX_Heart.Decal());
|
DrawDecal({2,2},GFX_Heart.Decal());
|
||||||
DrawDecal({2,20},GFX_Mana.Decal());
|
DrawDecal({2,20},GFX_Mana.Decal());
|
||||||
std::string text=player->GetHealth()>0?std::to_string(player->GetHealth()):"X";
|
std::string text=player->GetHealth()>0?std::to_string(player->GetHealth()):"X";
|
||||||
|
@ -163,6 +163,7 @@ void Player::Update(float fElapsedTime){
|
|||||||
notEnoughManaDisplay.second=std::max(0.f,notEnoughManaDisplay.second-fElapsedTime);
|
notEnoughManaDisplay.second=std::max(0.f,notEnoughManaDisplay.second-fElapsedTime);
|
||||||
notificationDisplay.second=std::max(0.f,notificationDisplay.second-fElapsedTime);
|
notificationDisplay.second=std::max(0.f,notificationDisplay.second-fElapsedTime);
|
||||||
manaTickTimer-=fElapsedTime;
|
manaTickTimer-=fElapsedTime;
|
||||||
|
castInfo.castTimer=std::max(0.f,castInfo.castTimer-fElapsedTime);
|
||||||
while(manaTickTimer<=0){
|
while(manaTickTimer<=0){
|
||||||
manaTickTimer+=0.2;
|
manaTickTimer+=0.2;
|
||||||
mana=std::min(maxmana,mana+1);
|
mana=std::min(maxmana,mana+1);
|
||||||
@ -481,6 +482,14 @@ std::vector<Buff>Player::GetBuffs(BuffType buff){
|
|||||||
return filteredBuffs;
|
return filteredBuffs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::CastSpell(std::string name,float castTotalTime){
|
||||||
|
castInfo={name,castTotalTime,castTotalTime};
|
||||||
|
}
|
||||||
|
|
||||||
|
CastInfo&Player::GetCastInfo(){
|
||||||
|
return castInfo;
|
||||||
|
}
|
||||||
|
|
||||||
bool Player::CanPathfindTo(vf2d pos,vf2d targetPos,float range){
|
bool Player::CanPathfindTo(vf2d pos,vf2d targetPos,float range){
|
||||||
std::vector<vf2d>pathing=game->pathfinder.Solve_AStar(pos,targetPos,8,upperLevel);
|
std::vector<vf2d>pathing=game->pathfinder.Solve_AStar(pos,targetPos,8,upperLevel);
|
||||||
return pathing.size()>0&&pathing.size()<8;//We'll say 7 tiles or less is close enough to 650 range. Have a little bit of wiggle room.
|
return pathing.size()>0&&pathing.size()<8;//We'll say 7 tiles or less is close enough to 650 range. Have a little bit of wiggle room.
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
#include "Buff.h"
|
#include "Buff.h"
|
||||||
#include "Pathfinding.h"
|
#include "Pathfinding.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct CastInfo{
|
||||||
|
std::string name;
|
||||||
|
float castTimer;
|
||||||
|
float castTotalTime;
|
||||||
|
};
|
||||||
|
|
||||||
struct Player{
|
struct Player{
|
||||||
friend class Crawler;
|
friend class Crawler;
|
||||||
friend class sig::Animation;
|
friend class sig::Animation;
|
||||||
@ -34,6 +41,7 @@ struct Player{
|
|||||||
void Update(float fElapsedTime);
|
void Update(float fElapsedTime);
|
||||||
void AddAnimation(AnimationState state);
|
void AddAnimation(AnimationState state);
|
||||||
std::vector<Buff>buffList;
|
std::vector<Buff>buffList;
|
||||||
|
CastInfo castInfo={"",0};
|
||||||
protected:
|
protected:
|
||||||
const float ATTACK_COOLDOWN=0.35f;
|
const float ATTACK_COOLDOWN=0.35f;
|
||||||
const float MAGIC_ATTACK_COOLDOWN=0.85f;
|
const float MAGIC_ATTACK_COOLDOWN=0.85f;
|
||||||
@ -60,6 +68,7 @@ protected:
|
|||||||
float attack_range=1.5f;
|
float attack_range=1.5f;
|
||||||
Key facingDirection;
|
Key facingDirection;
|
||||||
float swordSwingTimer=0;
|
float swordSwingTimer=0;
|
||||||
|
void CastSpell(std::string name,float castTotalTime);
|
||||||
public:
|
public:
|
||||||
Player();
|
Player();
|
||||||
//So this is rather fascinating and only exists because we have the ability to change classes which means we need to initialize a class
|
//So this is rather fascinating and only exists because we have the ability to change classes which means we need to initialize a class
|
||||||
@ -121,6 +130,8 @@ public:
|
|||||||
virtual AnimationState&GetIdleEAnimation()=0;
|
virtual AnimationState&GetIdleEAnimation()=0;
|
||||||
virtual AnimationState&GetIdleSAnimation()=0;
|
virtual AnimationState&GetIdleSAnimation()=0;
|
||||||
virtual AnimationState&GetIdleWAnimation()=0;
|
virtual AnimationState&GetIdleWAnimation()=0;
|
||||||
|
|
||||||
|
CastInfo&GetCastInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Warrior:Player{
|
struct Warrior:Player{
|
||||||
|
@ -73,7 +73,7 @@ bool Wizard::AutoAttack(){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void Wizard::InitializeClassAbilities(){
|
void Wizard::InitializeClassAbilities(){
|
||||||
#pragma region Wizard Right-click Ability (???)
|
#pragma region Wizard Right-click Ability (Teleport)
|
||||||
Wizard::rightClickAbility.action=
|
Wizard::rightClickAbility.action=
|
||||||
[&](){
|
[&](){
|
||||||
float pointMouseDirection=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x);
|
float pointMouseDirection=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x);
|
||||||
@ -101,7 +101,7 @@ void Wizard::InitializeClassAbilities(){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
#pragma region Wizard Ability 1 (???)
|
#pragma region Wizard Ability 1 (Fire Bolt)
|
||||||
Wizard::ability1.action=
|
Wizard::ability1.action=
|
||||||
[&](){
|
[&](){
|
||||||
float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x);
|
float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x);
|
||||||
@ -109,7 +109,7 @@ void Wizard::InitializeClassAbilities(){
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
#pragma region Wizard Ability 2 (???)
|
#pragma region Wizard Ability 2 (Lightning Bolt)
|
||||||
Wizard::ability2.action=
|
Wizard::ability2.action=
|
||||||
[&](){
|
[&](){
|
||||||
float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x);
|
float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x);
|
||||||
@ -117,10 +117,11 @@ void Wizard::InitializeClassAbilities(){
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
#pragma region Wizard Ability 3 (???)
|
#pragma region Wizard Ability 3 (Meteor)
|
||||||
Wizard::ability3.action=
|
Wizard::ability3.action=
|
||||||
[&](){
|
[&](){
|
||||||
SetState(State::CASTING);
|
SetState(State::CASTING);
|
||||||
|
CastSpell("Meteor",1.5);
|
||||||
game->AddEffect(std::make_unique<Meteor>(GetPos(),3,AnimationState::METEOR,OnUpperLevel(),vf2d{1,1},2));
|
game->AddEffect(std::make_unique<Meteor>(GetPos(),3,AnimationState::METEOR,OnUpperLevel(),vf2d{1,1},2));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user