Switch to smart pointer implementation for damage numbers to handle damage combo'ing quick attack displays.

This commit is contained in:
2023-07-25 19:48:24 -05:00
parent 9585baf5c6
commit a0916cfe9b
9 changed files with 49 additions and 19 deletions
+10 -1
View File
@@ -162,6 +162,7 @@ void Player::Update(float fElapsedTime){
iframe_time=std::max(0.f,iframe_time-fElapsedTime);
notEnoughManaDisplay.second=std::max(0.f,notEnoughManaDisplay.second-fElapsedTime);
notificationDisplay.second=std::max(0.f,notificationDisplay.second-fElapsedTime);
lastHitTimer=std::max(0.f,lastHitTimer-fElapsedTime);
manaTickTimer-=fElapsedTime;
if(castInfo.castTimer>0){
castInfo.castTimer-=fElapsedTime;
@@ -471,7 +472,15 @@ bool Player::Hurt(int damage,bool onUpperLevel){
mod_dmg-=damage*b.intensity;
}
hp=std::max(0,hp-int(mod_dmg));
DAMAGENUMBER_LIST.push_back(DamageNumber(pos,int(mod_dmg)));
if(lastHitTimer>0){
damageNumberPtr.get()->damage+=int(mod_dmg);
damageNumberPtr.get()->pauseTime=0.4;
} else {
DAMAGENUMBER_LIST.push_back(std::make_shared<DamageNumber>(pos,int(mod_dmg)));
std::shared_ptr<DamageNumber>numb=*(DAMAGENUMBER_LIST.end()-1);
damageNumberPtr=numb;
}
lastHitTimer=0.05;
return true;
}