diff --git a/Crawler/Crawler b/Crawler/Crawler index e95c06e7..95857e93 100755 Binary files a/Crawler/Crawler and b/Crawler/Crawler differ diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 0febed67..c82f6bd7 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -699,6 +699,20 @@ void Crawler::RenderHud(){ } 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<GetHealth()>0?std::to_string(player->GetHealth()):"X"; diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 7f829697..16f9c9c9 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -163,6 +163,7 @@ void Player::Update(float fElapsedTime){ notEnoughManaDisplay.second=std::max(0.f,notEnoughManaDisplay.second-fElapsedTime); notificationDisplay.second=std::max(0.f,notificationDisplay.second-fElapsedTime); manaTickTimer-=fElapsedTime; + castInfo.castTimer=std::max(0.f,castInfo.castTimer-fElapsedTime); while(manaTickTimer<=0){ manaTickTimer+=0.2; mana=std::min(maxmana,mana+1); @@ -481,6 +482,14 @@ std::vectorPlayer::GetBuffs(BuffType buff){ 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){ std::vectorpathing=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. diff --git a/Crawler/Player.h b/Crawler/Player.h index 8d2012fb..eee3ce0a 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -8,6 +8,13 @@ #include "Buff.h" #include "Pathfinding.h" + +struct CastInfo{ + std::string name; + float castTimer; + float castTotalTime; +}; + struct Player{ friend class Crawler; friend class sig::Animation; @@ -34,6 +41,7 @@ struct Player{ void Update(float fElapsedTime); void AddAnimation(AnimationState state); std::vectorbuffList; + CastInfo castInfo={"",0}; protected: const float ATTACK_COOLDOWN=0.35f; const float MAGIC_ATTACK_COOLDOWN=0.85f; @@ -60,6 +68,7 @@ protected: float attack_range=1.5f; Key facingDirection; float swordSwingTimer=0; + void CastSpell(std::string name,float castTotalTime); public: 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 @@ -121,6 +130,8 @@ public: virtual AnimationState&GetIdleEAnimation()=0; virtual AnimationState&GetIdleSAnimation()=0; virtual AnimationState&GetIdleWAnimation()=0; + + CastInfo&GetCastInfo(); }; struct Warrior:Player{ diff --git a/Crawler/Wizard.cpp b/Crawler/Wizard.cpp index 39df1c67..95f2d394 100644 --- a/Crawler/Wizard.cpp +++ b/Crawler/Wizard.cpp @@ -73,7 +73,7 @@ bool Wizard::AutoAttack(){ return true; } void Wizard::InitializeClassAbilities(){ - #pragma region Wizard Right-click Ability (???) + #pragma region Wizard Right-click Ability (Teleport) Wizard::rightClickAbility.action= [&](){ float pointMouseDirection=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); @@ -101,7 +101,7 @@ void Wizard::InitializeClassAbilities(){ } }; #pragma endregion - #pragma region Wizard Ability 1 (???) + #pragma region Wizard Ability 1 (Fire Bolt) Wizard::ability1.action= [&](){ float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); @@ -109,7 +109,7 @@ void Wizard::InitializeClassAbilities(){ return true; }; #pragma endregion - #pragma region Wizard Ability 2 (???) + #pragma region Wizard Ability 2 (Lightning Bolt) Wizard::ability2.action= [&](){ float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); @@ -117,10 +117,11 @@ void Wizard::InitializeClassAbilities(){ return true; }; #pragma endregion - #pragma region Wizard Ability 3 (???) + #pragma region Wizard Ability 3 (Meteor) Wizard::ability3.action= [&](){ SetState(State::CASTING); + CastSpell("Meteor",1.5); game->AddEffect(std::make_unique(GetPos(),3,AnimationState::METEOR,OnUpperLevel(),vf2d{1,1},2)); return true; };