Esempio n. 1
0
void PokeEdit::fillMoves()
{
    movesModel = new PokeMovesModel(m_poke->num(), m_poke->gen(), this, hackMons);
    QSortFilterProxyModel *filter = new QSortFilterProxyModel(this);
    filter->setSourceModel(movesModel);
    ui->moveChoice->setModel(filter);
    ui->moveChoice->disconnect(SIGNAL(activated(QModelIndex)), this);
    connect(ui->moveChoice, SIGNAL(activated(QModelIndex)), SLOT(moveEntered(QModelIndex)));
#ifdef QT5
    ui->moveChoice->horizontalHeader()->setSectionResizeMode(PokeMovesModel::PP, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setSectionResizeMode(PokeMovesModel::Priority, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setSectionResizeMode(PokeMovesModel::Pow, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setSectionResizeMode(PokeMovesModel::Acc, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setSectionResizeMode(PokeMovesModel::Name, QHeaderView::Fixed);
#else
    ui->moveChoice->horizontalHeader()->setResizeMode(PokeMovesModel::PP, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setResizeMode(PokeMovesModel::Pow, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setResizeMode(PokeMovesModel::Acc, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setResizeMode(PokeMovesModel::Name, QHeaderView::Fixed);
#endif
    ui->moveChoice->horizontalHeader()->resizeSection(PokeMovesModel::Name, 125);
    ui->moveChoice->horizontalHeader()->resizeSection(PokeMovesModel::Type, Theme::TypePicture(Type::Normal).width()+5);
    ui->moveChoice->setIconSize(Theme::TypePicture(Type::Normal).size());

    ui->moveChoice->sortByColumn(PokeMovesModel::Name, Qt::AscendingOrder);
    m_moves[0] = ui->move1;
    m_moves[1] = ui->move2;
    m_moves[2] = ui->move3;
    m_moves[3] = ui->move4;
    connect(ui->speciesLabel, SIGNAL(clicked()), SLOT(on_pokemonFrame_clicked()));

    /* the four move choice items */
    for (int i = 0; i < 4; i++)
    {
        QCompleter *completer = new QCompleter(m_moves[i]);
        completer->setModel(ui->moveChoice->model());
        completer->setCompletionColumn(PokeMovesModel::Name);
        completer->setCaseSensitivity(Qt::CaseInsensitive);
        completer->setCompletionMode(QCompleter::PopupCompletion);
        completer->setCompletionRole(Qt::DisplayRole);
        m_moves[i]->setCompleter(completer);

        completer->setProperty("move", i);
        m_moves[i]->setProperty("move", i);
        connect(completer, SIGNAL(activated(QString)), SLOT(changeMove()));
        connect(m_moves[i], SIGNAL(returnPressed()), SLOT(changeMove()));
        connect(m_moves[i], SIGNAL(editingFinished()), SLOT(changeMove()));
    }
}
Esempio n. 2
0
void AIRandomMoveTank::update(uint t)
{
        double timel = t - lasttimeUpdated;

        if (::GetTickCount()-lasttimeChangedMove>ccTime && state != AIRM_STATE_DEAD)
        {
                state = changeMove();
                lasttimeChangedMove = ::GetTickCount();
                ccTime = random(changeTime)+changeTime/2;
        }


        if ((state&0xFF) == AIRM_STATE_GO_UP && sprite->getCurrentAnimationName()!="go_up")
                sprite->setAnimation("go_up");
        else if ((state&0xFF) == AIRM_STATE_GO_RIGHT && sprite->getCurrentAnimationName()!="go_right")
                sprite->setAnimation("go_right");
        else if ((state&0xFF) == AIRM_STATE_GO_DOWN && sprite->getCurrentAnimationName()!="go_bottom")
                sprite->setAnimation("go_bottom");
        else if ((state&0xFF) == AIRM_STATE_GO_LEFT && sprite->getCurrentAnimationName()!="go_left")
                sprite->setAnimation("go_left");
        else if ((state&0xFF) == AIRM_STATE_DEAD && sprite->getCurrentAnimationName()!="death")
                sprite->setAnimation("death");
        sprite->update();

        if ((state&0xFF)==AIRM_STATE_DEAD && sprite->isLastFrameInAnimation())
        {
                manager->sendMessage(IMessage::createDestroyMeMessage(this));
                return;
        }
        TDoubleRect r = sprite->getDoubleRect();
        if (r.left<0)
                r.left=0;
        if (r.top<0)
                r.top=0;
        if (r.right>768)
                r.left-=r.right-768;
        if (r.bottom>512)
                r.top-=r.bottom-512;
        sprite->setPosition(r.left,r.top);


        if ((state&0xFF) == AIRM_STATE_GO_UP)
                r.top -= double(speed)*timel/1000.;
        if ((state&0xFF) == AIRM_STATE_GO_RIGHT)
                r.left += double(speed)*timel/1000.;
        if ((state&0xFF) == AIRM_STATE_GO_DOWN)
                r.top += double(speed)*timel/1000.;
        if ((state&0xFF) == AIRM_STATE_GO_LEFT)
                r.left -= double(speed)*timel/1000.;

        manager->sendMessage(IMessage::createMoveRequestMessage(this,r.left,r.top));
        shoot();
        moveRequested = true;
        lasttimeUpdated = ::GetTickCount();
}
Esempio n. 3
0
void AIRandomMoveTank::processMessage(IMessage * msg)
{
        switch (msg->type)
        {
        case MSG_MOVE_REQUEST:
                sprite->setPosition(msg->left,msg->top);
                break;
        case MSG_COLLISION:

                if (msg->super->type&TYPE_WALL)
                {
                        if (msg->super->type != TYPE_BRICK_WALL || random(100)>95)
                        {
                                state = changeMove();
                                lasttimeChangedMove = ::GetTickCount();
                        }
                }
                else if (msg->super->type&TYPE_BULLETS)
                {
                        if(msg->super->team == team)
                        {
                                if (moveRequested)
                                {
                                        sprite->setPosition(msg->left,msg->top);
                                        moveRequested=false;
                                }
                        }
                        else if (msg->super->team != TEAM_PEACEFUL)
                        {
                                Bullet * b = (Bullet*)msg->super;
                                hp-=b->getDmg(this,typeResist,valueResist);
                                if (hp<0)
                                {
                                        manager->sendMessage(IMessage::createHideMeMessage(this, false,false,true));
                                        UserStats * us = UserStats::getInstance();
                                        us->scores+=scoreForKill* (state==AIRM_STATE_DEAD?0:1);
                                        state = AIRM_STATE_DEAD;
                                }
                        }
                }
                else if (msg->super->type&TYPE_TANK && msg->super->team == TEAM_AI)
                {
                        if (moveRequested)
                        {
                                sprite->setPosition(msg->left,msg->top);
                                moveRequested=false;
                        }
                }
                break;
        default:
                break;
        }
        delete msg;
}
Esempio n. 4
0
PokeEdit::PokeEdit(PokeTeam *poke, QAbstractItemModel *pokeModel, QAbstractItemModel *itemsModel, QAbstractItemModel *natureModel) :
    ui(new Ui::PokeEdit),
    pokemonModel(pokeModel),
    m_poke(poke)
{
    ui->setupUi(this);
    ui->itemSprite->raise();
    ui->item->setModel(itemsModel);
    ui->nature->setModel(natureModel);

    ui->levelSettings->setPoke(poke);
    ui->evbox->setPoke(poke);
    ui->ivbox->setPoke(poke);

    movesModel = new PokeMovesModel(poke->num(), poke->gen(), this);
    QSortFilterProxyModel *filter = new QSortFilterProxyModel(this);
    filter->setSourceModel(movesModel);
    ui->moveChoice->setModel(filter);

    ui->moveChoice->horizontalHeader()->setResizeMode(PokeMovesModel::PP, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setResizeMode(PokeMovesModel::Pow, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setResizeMode(PokeMovesModel::Acc, QHeaderView::ResizeToContents);
    ui->moveChoice->horizontalHeader()->setResizeMode(PokeMovesModel::Name, QHeaderView::Fixed);
    ui->moveChoice->horizontalHeader()->resizeSection(PokeMovesModel::Name, 125);
    ui->moveChoice->horizontalHeader()->resizeSection(PokeMovesModel::Type, Theme::TypePicture(Type::Normal).width()+5);
    ui->moveChoice->setIconSize(Theme::TypePicture(Type::Normal).size());

    ui->moveChoice->sortByColumn(PokeMovesModel::Name, Qt::AscendingOrder);

    m_moves[0] = ui->move1;
    m_moves[1] = ui->move2;
    m_moves[2] = ui->move3;
    m_moves[3] = ui->move4;

    connect(ui->speciesLabel, SIGNAL(clicked()), SLOT(on_pokemonFrame_clicked()));

    connect(ui->moveChoice, SIGNAL(activated(QModelIndex)), SLOT(moveEntered(QModelIndex)));

    /* the four move choice items */
    for (int i = 0; i < 4; i++)
    {
        QCompleter *completer = new QCompleter(m_moves[i]);
        completer->setModel(ui->moveChoice->model());
        completer->setCompletionColumn(PokeMovesModel::Name);
        completer->setCaseSensitivity(Qt::CaseInsensitive);
        completer->setCompletionMode(QCompleter::PopupCompletion);
        completer->setCompletionRole(Qt::DisplayRole);
        m_moves[i]->setCompleter(completer);

        completer->setProperty("move", i);
        m_moves[i]->setProperty("move", i);

        connect(completer, SIGNAL(activated(QString)), SLOT(changeMove()));
        connect(m_moves[i], SIGNAL(returnPressed()), SLOT(changeMove()));
        connect(m_moves[i], SIGNAL(editingFinished()), SLOT(changeMove()));
    }

    connect(ui->levelSettings, SIGNAL(levelUpdated()), this, SLOT(updateStats()));
    connect(ui->levelSettings, SIGNAL(levelUpdated()), ui->ivbox, SLOT(updateStats()));
    connect(ui->levelSettings, SIGNAL(shinyUpdated()), this, SLOT(updatePicture()));
    connect(ui->levelSettings, SIGNAL(genderUpdated()), this, SLOT(updatePicture()));
    connect(ui->levelSettings, SIGNAL(genderUpdated()), this, SLOT(updateGender()));
    connect(ui->ivbox, SIGNAL(genderUpdated()), SLOT(updateGender()));
    connect(ui->ivbox, SIGNAL(genderUpdated()), ui->levelSettings, SLOT(updateGender()));
    connect(ui->ivbox, SIGNAL(shinyUpdated()), SLOT(updatePicture()));
    connect(ui->ivbox, SIGNAL(shinyUpdated()), ui->levelSettings, SLOT(updateShiny()));
    connect(ui->happiness, SIGNAL(valueChanged(int)), this, SLOT(changeHappiness(int)));
    connect(ui->nature, SIGNAL(currentIndexChanged(int)), this, SLOT(changeNature(int)));
    connect(ui->item, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeItem(QString)));
    connect(ui->evbox, SIGNAL(natureChanged(int)), this, SLOT(setNature(int)));
    connect(ui->evbox, SIGNAL(natureBoostChanged()), ui->ivbox, SLOT(updateStats()));
    connect(ui->ivbox, SIGNAL(statsUpdated()), ui->evbox, SLOT(updateEVs()));

    updateAll();
}