Пример #1
0
void TREnemy::move(){
    if(anilock){
        anilockrem--;
        if(anilockrem <= 0){
            unlock();
            endAttacking();
        }
    }
    atk_cd_rem--;
    if (isMoving()) {
        if(type == TREnemyRandom){
            moveRandom();
        }else if(type == TREnemySmart){
            if(std::abs(hero->getX()-getX()) + std::abs(hero->getY()-getY()) > 100+rand()%250){
                clearRoute();
                moveRandom();
            }else{
                setVelXY(0);
                moveAlongPath();
            }
        }
        if(turretMode){
            if (--bul_cd_rem < 0) {
                bul_cd_rem = bul_cd;
                flgfire = true;
            }
        }
    }
}
Пример #2
0
void TREnemy::planRoute(bool force){
    int hero_gridX,hero_gridY,gridX,gridY;
    grider->convertLevelTopLeftToGrid(getX(), getY(), gridX, gridY);
    grider->convertLevelTopLeftToGrid(hero->getX(), hero->getY(), hero_gridX, hero_gridY);
    if(force || hero_gridX != prv_hero_x || hero_gridY != prv_hero_y){
        prv_hero_x = hero_gridX,prv_hero_y = hero_gridY;
        pathFinder->setStartingPoint(gridX, gridY);
        pathFinder->setTargetPoint(hero_gridX, hero_gridY);
        pathFinder->findPath();
        clearRoute();
        int tx,ty,ax,ay;
        while(pathFinder->extractPath(tx, ty)){
            grider->convertGridToLevelTopLeft(tx, ty, ax, ay);
            path.push(std::make_pair(ax,ay));
        }
        if (path.size()) {
            path.pop();
        }
    }
}
Пример #3
0
// What to do when the route is finished?
void Car::routeFinished() {
    // Clear the route
    clearRoute();
    mFinished = true;
}