Skip to content

Commit

Permalink
Added boss to Cell and MazeActivity.
Browse files Browse the repository at this point in the history
  • Loading branch information
AHMAD-DINKINS committed Dec 8, 2018
1 parent 1f5f7d4 commit dcfba51
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions app/src/main/java/com/ahmaddinkins/cs125thegame/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class Cell {
private ArrayList<Cell> neighbors;
/**The enemy within the cell*/
private boolean enemy = false;
/**The boss if there is one*/
public static boolean boss = false;
private boolean isBoss;
/** The number of enemies on the map*/
static int numEnemies = 0;
/**
Expand All @@ -39,6 +42,13 @@ public class Cell {
enemy = true;
numEnemies++;
}
if (enemy && !boss) {
spawnChance = random.nextInt(10);
if (spawnChance == 0) {
boss = true;
isBoss = true;
}
}
}
/**
* Function that finds all of the horizontal and adjacent neighboring cells.
Expand Down Expand Up @@ -79,7 +89,13 @@ ArrayList<Cell> getNeighbors() {
boolean[] getWalls() {
return walls;
}

/**
* Return is this cell is a boss.
* @return The boss status
*/
boolean getBoss() {
return isBoss;
}
/**
* Returns the enemy.
* @return boolean representing if an enemy has spawned.
Expand Down Expand Up @@ -147,7 +163,6 @@ public String toString() {
}
return output.toString();
}

int getImageId() {
return imageId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* Class that will
*/
public class MazeActivity extends AppCompatActivity {
private static final int NOT_BOSS = 0;
private static final int BOSS = 1;
private Random random = new Random();
private GridLayout characterMazeGrid;
private TextView healthView;
Expand Down Expand Up @@ -66,7 +68,12 @@ private void init(final GridLayout gridMaze) {
position = cell.getIndex();
} else if (cell.getEnemy()) {
ImageView enemyImageView = new ImageView(MazeActivity.this);
int selectedEnemy = ENEMIES[random.nextInt(ENEMIES.length)];
int selectedEnemy;
if (!cell.getBoss()) {
selectedEnemy = ENEMIES[random.nextInt(ENEMIES.length)];
} else {
selectedEnemy = R.drawable.geoffry;
}
cell.setImageId(selectedEnemy);
enemyImageView.setBackground(getDrawable(selectedEnemy));
characterMazeGrid.addView(enemyImageView, cell.getIndex());
Expand Down Expand Up @@ -170,6 +177,11 @@ private void update(final int newPosition) {
if (enemy) {
Intent encounter = new Intent(MazeActivity.this, EncounterActivity.class);
encounter.putExtra("enemyImage", newCell.getImageId());
if (newCell.getBoss()) {
encounter.putExtra("boss", BOSS);
} else {
encounter.putExtra("boss", NOT_BOSS);
}
startActivityForResult(encounter, 2);
newCell.markEnemy();
}
Expand Down

0 comments on commit dcfba51

Please sign in to comment.