2022-05-21 17:53:19 +02:00
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
2022-05-23 16:10:45 +02:00
|
|
|
import java.awt.event.*;
|
2022-05-21 17:53:19 +02:00
|
|
|
|
|
|
|
public class Banniere extends JPanel {
|
2022-05-21 22:17:25 +02:00
|
|
|
private FrameJeu fenetre;
|
2022-05-23 19:32:09 +02:00
|
|
|
private FrameMenu menu;
|
2022-05-21 17:53:19 +02:00
|
|
|
// Définition du constructeur
|
2022-05-23 19:32:09 +02:00
|
|
|
public Banniere(int mines, FrameJeu fenetre, FrameMenu menu) {
|
2022-05-21 17:53:19 +02:00
|
|
|
super();
|
2022-05-21 22:17:25 +02:00
|
|
|
this.fenetre=fenetre;
|
2022-05-23 19:32:09 +02:00
|
|
|
this.menu=menu;
|
2022-05-21 17:53:19 +02:00
|
|
|
|
|
|
|
// On défini un style à la bannière
|
|
|
|
this.setBackground( new Color(0, 236, 96));
|
2022-05-21 18:41:24 +02:00
|
|
|
|
2022-05-21 17:53:19 +02:00
|
|
|
// TODO : Bouton sauver et quitter
|
|
|
|
}
|
|
|
|
|
|
|
|
// Méthode pour afficher le nombre de mines restantes
|
|
|
|
public void setMinesLeft(int minesLeft){
|
|
|
|
this.removeAll();
|
|
|
|
this.add(new MineLeft(minesLeft,this.getSize()));
|
|
|
|
this.repaint();
|
2022-05-21 18:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Méthode pour indiquer au joueur sa Victoire
|
|
|
|
public void setVictoire(){
|
|
|
|
this.add(new Fin("Victoire !",this.getSize()));
|
|
|
|
this.repaint();
|
2022-05-23 19:32:09 +02:00
|
|
|
ActionListener backToMenu = new MenuListener(this.fenetre, this.menu);
|
2022-05-23 16:10:45 +02:00
|
|
|
Timer timerMenu = new Timer(5000, backToMenu);
|
|
|
|
timerMenu.setRepeats(false);
|
|
|
|
timerMenu.start();
|
2022-05-21 18:41:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Méthode pour indiquer au joueur sa Défaite
|
|
|
|
public void setDefaite(){
|
|
|
|
this.add(new Fin("Défaite !",this.getSize()));
|
2022-05-23 16:10:45 +02:00
|
|
|
this.repaint();
|
2022-05-23 19:32:09 +02:00
|
|
|
ActionListener backToMenu = new MenuListener(this.fenetre, this.menu);
|
2022-05-23 16:10:45 +02:00
|
|
|
Timer timerMenu = new Timer(5000, backToMenu);
|
|
|
|
timerMenu.setRepeats(false);
|
|
|
|
timerMenu.start();
|
2022-05-21 17:53:19 +02:00
|
|
|
}
|
|
|
|
}
|