示例#1
0
BOOL KBall::PassTo(KHero* pPasser, KHero* pReceiver)
{
    BOOL bResult = false;
    BOOL bRetCode = false;
    KPOSITION cSrcPos;
    KPOSITION cDstPos;
    KFix2PParabola cPath(GetCurrentGravity());
    int       nZMax = 0;

    KGLOG_PROCESS_ERROR(pPasser && pReceiver);
    KGLOG_PROCESS_ERROR(pPasser->m_dwID != pReceiver->m_dwID);

    bRetCode = IsTokenBy(pPasser);
    KG_PROCESS_ERROR(bRetCode);

    cSrcPos = GetPassSrcPos(pPasser, pReceiver);
    cDstPos = GetPassDstPos(pPasser, pReceiver);
    nZMax = GetPassZMax(cSrcPos, cDstPos);

    cPath.SetCtrlParams(cSrcPos, cDstPos, nZMax);
    cPath.Start(g_pSO3World->m_nGameLoop);

    DoTrackMove(&cPath);

    pPasser->ForbitAutoTakeBall(GAME_FPS);

    bResult = true;
Exit0:
    return bResult;
}
示例#2
0
/** \brief MouseUp Callback.
 * This handles the situation where someone does a drag and drop of an item.
 * In this case we should copy it to the desired location.
 *
 * \todo Implement recursive transfer when a folder is dropped.
 */
