Exemple #1
0
  private static ArrayList<Towers> FindSilenceTower(
      int direction, FieldIndex startPoint, boolean[][] cluster) {
    // checks for the two last pieces of a silence tower in the given direction
    // startPoint should be the second index
    // returns number of found towers

    ArrayList<Towers> towerList = new ArrayList<Towers>();
    FieldIndex right = startPoint.Right(direction);
    FieldIndex left = startPoint.Left(direction);
    boolean leftPart = left.Valid() && cluster[left.x()][left.y()];
    boolean rightPart = right.Valid() && cluster[right.x()][right.y()];

    if (leftPart) {
      FieldIndex up = left.Up(direction);
      if (up.Valid() && cluster[up.x()][up.y()]) {
        Towers leftTower = new Towers(startPoint, direction); // initing the tower
        leftTower.add(left);
        leftTower.add(up);
        leftTower.towerType = SkillType.SILENCE;
        towerList.add(leftTower);
      }
    }
    if (rightPart) {
      FieldIndex up = right.Up(direction);
      if (up.Valid() && cluster[up.x()][up.y()]) {
        Towers rightTower = new Towers(startPoint, direction); // initing the tower
        rightTower.add(right);
        rightTower.add(up);
        rightTower.towerType = SkillType.SILENCE;
        towerList.add(rightTower);
      }
    }
    return towerList;
  }
Exemple #2
0
  private static ArrayList<Towers> FindMultipleSkillsTower(
      int direction, FieldIndex startPoint, boolean[][] cluster) {
    // checks for the two last pieces of a multiple-skills tower in the given direction
    // startPoint should be the second index
    // returns number of found towers

    ArrayList<Towers> towerList = new ArrayList<Towers>();
    FieldIndex right = startPoint.Right(direction);
    if (right.Valid() && cluster[right.x()][right.y()]) {
      FieldIndex down = right.Down(direction);
      if (down.Valid() && cluster[down.x()][down.y()]) {
        Towers tower = new Towers(startPoint, direction); // initing the tower
        tower.add(right);
        tower.add(down);
        tower.towerType = SkillType.SKILLCAP;
        towerList.add(tower);
      }
    }
    return towerList;
  }
Exemple #3
0
  private static ArrayList<Towers> FindShootTower(
      int direction, FieldIndex startPoint, boolean[][] cluster) {
    // checks for the two last pieces of a shoot tower in the given direction
    // startpoint should be the second index
    // returns number of found towers

    FieldIndex right = startPoint.Right(direction);
    FieldIndex left = startPoint.Left(direction);
    boolean leftPart = left.Valid() && cluster[left.x()][left.y()];
    boolean rightPart = right.Valid() && cluster[right.x()][right.y()];

    ArrayList<Towers> towerList = new ArrayList<Towers>();

    if (leftPart && rightPart) {
      Towers tow = new Towers(startPoint, direction);
      tow.add(left);
      tow.add(right);
      tow.towerType = SkillType.SHOOT;
      towerList.add(tow);
    }
    return towerList;
  }