//----------------------------------------------------------------- void GABot::prepareGame(void) { GAGame = new Game(this, TeamA, TeamB, 1000, 80, 40); TeamA->goals(0); TeamB->goals(0); GAGame->reset(); connect(GAGame, SIGNAL(ballMoved(Coordinate,Coordinate)), this, SLOT(slotBallMoved(Coordinate,Coordinate))); connect(GAGame, SIGNAL(teamAScores()), this,SLOT(slotTeamAScores()) ); connect(GAGame, SIGNAL(teamBScores()), this,SLOT(slotTeamBScores()) ); connect(GAGame, SIGNAL(clearField()), this, SLOT(slotClearField()) ); connect(GAGame, SIGNAL(gameOver()), this, SLOT(slotGameOver()) ); }
void MainWgt::unluzged() { int c = ui->lcdUnluzged->intValue() - 1; if (c < 0){ return; } ui->lcdUnluzged->display ( c ); if (c <= 0){ c = 0; emit gameOver(false); slotGameOver(false); } }
MainWindow::MainWindow() { setCaption(tr("GA Bots " VERSION)); initActions(); initMenuBar(); initToolBar(); initStatusBar(); initGABotDoc(); initView(); ViewToolBar->setOn(true); ViewStatusBar->setOn(true); //ViewGame->setOn(true); connect(GABotDoc, SIGNAL(gameReady(bool)), this, SLOT(slotGameReady(bool))); connect(GABotDoc, SIGNAL(teamAScores()), View, SLOT(slotScoreA())); connect(GABotDoc, SIGNAL(teamBScores()), View, SLOT(slotScoreB())); connect(GABotDoc, SIGNAL(clearScores()), View, SLOT(slotClearScores())); connect(GABotDoc, SIGNAL(moveTeamA(Coordinate, Coordinate)), View, SLOT(slotMoveTeamA(Coordinate, Coordinate))); connect(GABotDoc, SIGNAL(moveTeamB(Coordinate, Coordinate)), View, SLOT(slotMoveTeamB(Coordinate, Coordinate))); connect(GABotDoc, SIGNAL(turnTeamA(Coordinate, Direction)), View, SLOT(slotTurnTeamA(Coordinate, Direction))); connect(GABotDoc, SIGNAL(turnTeamB(Coordinate, Direction)), View, SLOT(slotTurnTeamB(Coordinate, Direction))); connect(GABotDoc, SIGNAL(moveBall(Coordinate,Coordinate)), View, SLOT(slotMoveBall(Coordinate,Coordinate))); connect(GoGame, SIGNAL(activated()), this, SLOT(slotGoGame())); connect(GoGame, SIGNAL(activated()), GABotDoc, SLOT(slotStartTimer())); connect(StopGame, SIGNAL(activated()), GABotDoc, SLOT(slotStopTimer())); connect(StopGame, SIGNAL(activated()), this, SLOT(slotStopGame())); connect(View, SIGNAL(valueChanged(int)), this, SLOT(slotTickInterval(int))); connect(GABotDoc, SIGNAL(clearField()), View, SLOT(slotClearField())); connect(ResetScreen, SIGNAL(activated()), View, SLOT(slotClearField())); //not sure if we should clear the field whenever regenerating the team // connect(TeamAGenerate,SIGNAL(activated()), View, SLOT(slotClearField())); // connect(TeamBGenerate,SIGNAL(activated()), View, SLOT(slotClearField())); connect(GABotDoc, SIGNAL(gameOver()), View, SLOT(slotClearField())); connect(GABotDoc, SIGNAL(gameOver()), View, SLOT(slotClearScores())); connect(GABotDoc, SIGNAL(gameOver()), this, SLOT(slotGameOver())); }
void Tank::slotTankShot(QString typeObject) { if (this->_shot == false) return; try { Bullet *bullet = this->shot(); bullet->nameObjectSender = typeObject; bullet->setData(0, OBJ_NAME_BULLET); this->_shot = false; connect( bullet, SIGNAL( signalDestroy() ) , this, SLOT( slotAllowShot() )); connect( bullet, SIGNAL( signalGameOver() ) , this, SLOT( slotGameOver() )); connect( bullet, SIGNAL( signalKillBot() ) , this, SLOT( slotKillBot() )); scene()->addItem(bullet); } catch (QString *str) { qDebug() << "Good"; } }
// Constructor Battleship::Battleship(QWidget *parent) : QMainWindow(parent) { QApplication::setStyle("plastique"); setupUi(this); gridLayoutHuman->sizePolicy().setHeightForWidth(true); gridLayoutEnemy->sizePolicy().setHeightForWidth(true); labelStatus = new QLabel(QString::fromUtf8("Press Ön to start the Game"), statusbar); statusbar->setSizeGripEnabled(true); statusbar->addWidget(labelStatus, 3); imageDialog = new ImageDialog(this); alignment = h; // set default alignment enemyPlayer = new AI(enemy, this); // Create players and their fields setupField(enemyPlayer); humanPlayer = new Human(human, this); setupField(humanPlayer); round = 0; // for first round gridLayoutHuman->installEventFilter(this); // EventFilter for right mouse button gridLayoutEnemy->setCursor(QCursor(Qt::ForbiddenCursor)); gridLayoutHuman->setCursor(QCursor(Qt::ForbiddenCursor)); // Buttons: connect(pushButtonEwo, SIGNAL(toggled(bool)), this, SLOT(slotSetEwoMode(bool))); connect(pushButtonStartGame, SIGNAL(clicked()), this, SLOT(slotStartGame())); // Place fleet & ships connect(this, SIGNAL(sigHumanPlaceShip(int, int, int)), humanPlayer, SLOT(slotPlaceShip(int, int, int))); connect(this, SIGNAL(sigPlaceFleet()), humanPlayer, SLOT(slotPlaceFleet())); connect(this, SIGNAL(sigPlaceFleet()), enemyPlayer, SLOT(slotPlaceFleet())); connect(humanPlayer, SIGNAL(sigFleetComplete()), this, SLOT(slotPlayerReady())); connect(enemyPlayer, SIGNAL(sigFleetComplete()), this, SLOT(slotPlayerReady())); // players get shot connect(this, SIGNAL(sigShotAtEnemy(int, int)), enemyPlayer, SLOT(slotShotAt(int, int))); connect(enemyPlayer, SIGNAL(sigShotAtHuman(int, int)), humanPlayer, SLOT(slotShotAt(int, int))); // toggle player turn connect(enemyPlayer, SIGNAL(sigDone(PlayerT)), this, SLOT(slotPlayerTurn(PlayerT))); connect(humanPlayer, SIGNAL(sigDone(PlayerT)), this, SLOT(slotPlayerTurn(PlayerT))); // AI shall shoot connect(this, SIGNAL(sigRequestShotFromEnemy()), enemyPlayer, SLOT(slotFire())); connect(humanPlayer, SIGNAL(sigEnemyTryAgain()), this, SLOT(slotRequestShotNow())); //Feedback of shots for AI connect(humanPlayer, SIGNAL(sigFireFeedback(int, int, ConditionT)), enemyPlayer, SLOT(slotFireFeedback(int, int, ConditionT))); // Game Over connect(enemyPlayer, SIGNAL(sigGameOver(PlayerT)), this, SLOT(slotGameOver(PlayerT))); connect(humanPlayer, SIGNAL(sigGameOver(PlayerT)), this, SLOT(slotGameOver(PlayerT))); // console output connect(humanPlayer, SIGNAL(sigPrint(QString)), this, SLOT(slotPrintToConsole(QString))); connect(enemyPlayer, SIGNAL(sigPrint(QString)), this, SLOT(slotPrintToConsole(QString))); //sound output connect(humanPlayer, SIGNAL(sigPlaySound(QString)), this, SLOT(slotPlaySound(QString))); connect(enemyPlayer, SIGNAL(sigPlaySound(QString)), this, SLOT(slotPlaySound(QString))); connect(humanPlayer, SIGNAL(sigPlayDelayedSound(QString, int)), this, SLOT(slotPlayDelayedSound(QString, int))); connect(enemyPlayer, SIGNAL(sigPlayDelayedSound(QString, int)), this, SLOT(slotPlayDelayedSound(QString, int))); // help menu -> display info infoDialog = new InfoDialog(this); connect(actionManual, SIGNAL(triggered()), infoDialog, SLOT(slotLoadTutorial())); connect(actionAbout, SIGNAL(triggered()), infoDialog, SLOT(slotLoadAbout())); connect(actionLicense, SIGNAL(triggered()), infoDialog, SLOT(slotLoadLicense())); //options menu connect(actionSound_on, SIGNAL(triggered()), this, SLOT(slotSoundOn())); if(QSound::isAvailable()) { soundAvailable = true; soundOn = true; slotPrintToConsole("Sound is availiable\n"); } else { soundAvailable = false; soundOn = false; slotPrintToConsole("Sound is not availiable\n"); } }