Esempio n. 1
0
int GameState::countCollisions() {
    int numberDestroyed = 0;
    unsigned int i = 0;
    while (i < robots.size()) {
        bool collision = (countRobotsAt(*robots[i]) > 1);
        if (collision && !robots[i]->isJunk()) {
            Junk* j = new Junk(*robots[i]);
            delete robots[i];
            robots[i] = j;
            this->numberOfRobots--;
            numberDestroyed++;
        }
        i++;
    }
    return numberDestroyed;
}
Esempio n. 2
0
int GameState::countCollisions() {
    int numberDestroyed = 0;
    unsigned int i = 0;
    while (i < robots.size()) {
        bool hitJunk = robots[i]->isJunk();
        bool collision = (countRobotsAt(*robots[i]) > 1);
        if (collision && !hitJunk) {
            Robot* temp = robots[i];
            robots[i] = new Junk((*robots[i]));
            delete temp;
            numberDestroyed++;
        } else {
            i++;
        }
    }
    return numberDestroyed;
}
Esempio n. 3
0
/*
 * Free of robots and junk only
 */
bool GameState::isEmpty(const Unit& unit) const {
    return countRobotsAt(unit) == 0;
}
Esempio n. 4
0
/*
 * Free of robots and junk only
 */
bool GameState::isEmpty(const Unit& unit) const {
    return (countRobotsAt(unit) == 0);// && !(robot.isJunk());
}