예제 #1
0
파일: Vue.java 프로젝트: exidhor/Bejeweled
  public void partieEstPerdu(String origineFin) {
    boolean newRecord = gestionHighScore();

    StringBuilder message = new StringBuilder();

    message.append("Desole, vous n'avez plus de ");
    message.append(origineFin);
    if (newRecord) {
      message.append(", mais vous avez fait un nouveau meilleur score : " + model.getScore());
    }

    JOptionPane optionPane = new JOptionPane();
    JDialog dialog = new JDialog();
    JOptionPane.showMessageDialog(
        optionPane, message, "Game Over", JOptionPane.INFORMATION_MESSAGE);

    model.genererTableau();
    model.reinitialiser();
    progressBar = new TheProgressBar(this);
    drawMap();
    setVisible(true);
    model.setEstEnJeu(false);
  }
예제 #2
0
  public void actionPerformed(ActionEvent e) {
    if (!model.getEstEnJeu()) {
      vue.getProgressBar().start();
      model.setEstEnJeu(true);
    }

    System.out.println(
        e.getSource().toString() + model.getBijou(((Bijou) e.getSource()).getPosition()));
    if (e.getSource().getClass() == bouton1.getClass()) {
      if (bouton1selectionne && estProche((Bijou) e.getSource())) {
        bouton2.setBackground(Color.WHITE);
        bouton2 = (Bijou) e.getSource();
        bouton2.setBackground(Color.DARK_GRAY);

        // model.permut(bouton1.getPosition(), bouton2.getPosition());
        // vue.actualiserCase(bouton1.getPosition());
        // vue.actualiserCase(bouton2.getPosition());

        model.actualiserCoupPossible();
        vue.actualiserTableau();

        if (model.estUnCoupValide(new Coup(bouton1.getPosition(), bouton2.getPosition()))) {
          controlMenu.setHintPressed(false);
          /*
          try {
              Thread.sleep(500);
          } catch (InterruptedException e1) {
              e1.printStackTrace();
          }*/
          model.permut(bouton1.getPosition(), bouton2.getPosition());
          vue.actualiserCase(bouton1.getPosition());
          vue.actualiserCase(bouton2.getPosition());

          bouton1selectionne = false;
          bouton1.setBackground(Color.WHITE);
          bouton2.setBackground(Color.WHITE);
          // model.actualiserCoupPossible();
          // vue.coloreCoupPossible();
          System.out.println("coup valide");
          /*
          try {
              Thread.sleep(500);
          } catch (InterruptedException e1) {
              e1.printStackTrace();
          }*/
          int score = 0;
          int newScore = 0;
          int progres = 0;
          ArrayList<ArrayList<Coord>> lignesCombo;
          do {
            lignesCombo = vue.coloreLigneCombo();
            newScore = compteScore(lignesCombo);
            score += newScore;
            progres += compteProgres(lignesCombo);
          } while (newScore != 0);

          model.addScore(score);
          vue.actualiserProgres(progres);
          vue.actualiserScore();

          /*
          try {
              Thread.sleep(500);
          } catch (InterruptedException e1) {
              e1.printStackTrace();
          }*/

          model.actualiserCoupPossible();
          vue.actualiserTableau();
          if (vue.getProgressBar().getValue() >= 100) {
            model.genererTableau();
            model.upLevel();
            vue.actualiserTableau();
            vue.drawMap();
            vue.setVisible(true);
            vue.getProgressBar().setValue(50);
          }
        } else {
          model.enleveUnTrie();
          vue.actualiserTries();
        }
      } else {
        bouton1.setBackground(Color.WHITE);
        bouton2.setBackground(Color.WHITE);
        bouton1 = (Bijou) e.getSource();
        bouton1.setBackground(Color.DARK_GRAY);
        bouton1selectionne = true;
      }
    }
  }