Make swatter disappear after one hit in 3 strikes battle
This commit is contained in:
parent
ba706f4476
commit
21c38a6c0b
@ -112,6 +112,7 @@ Swatter::~Swatter()
|
|||||||
*/
|
*/
|
||||||
bool Swatter::updateAndTestFinished(float dt)
|
bool Swatter::updateAndTestFinished(float dt)
|
||||||
{
|
{
|
||||||
|
bool discard_now = false;
|
||||||
if (m_removing_bomb)
|
if (m_removing_bomb)
|
||||||
{
|
{
|
||||||
m_swat_bomb_frame += dt*25.0f;
|
m_swat_bomb_frame += dt*25.0f;
|
||||||
@ -181,7 +182,12 @@ bool Swatter::updateAndTestFinished(float dt)
|
|||||||
{
|
{
|
||||||
// Squash the karts and items around and
|
// Squash the karts and items around and
|
||||||
// change the current phase
|
// change the current phase
|
||||||
squashThingsAround();
|
if (squashThingsAround() &&
|
||||||
|
race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES)
|
||||||
|
{
|
||||||
|
//Remove swatter from kart in 3 strikes battle after one successful hit
|
||||||
|
discard_now = true;
|
||||||
|
}
|
||||||
m_animation_phase = SWATTER_FROM_TARGET;
|
m_animation_phase = SWATTER_FROM_TARGET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +200,7 @@ bool Swatter::updateAndTestFinished(float dt)
|
|||||||
// If the swatter is used up, trigger cleaning up
|
// If the swatter is used up, trigger cleaning up
|
||||||
// TODO: use a timeout
|
// TODO: use a timeout
|
||||||
// TODO: how does it work currently...?
|
// TODO: how does it work currently...?
|
||||||
return false;
|
return (discard_now ? true : false);
|
||||||
} // updateAndTestFinished
|
} // updateAndTestFinished
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -261,8 +267,9 @@ void Swatter::pointToTarget()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Squash karts or items that are around the end position (determined using
|
/** Squash karts or items that are around the end position (determined using
|
||||||
* a joint) of the swatter.
|
* a joint) of the swatter.
|
||||||
|
* \return True if target kart is hit.
|
||||||
*/
|
*/
|
||||||
void Swatter::squashThingsAround()
|
bool Swatter::squashThingsAround()
|
||||||
{
|
{
|
||||||
const KartProperties* kp = m_kart->getKartProperties();
|
const KartProperties* kp = m_kart->getKartProperties();
|
||||||
// Square of the minimum distance
|
// Square of the minimum distance
|
||||||
@ -277,6 +284,7 @@ void Swatter::squashThingsAround()
|
|||||||
|
|
||||||
m_swat_sound->setPosition(swatter_pos);
|
m_swat_sound->setPosition(swatter_pos);
|
||||||
m_swat_sound->play();
|
m_swat_sound->play();
|
||||||
|
bool target_is_hit = false;
|
||||||
|
|
||||||
// Squash karts around
|
// Squash karts around
|
||||||
for(unsigned int i=0; i<world->getNumKarts(); i++)
|
for(unsigned int i=0; i<world->getNumKarts(); i++)
|
||||||
@ -295,6 +303,7 @@ void Swatter::squashThingsAround()
|
|||||||
|
|
||||||
kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(),
|
kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(),
|
||||||
kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown());
|
kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown());
|
||||||
|
target_is_hit = true;
|
||||||
|
|
||||||
//Handle achievement if the swatter is used by the current player
|
//Handle achievement if the swatter is used by the current player
|
||||||
const StateManager::ActivePlayer *const ap = m_kart->getController()
|
const StateManager::ActivePlayer *const ap = m_kart->getController()
|
||||||
@ -316,6 +325,7 @@ void Swatter::squashThingsAround()
|
|||||||
} // if kart has bomb attached
|
} // if kart has bomb attached
|
||||||
World::getWorld()->kartHit(kart->getWorldKartId());
|
World::getWorld()->kartHit(kart->getWorldKartId());
|
||||||
} // for i < num_kartrs
|
} // for i < num_kartrs
|
||||||
|
return target_is_hit;
|
||||||
|
|
||||||
// TODO: squash items
|
// TODO: squash items
|
||||||
} // squashThingsAround
|
} // squashThingsAround
|
||||||
|
@ -91,7 +91,7 @@ private:
|
|||||||
void pointToTarget();
|
void pointToTarget();
|
||||||
|
|
||||||
/** Squash karts or items that are around the end position (determined using a joint) of the swatter */
|
/** Squash karts or items that are around the end position (determined using a joint) of the swatter */
|
||||||
void squashThingsAround();
|
bool squashThingsAround();
|
||||||
}; // Swatter
|
}; // Swatter
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user