Skip to content
Snippets Groups Projects
Commit f11c967d authored by SYMKO TRISTAN's avatar SYMKO TRISTAN
Browse files

réorganisation du code door

parent 5671469f
Branches
No related merge requests found
package paquetSrc;
/**
* Classe représentant une porte dans le jeu.
*/
public class Door {
private int x;
private int y;
private boolean isOpen = false;
private boolean estOuverte = false;
public Monster[] monstres = new Monster[255];
public int nbMonstres = 0;
public Monster[] monster = new Monster[5];
/**
* Constructeur avec position initiale spécifiée.
*
* @param x Position x de la porte.
* @param y Position y de la porte.
*/
public Door(int x, int y) {
this.x = x;
this.y = y;
}
public void allMonstersDead() {
for (int i = 0; i < this.monster.length; i++) {
if (!(this.monster[i] == null)) {
if (this.monster[i].getMort() && this.nbMonstres > 0) {
this.monster[i] = null;
/**
* Vérifie si tous les monstres sont morts. Si oui, ouvre la porte.
*/
public void toutMonstresMort() {
for (int i = 0; i < this.monstres.length; i++) {
if (this.monstres[i] != null) {
if (this.monstres[i].getMort() && this.nbMonstres > 0) {
this.monstres[i] = null;
if (--this.nbMonstres <= 0) {
open();
ouvrir();
}
}
}
}
}
public void open() {
this.isOpen = true;
/**
* Ouvre la porte.
*/
public void ouvrir() {
this.estOuverte = true;
}
public boolean isOpen() {
return this.isOpen;
/**
* @return True si la porte est ouverte, false sinon.
*/
public boolean estOuverte() {
return this.estOuverte;
}
/**
* @return La position x de la porte.
*/
public int getX() {
return this.x;
}
/**
* @return La position y de la porte.
*/
public int getY() {
return this.y;
}
}
\ No newline at end of file
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment