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; }
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; }
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; }
private static ArrayList<Towers> FindFiveTower( int direction, FieldIndex startPoint, boolean[][] cluster) { // checks for the three last pieces of a five-in-a-row tower in the given direction // startPoint should be the second index // returns a list of found towers ArrayList<Towers> towerList = new ArrayList<Towers>(); Towers tower = new Towers(startPoint, direction); FieldIndex up = startPoint.Up(direction); if (up.Valid() && cluster[up.x()][up.y()]) { tower.add(up); up = up.Up(direction); if (up.Valid() && cluster[up.x()][up.y()]) { tower.add(up); up = up.Up(direction); if (up.Valid() && cluster[up.x()][up.y()]) { tower.add(up); towerList.add(tower); Game.getInstance().setShowVictoryScreen(true); return towerList; } } } return towerList; // returning the empty tower list }