Esempio n. 1
0
  public void turn() throws GameActionException {
    if (rc.getConstructingRounds() > 0) return; // can't do anything while constructing

    if (Strategy.active == Strategy.HQ_PASTR) {
      if (spawnOrder == 1) {
        MapLocation pastrLoc = ourHQ.add(ourHQ.directionTo(here).rotateRight().rotateRight());
        constructNoiseTower(pastrLoc);
        return;
      }
      if (spawnOrder == 2) {
        rc.construct(RobotType.PASTR);
        return;
      }
    }

    updateEnemyData();
    MapLocation attackTarget = MessageBoard.ATTACK_LOC.readMapLocation();
    stance = chooseMicroStance(attackTarget);
    navEngage = stance == MicroStance.AGGRESSIVE ? Nav.Engage.YES : Nav.Engage.NO;

    // If there are enemies in attack range, fight!
    if (attackableEnemies.length > 0 && rc.isActive()) {
      fight();
      return;
    }

    // If we are in attack mode, move toward the attack target and engage.
    if (attackTarget != null) {
      if (rc.isActive()
          && attackTarget.distanceSquaredTo(theirHQ) <= 5
          && here.distanceSquaredTo(theirHQ) <= 35) {
        harrassTheirHQ();
        return;
      } else {
        Nav.goTo(attackTarget, Nav.Sneak.NO, navEngage);
        if (rc.isActive() && visibleEnemies.length > 0) fight();
        return;
      }
    }

    // See if we should build something
    maybeBuildSomething();

    // Build or defend a pastr
    buildOrDefendPastr();
  }