/** Overloading setKartAnimation with a kind of listener function in order
 *  to gather statistics about rescues and explosions.
 */
void KartWithStats::setKartAnimation(AbstractKartAnimation *ka)
{
    bool is_new = !getKartAnimation() && !isInvulnerable() && !isShielded();
    Kart::setKartAnimation(ka);
    // Nothing to count if it's not a new animation
    if(!is_new) return;

    // We can't use a dynamic cast here, since this function is called from
    // constructor of AbstractKartAnimation, which is the base class for all
    // animations. So at this stage ka is only an AbstractKartAnimation, not
    // any of the derived classes.
    if(ka && ka->getName()=="ExplosionAnimation")
    {
        m_explosion_count ++;
        m_explosion_time += ka->getAnimationTimer();
    }
    else if(ka && ka->getName()=="RescueAnimation")
    {
        m_rescue_count ++;
        m_rescue_time += ka->getAnimationTimer();
    }
}   // setKartAnimation
示例#2
0
文件: Player.cpp 项目: 8102/R-Type
void Player::getDrawn(sf::RenderWindow & win)
{
	win.draw(*this);
	if (isShielded() == true)
		win.draw(_shield);
}
示例#3
0
文件: Player.cpp 项目: 8102/R-Type
bool Player::collide(AGameElement const & collider, bool const &shieldCollision) const
{
	if (isShielded() == true && shieldCollision == true)
		return collider.collide(_shield);
	return collider.collide(*this);
}