void RemoteIconView::MouseUp( const Point& cPoint, uint32 nButtons, Message* pcData )
{
	if( pcData == NULL || m_pcServer == NULL ) {
		/* No drag & drop, or no connection */
		IconView::MouseUp( cPoint, nButtons, pcData );
		return;
	}
	StopScroll();
	
	/* We got a drag & drop. Check if it contains a local file */
	int nCount, nType;
	pcData->GetNameInfo( "file/path", &nType, &nCount );
	if( nType != T_STRING || nCount == 0 ) {
		/* Something was dropped that isn't a file. Ignore it */
		IconView::MouseUp( cPoint, nButtons, pcData );
		return;
	}
	
	/* Check if there is a directory icon under the mouse. If so, we transfer the file into that directory.
	   Otherwise, we transfer it into this directory. */
	String zDestPath = m_zPath;
	for( uint i = 0; i < GetIconCount(); i++ ) {
		if( Rect( GetIconPosition( i ), GetIconPosition( i ) + GetIconSize() ).DoIntersect( ConvertToView( cPoint ) ) ) {
			/* Found an icon under the mouse */
			RemoteIconData* pcData = (RemoteIconData*)GetIconData( i );
			if( pcData->m_cNode.IsDir() ) {
				/* Found a dir under the mouse. Add it to the destination path */
				zDestPath += "/";
				zDestPath += pcData->m_cNode.m_zName;
				break;
			}
		}
	}
	
	/* Start transferring the files */
	String zSource;
	String zDest;
	for( int i = 0; pcData->FindString( "file/path", &zSource, i ) == 0; i++ )
	{
		Path cPath( zSource );
		zDest = zDestPath;
		if( zDest.Length() > 0 && zDest[zDest.Length()-1] != '/' ) zDest += "/";
		zDest += cPath.GetLeaf();
		DEBUG( "GUI: Drag & drop %s to %s\n", zSource.c_str(), zDest.c_str() );
		
		/* Ask the Server object to start the transfer */
		/* Need to determine if it is a file or a dir first though */
		FileReference cFileRef( zSource );
		struct stat sStat;
		cFileRef.GetStat( &sStat );
		if( S_ISDIR( sStat.st_mode ) ) {
			m_pcServer->SendLocalDir( zSource, zDest );
		} else {
			m_pcServer->SendLocalFile( zSource, zDest );
		}
	}
}
示例#3
0
BOOL KBall::BeShoot(KHero* pShooter, KBasketSocket* pTargetSocket, int nInterference)
{
    BOOL            bResult                 = false;
    BOOL            bRetCode                = false;
    int             nNowHitRate             = 0;
    int             nNowAttenuationTimes    = 0;
    KFix2PParabola  cPath(GetCurrentGravity());
    int             nZmax                   = 0;
    KPOSITION       cStart;
    KPOSITION       cEnd;

    KGLOG_PROCESS_ERROR(pShooter && pTargetSocket);

    bRetCode = CanBeShootBy(pShooter);
    KGLOG_PROCESS_ERROR(bRetCode);

    cStart = GetShootStartPos(pShooter);
    cEnd =  GetShootEndPos(pTargetSocket);

    pShooter->CalcHitRateParams(cStart, cEnd, nNowAttenuationTimes, nNowHitRate, nInterference);
    m_bCanHit = pShooter->RandomHitted(nNowHitRate);

    LogInfo(
        "Canhit:%d, hitrate:%d, virtualframe:%d, nInterference:%d", 
        m_bCanHit, nNowHitRate, pShooter->m_nVirtualFrame, nInterference
    );

    if (!m_bCanHit)
    {
        int nFlag = 1;
        if (nNowAttenuationTimes % 2 == 0)
            nFlag = -1;
        cEnd.nX += nFlag * pShooter->m_nMaxHitOffset * (HUNDRED_NUM - nNowHitRate) / HUNDRED_NUM;
        cEnd.nY += nFlag * pShooter->m_nMaxHitOffset * (HUNDRED_NUM - nNowHitRate) / HUNDRED_NUM;
    }

    nZmax = CalcProcessTrackMoveZmax(pShooter->m_nVirtualFrame, cStart, cEnd);

    cPath.SetCtrlParams(cStart, cEnd, nZmax);
    cPath.Start(g_pSO3World->m_nGameLoop);
    DoTrackMove(&cPath);

    m_nTotalFrame   = cPath.GetTotalFrame();
    m_pTargetSocket = pTargetSocket;
    m_dwShooterID   = pShooter->m_dwID;
    m_dwThrowerID   = ERROR_ID;

    bResult = true;
Exit0:
    return bResult;
}
示例#4
0
BOOL KBall::SkillShoot(KHero* pShooter, KBasketSocket* pSocket)
{
    BOOL            bResult     = false;
    BOOL            bRetCode    = false;
    int             nVelocity   = CELL_LENGTH;
    KSkillShootPath cPath((GetCurrentGravity()));
    KPOSITION       cSocketPos;
    KPOSITION       cSrc;
    KPOSITION       cDst;
    KPOSITION       cCtrl;
    
    KGLOG_PROCESS_ERROR(pShooter && pSocket);

    bRetCode = CanBeShootBy(pShooter);
    KG_PROCESS_ERROR(bRetCode);

    cSocketPos = pSocket->GetPosition();

    cSrc = GetShootStartPos(pShooter);

    cDst = cSocketPos;
    cDst.nZ += CELL_LENGTH * 3;

    cCtrl.nX = (pSocket->m_eDir == csdLeft) ? cSocketPos.nX - (CELL_LENGTH * 12) : cSocketPos.nX + (CELL_LENGTH * 12);
    cCtrl.nY = cSocketPos.nY;
    cCtrl.nZ = CELL_LENGTH * 4;

    cPath.SetCtrlParams(cSrc, cDst, cCtrl, nVelocity);
    cPath.Start(g_pSO3World->m_nGameLoop);

    DoTrackMove(&cPath);

    m_bAttackState = true;
    m_dwShooterID = pShooter->m_dwID;
    m_dwThrowerID = ERROR_ID;
    m_pTargetSocket = pSocket;
    m_bRestAfterTrackMove = true;

    bResult = true;
Exit0:
    return bResult;
}
示例#5
0
BOOL KBall::SkillSlamEx(KHero* pSlamer, KSlamBallSkill* pSkill, KBasketSocket* pTargetSocket)
{
    BOOL            bResult                 = false;
    BOOL            bRetCode                = false;
    int             nNowHitRate             = 0;
    int             nNowAttenuationTimes    = 0;
    int             nZmax                   = 0;
    KFix2PParabola  cPath(GetCurrentGravity());
    KPOSITION       cSrc;
    KPOSITION       cDst;
    int             nTotalFrame             = 0;

    KG_PROCESS_ERROR(pSlamer && pTargetSocket);

    bRetCode = CanSkillSlam(pSlamer, pTargetSocket);
    KGLOG_PROCESS_ERROR(bRetCode);

    cSrc = GetShootStartPos(pSlamer);
    cDst = GetSkillSlamDstPos(pSlamer, pTargetSocket);

    nZmax = CalcProcessTrackMoveZmax(pSlamer->m_nVirtualFrame, cSrc, cDst);

    cPath.SetCtrlParams(cSrc, cDst, nZmax);
    cPath.Start(pSlamer->m_nVirtualFrame);
    pSlamer->DoTrackMove(&cPath);
    nTotalFrame = cPath.GetTotalFrame();
    pSlamer->LoseControlByCounter(nTotalFrame);

    m_bCanHit = true;
    m_nTotalFrame = cPath.GetTotalFrame();
    m_pTargetSocket = pTargetSocket;
    m_dwShooterID = pSlamer->m_dwID;
    m_dwThrowerID = ERROR_ID;

    bResult = true;
Exit0:
    return bResult;
}
示例#6
0
void MainWindow::HandleMessage( os::Message* pcMessage )
{
	switch( pcMessage->GetCode() )
	{
		case M_CHANGE_DIR:
		{
			os::String zPath;
			if( pcMessage->FindString( "file/path", &zPath.str() ) != 0 )
				break;
			
			m_pcView->SetPath( zPath );
			m_pcView->Clear();
			LoadWindow( true );
			m_pcView->ReRead();
			
			/* Get the new directory icon */
			os::BitmapImage* pcImage = static_cast<os::BitmapImage*>(m_pcView->GetDirIcon());
			if( pcImage )
			{
				pcImage->SetSize( os::Point( 24, 24 ) );
				SetIcon( pcImage->LockBitmap() );
				delete( pcImage );
			}
			SetTitle( m_pcView->GetPath() );
			m_cBackStack.push( m_pcView->GetPath() );
			if( m_cBackStack.size() > 1 )
				m_pcBackButton->SetEnable( true );
			else
				m_pcBackButton->SetEnable( false );
			
			break;
		}
		case M_BACK:
		{
			if( m_cBackStack.size() > 1 )
			{
				m_cBackStack.pop();
				os::String cNewPath = m_cBackStack.top();
				m_cBackStack.pop();
				os::Message* pcMsg = new os::Message( M_CHANGE_DIR );
				pcMsg->AddString( "file/path", cNewPath );
				PostMessage( pcMsg, this );
				delete( pcMsg );
			}
			break;
		}
		case M_UP:
		{
			os::Message* pcMsg = new os::Message( M_CHANGE_DIR );
			os::Path cPath( m_pcView->GetPath().c_str() );
			pcMsg->AddString( "file/path", cPath.GetDir().GetPath() );
			PostMessage( pcMsg, this );
			delete( pcMsg );
			break;
		}
		case M_HOME:
		{
			const char *pzHome = getenv( "HOME" );
			os::Message* pcMsg = new os::Message( M_CHANGE_DIR );
			pcMsg->AddString( "file/path", pzHome );
			PostMessage( pcMsg, this );
			delete( pcMsg );
			break;
		}
		case M_RELOAD:
		{
			m_pcView->ReRead();
			break;
		}
		case M_VIEW_ICONS:
		{
			m_pcView->SetView( os::IconDirectoryView::VIEW_ICONS );
			m_pcView->ReRead();  /* ReRead after view change to ensure that correct-sized icons are used */
			break;
		}
		case M_VIEW_LIST:
		{
			m_pcView->SetView( os::IconDirectoryView::VIEW_LIST );
			m_pcView->ReRead();
			break;
		}
		case M_VIEW_DETAILS:
		{
			m_pcView->SetView( os::IconDirectoryView::VIEW_DETAILS );
			m_pcView->ReRead();
			break;
		}
		case M_SAVE_WINDOW:
		{
			SaveWindow();
			break;
		}
		case M_SAVE_DEFAULT:
		{
			SaveDefault();
			break;
		}
		case M_APP_QUIT:
		{
			OkToQuit();
			break;
		}
		
		break;
	}
}