Elevator* Elevator::setBalls(int newBalls) { while(getNumOfBalls() > newBalls) doShoot(); while(getNumOfBalls() < newBalls) newBall(); return this; }
void Viewer::VideoShooter::start(const DB::ImageInfoPtr& info, ViewerWidget* viewer) { qApp->setOverrideCursor( QCursor( Qt::BusyCursor ) ); m_info = info; m_viewer = viewer; // Hide the info box m_infoboxVisible = m_viewer->_infoBox->isVisible(); if ( m_infoboxVisible ) m_viewer->_infoBox->hide(); // Stop playback m_wasPlaying = !m_viewer->_videoDisplay->isPaused(); if ( m_wasPlaying ) m_viewer->_videoDisplay->playPause(); // Wait a bit for the context menu to disapear QTimer::singleShot(200, this, SLOT(doShoot())); }
void PenaltyPlan::decide() { vector <int> opps = pWorldData->mr_found_opponents(); Vector Me = pWorldData->me(true); Point ballPos = pWorldData->basedCenter(pWorldData->ball()); Point me(Me.getX() , Me.getY()); Point nearstOppToMe; if(opps.size() != 0) nearstOppToMe = pWorldData->basedCenter(pWorldData->opponent(pWorldData->getNearstOppToPoint(Me))); Point pole1 = pWorldData->oppPole1; Point pole2 = pWorldData->oppPole2; Point goalCenter((pole1.getX() + pole2.getX()) / 2, (pole1.getY() + pole2.getY()) / 2); if(opps.size() != 0) { if(!pBasicPlayer->can_kick()) { cout << "[PenaltyPlan] i'm dribbling" << endl; doDribble(); } else { if(me.getDistance(goalCenter) > 190) { cout << "[PenaltyPlan] i'm dribbling" << endl; doDribble(); } else { cout << "[PenaltyPlan] my dist from goalCenter: " << me.getDistance(goalCenter) << endl; cout << "[PenaltyPlan] i'm shooting" << endl; doShoot(); } } } }
bool Elevator::calculateBalls(int ballAdjustment) { bool handled = false; bool iEnterOn = !iEnter->Get(); bool iInOn = iIn->Get(); bool iTopOn = iTop->Get(); for(; ballAdjustment > 0; ballAdjustment--) newBall(); for(; ballAdjustment < 0; ballAdjustment++) doShoot(); //bool limboBallBefore = limboBall; if( iInOn && tIIn.Get() == 0) { tIIn.Start(); } else if( !iInOn && tIIn.Get() > Constants::elevatorBallSpeediIn) { limboBall = false; handled = false; //if(limboBallBefore) //cerr<<"Ball Has now Passed out of limbo"<<endl; } if( !iInOn ) { tIIn.Stop(); tIIn.Reset(); } if( iEnterOn && tIEnter.Get() == 0) { tIEnter.Start(); } else if( !iEnterOn && tIEnter.Get() > Constants::elevatorBallSpeediEnter) { if ( speed > 0 ) { newBall(); } } if( !iEnterOn ) { tIEnter.Stop(); tIEnter.Reset(); } if ( iEnterOn || limboBall ) { speed = 1; limboBall = true; handled = true; //if(!limboBallBefore) //cerr<<"Ball is now in limbo"<<endl; } iEnterOnBefore = iEnterOn; if( iTopOn && tITop.Get() == 0) // Ball was not previously in sensor. { tITop.Start(); } else if( !iTopOn && tITop.Get() > Constants::elevatorBallSpeed ) { // Ball went through sensor. if ( speed > 0 ) { cerr << tITop.Get() << endl; doShoot(); } } if (!iTopOn) // If the sensor is off, { tITop.Stop(); // Reset the timer. tITop.Reset(); // } return handled; }