//=============================================================
//=============================================================
void CC3DCircleListLayer::endUpdateToCenter()
{
    CCButton* pSelButton = getSelectedButton();
    if(!pSelButton)
        return;
    moveToCenter(pSelButton,true);
}
Esempio n. 2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowTitle(trUtf8("Chess"));
    setWindowIcon(QIcon("://images/black_king.png"));
    moveToCenter();
    mkDir();

    scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);
    scene->setBackgroundBrush(Qt::lightGray);

    ellipse = scene->addEllipse(0,0,150,150,QPen(Qt::gray),QBrush(Qt::white));
    saver = scene->addPixmap(QPixmap("://images/black_king.png"));
    saver->setPos(25, 25);

    connect(ui->loadButton, SIGNAL(clicked()),SLOT(showLoad())); //показываем окно загрузки сохраненной игры
    connect(ui->loadButton, SIGNAL(clicked()),SLOT(hide())); //делаем невидимым главное окно

    connect(ui->newButton, SIGNAL(clicked()),SLOT(showNew()));
    connect(ui->newButton, SIGNAL(clicked()),SLOT(hide()));

}
Esempio n. 3
0
void MooreHallway() {

    if (direction == 1) {

        // Move to center
        moveToCenter(0.0);

        correctAngle('B');

        int lostL, lostR;
        double wallL, wallR;
        wallR = 0;
        urgStart(&urg);
        // Go until right wall is greater than 6 feet away
        while(fabs(wallR) < (6 * feet2mm)) {
            Xprintf("Going until right wall > 5ft . . .\n");
            scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 1);
        }
        urgStop(&urg);
        current++;
        currentRoom  = -1;
        return;
    }

    if (direction == -1) {

        // Move to center
        moveToCenter(0.0);

        correctAngle('B');

        // Go until right wall breaks
        int lostL, lostR;
        double wallL, wallR;
        lostR = 0;
        urgStart(&urg);
        while(!lostR) {
            Xprintf("Going until right wall breaks . . .\n");
            scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 1);
        }
        urgStop(&urg);
        current--;
        currentRoom  = -1;
        return;
    }
}
Esempio n. 4
0
void TownSprite::onTouchEnded(Touch* pTouch, Event* pEvent)
{
    this->setScale(1.0f);
    
    if (_delta <= LIMIT_DELTA) {
        moveToCenter();
        showDialog();
    }
}
Esempio n. 5
0
//--------------------------------------------------------------
void particleSystem::update(){
	
	
	mouseLocation = ofxVec3f (ofGetAppPtr()->mouseX,ofGetAppPtr()->mouseY,0);
	mouseX = mouseLocation.x;
	mouseY = mouseLocation.y;
	
	if (mustMoveBack) {
		moveBack();
		mustMoveBack = !mustMoveBack;
	}
	if (mustMoveToCenter) {
		moveToCenter();
		//mustMoveToCenter = !mustMoveToCenter;
	}
	
	if (mustMoveRandom) {
		moveRandom();
 		//mustMoveRandom = !mustMoveRandom;
	} 
	/*
	if (mustMoveRandomH) {
		moveRandomH();
 		//mustMoveRandomH = !mustMoveRandomH;
	} 
	if (mustMoveRandomV) {
		moveRandomV();
 		//mustMoveRandomV = !mustMoveRandomV;
	} 
	*/
	
	if (mustMovePaused) {
		movePaused(); 	
		mustMovePaused = !mustMovePaused;
	}
	
	
	particleIter = particles.begin();
	while (particleIter!= particles.end()){
		(*particleIter)->update();
		++particleIter;
	}
}
void PlayerCardBox::chooseCard(const QString &reason, const ClientPlayer *player,
                          const QString &flags, bool handcardVisible,
                          Card::HandlingMethod method, const QList<int> &disabledIds)
{
    nameRects.clear();
    rowCount = 0;
    intervalsBetweenAreas = -1;
    intervalsBetweenRows = 0;
    maxCardsInOneRow = 0;

    this->player = player;
    this->title = tr("%1: please choose %2's card").arg(reason).arg(ClientInstance->getPlayerName(player->objectName()));
    this->flags = flags;
    bool handcard = false;
    bool equip = false;
    bool judging = false;

    if (flags.contains(handcardFlag) && !player->isKongcheng()) {
        updateNumbers(player->getHandcardNum());
        handcard = true;
    }

    if (flags.contains(equipmentFlag) && player->hasEquip()) {
        updateNumbers(player->getEquips().length());
        equip = true;
    }

    if (flags.contains(judgingFlag) && !player->getJudgingArea().isEmpty()) {
        updateNumbers(player->getJudgingArea().length());
        judging = true;
    }

    int max = maxCardsInOneRow;
    int maxNumber = maxCardNumberInOneRow;
    maxCardsInOneRow = qMin(max, maxNumber);

    prepareGeometryChange();

    moveToCenter();
    show();

    this->handcardVisible = handcardVisible;
    this->method = method;
    this->disabledIds = disabledIds;

    const int startX = verticalBlankWidth + placeNameAreaWidth + intervalBetweenNameAndCard;
    int index = 0;

    if (handcard) {
        if (Self == player || handcardVisible) {
            arrangeCards(player->getHandcards(), QPoint(startX, nameRects.at(index).y()));
        } else {
            const int handcardNumber = player->getHandcardNum();
            CardList cards;
            for(int i = 0; i < handcardNumber; ++ i)
                cards << NULL;
            arrangeCards(cards, QPoint(startX, nameRects.at(index).y()));
        }

        ++ index;
    }

    if (equip) {
        arrangeCards(player->getEquips(), QPoint(startX, nameRects.at(index).y()));

        ++ index;
    }

    if (judging)
        arrangeCards(player->getJudgingArea(), QPoint(startX, nameRects.at(index).y()));

    if (ServerInfo.OperationTimeout != 0) {
        if (!progressBar) {
            progressBar = new QSanCommandProgressBar();
            progressBar->setMaximumWidth(qMin(boundingRect().width() - 16, (qreal) 150));
            progressBar->setMaximumHeight(12);
            progressBar->setTimerEnabled(true);
            progressBarItem = new QGraphicsProxyWidget(this);
            progressBarItem->setWidget(progressBar);
            progressBarItem->setPos(boundingRect().center().x() - progressBarItem->boundingRect().width() / 2, boundingRect().height() - 20);
            connect(progressBar, SIGNAL(timedOut()), this, SLOT(reply()));
        }
        progressBar->setCountdown(QSanProtocol::S_COMMAND_CHOOSE_CARD);
        progressBar->show();
    }
}
Esempio n. 7
0
void LevineHallway() {
    if (direction == 1) {
        currentRoom = -1;
        correctAngle('R');

        straightBlind(3*12);

        currentRoom++;
        // Stop for Recycling Center
        if (current == destination && currentRoom == destinationRoom) return;

        moveToCenter(0.0);
        correctAngle('L');

        straightBlind(8*12);

        moveToCenter(0.0);
        correctAngle('B');

        // Keep going until left wall too far
        int lostL, lostR;
        lostL = 0;
        double wallL, wallR;
        urgStart(&urg);
        while (lostL != 1) {
            scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 1);
            Xprintf("Scan centering until left lost\n");
        }
        urgStop(&urg);
        current++;
        currentRoom = -1;
        return;
    }
    if (direction == -1) {

        moveToCenter(0.0);
        correctAngle('B');

        // Keep going until hall width < 7ft
        int lostL, lostR;
        lostL = 0;
        double wallL = 10000;
        double wallR = 10000;
        urgStart(&urg);
        while (fabs(wallL) + fabs(wallR) > (7 * feet2mm)) {
            scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 1);
            Xprintf("Scan centering until hallway narrows to 7ft\n");
        }
        urgStop(&urg);
        moveToCenter(0.0);
        correctAngle('B');

        // Go until right wall breaks
        urgStart(&urg);
        while (lostR != 1) {
            scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 1);
            Xprintf("Scan centering until right wall breaks\n");
        }
        urgStop(&urg);
        straightBlind(20);

        turn90('R');

        // Go straight until walls are back
        lostL = lostR = 1;
        urgStart(&urg);
        while (!(!lostL && !lostR)) {
            scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 1);
            Xprintf("Scan centering until right lost\n");
        }
        urgStop(&urg);
        sendSpeed(0.0, 0.0);
        current--;
        currentRoom  = -1;
        return;
    }
}
Esempio n. 8
0
void GRWHallway() {
    if (direction == 1) {

        // Set up distance counting
        int lCount, rCount;
        int lostL = 0;
        int lostR = 0;
        double wallL, wallR;

        pollSensors(&lCount, &rCount);
        position = 0.0;
        lostL = lostR = 0;
        currentRoom = -1;
        int roomCount = 0;

        // Move to center
        moveToCenter(0.0);

        pollSensors(&lCount, &rCount);
        position = position + ((lCount + rCount) / 2.0) * ticks2inches;

        correctAngle('B');
        pollSensors(&lCount, &rCount);

        urgStart(&urg);
        // Keep going until both walls are lost or room found
        while (!lostL || !lostR) {
            if (scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 1) != -10) {
                lCount = rCount = 0;
                pollSensors(&lCount, &rCount);
                position = position + ((lCount + rCount) / 2.0) * ticks2inches;
                char string[70];
                sprintf(string, "Going Straight. Pos: %lf\n", position);
                Xprintf(string);
            }
            if (position > array[current].roomDist[roomCount]*12) {
                currentRoom++;
                roomCount++;
            }
            if (current == destination && currentRoom == destinationRoom) return;
        }
        urgStop(&urg);

        straightBlind(1.5 * 12);
        turn90('L');
        sendSpeed(0.0, 0.0);
        current++;
        currentRoom = -1;
        return;
    }
    if (direction == -1) {
        straightBlind(6);
        correctAngle('B');
        moveToCenter(0.0);
        correctAngle('B');

        // Keep going down center of hall until wall both disappear
        int lostL, lostR;
        double wallL, wallR;
        lostL = lostR = 0;
        wallL = wallR = 1;
        urgStart(&urg);
        while(!(lostR || lostL || ((wallL > 5 * feet2mm) && (wallR > 5 * feet2mm)))) {
            scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 1);
            Xprintf("Scan centering until both walls further than 5ft or either is lost\n");
        }
        urgStop(&urg);
        current--;
        currentRoom  = -1;
        return;
    }
}
Esempio n. 9
0
void MooreGRWLobby () {

    if (direction == 1) {
        currentRoom = 0;

        // Return if set as home
        if (destination == current && destinationRoom == 0) return;

        // Move to 4 feet from left wall
        moveToCenter(4 * feet2mm);

        correctAngle('B');

        int lostL = 1;
        int lostR = 1;
        double wallL = 10000;
        double wallR = 10000;

        // Keep going until both walls are found and less than 8ft apart
        urgStart(&urg);
        while (lostL || lostR || (fabs(wallL) + fabs(wallR)) > (8 * feet2mm)) {
            Xprintf("Searching for both walls . . .\n");
            if (scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 0) != -10) {
                sendSpeed(100.0, 100.0);
            } else {
                sendSpeed(0.0, 0.0);
            }
        }
        urgStop(&urg);
        current++;
        currentRoom  = -1;
        return;
    }
    if (direction == -1) {

        // Go straight until right wall appears at less than 5ft away
        int lostL, lostR;
        double wallL, wallR;
        lostR = 1;
        urgStart(&urg);
        while (lostR || wallR > (5 * feet2mm)) {
            Xprintf("Searching for right wall closer than 5ft . . .\n");
            if (scan_center(0.0, &wallL, &wallR, &lostL, &lostR, 0) != -10) {
                sendSpeed(100.0, 100.0);
            } else {
                sendSpeed(0.0, 0.0);
            }
        }
        urgStop(&urg);

        straightBlind(6);
        correctAngle('R');

        moveToCenter(-4.5 * feet2mm);
        correctAngle('R');

        lostL = lostR = 1;
        urgStart(&urg);
        // Go forward at 4.5ft from right wall until both walls appear less than 6ft apart
        while (lostL || lostR || (fabs(wallL) + fabs(wallR)) >  (6 * feet2mm)) {
            scan_center(-4.5*feet2mm, &wallL, &wallR, &lostL, &lostR, 0);
        }
        urgStop(&urg);
        sendSpeed(0.0, 0.0);

        currentRoom  = -1;
        current--;
        return;
    }
}
//=============================================================
//=============================================================
void CC3DCircleListLayer::clickButton(CCButton* pButton)
{
    int index = pButton->getTag();
    CCLog("%d",index);
    moveToCenter(pButton,true);
}