Example #1
0
void KBall::CheckWhetherScored()
{
    KG_PROCESS_ERROR(m_bLastFrameState);
    KG_PROCESS_ERROR(!m_bCurFrameState);
    KG_PROCESS_ERROR(m_nVelocityZ < 0);

    //m_nVelocityZ = 0;
    m_bLastFrameState = false;
    m_bCurFrameState  = false;

    {
        BOOL bRetCode = false;
        KHero* pShooter = NULL;
        KPlayer* pPlayer = NULL;

        KGLOG_PROCESS_ERROR(m_pTargetSocket);

        pShooter = m_pScene->GetHeroById(m_dwShooterID);
        if (pShooter && pShooter->IsMainHero())
            pPlayer = pShooter->GetOwner();
        
        if (pPlayer)
        {
            KPLAYER_EVENT eEvent = peInvalid;

            switch (m_pTargetSocket->m_eFloor)
            {
            case bfFirst:
            case bfSecond:
                eEvent = peShootFirstSuccess;
                break;
            case bfThird:
            case bfForth:
                eEvent = peShootSecondSuccess;
                break;
            case bfFifth:
            case bfSixth:
                eEvent = peShootThirdSuccess;
                break;
            default:
                assert(false);
            }

            pPlayer->OnEvent(eEvent);
			pPlayer->OnEvent(peShootSuccess);
        }

        if (m_pTargetSocket->m_eFloor == bfFifth || m_pTargetSocket->m_eFloor == bfThird)
        {
            m_bDoDropRebound = true;
        }
    }
    
    m_pScene->OnShootBallSuccess(this, m_pTargetSocket);

Exit0:
    return;
}