/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Frames;

import javax.swing.JOptionPane;

/**
 *
 * @author Leidy y Daniela
 */
public class Oceano extends javax.swing.JFrame {

    private boolean estado;
    private int turnos;
    private int contar;
    private String nombre;

    /**
     * Creates new form Oceano
     */
    public Oceano() {
        initComponents();
        setResizable(false);  
setBounds(0, 0, 510, 615);
this.setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        anemona = new javax.swing.JLabel();
        ballena = new javax.swing.JLabel();
        burbuja = new javax.swing.JLabel();
        cangrejo = new javax.swing.JLabel();
        caracol = new javax.swing.JLabel();
        caracolmar = new javax.swing.JLabel();
        pezcierra = new javax.swing.JLabel();
        concha = new javax.swing.JLabel();
        coral = new javax.swing.JLabel();
        delfin = new javax.swing.JLabel();
        estrella = new javax.swing.JLabel();
        medusa = new javax.swing.JLabel();
        orca = new javax.swing.JLabel();
        pezangel = new javax.swing.JLabel();
        pezazul = new javax.swing.JLabel();
        pezdorado = new javax.swing.JLabel();
        pezglobo = new javax.swing.JLabel();
        pezmora = new javax.swing.JLabel();
        pezpaya = new javax.swing.JLabel();
        pezseductor = new javax.swing.JLabel();
        pulpo = new javax.swing.JLabel();
        raya = new javax.swing.JLabel();
        tiburonagresivo = new javax.swing.JLabel();
        tiburonrelax = new javax.swing.JLabel();
        tortuga = new javax.swing.JLabel();
        caballomar = new javax.swing.JLabel();
        jButton6 = new javax.swing.JButton();
        puntaje = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        getContentPane().setLayout(null);

        jButton2.setBackground(new java.awt.Color(0, 153, 0));
        jButton2.setText("jButton2");
        getContentPane().add(jButton2);
        jButton2.setBounds(130, 560, 120, 23);

        jButton1.setBackground(new java.awt.Color(0, 153, 0));
        jButton1.setText("jButton1");
        getContentPane().add(jButton1);
        jButton1.setBounds(10, 560, 110, 23);

        jButton3.setBackground(new java.awt.Color(0, 153, 0));
        jButton3.setText("jButton3");
        getContentPane().add(jButton3);
        jButton3.setBounds(260, 560, 110, 23);

        jButton4.setBackground(new java.awt.Color(0, 153, 0));
        jButton4.setText("jButton4");
        getContentPane().add(jButton4);
        jButton4.setBounds(380, 560, 110, 23);

        anemona.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/anemona.png"))); // NOI18N
        getContentPane().add(anemona);
        anemona.setBounds(440, 490, 64, 60);

        ballena.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/ballena.png"))); // NOI18N
        getContentPane().add(ballena);
        ballena.setBounds(200, 30, 99, 80);

        burbuja.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/burbujas.png"))); // NOI18N
        getContentPane().add(burbuja);
        burbuja.setBounds(30, 190, 48, 50);

        cangrejo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/cangrejo.png"))); // NOI18N
        cangrejo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cangrejoMouseClicked(evt);
            }
        });
        getContentPane().add(cangrejo);
        cangrejo.setBounds(440, 390, 55, 40);

        caracol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/caracol.png"))); // NOI18N
        getContentPane().add(caracol);
        caracol.setBounds(250, 480, 55, 45);

        caracolmar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/caracolmar.png"))); // NOI18N
        getContentPane().add(caracolmar);
        caracolmar.setBounds(350, 490, 50, 40);

        pezcierra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/cierra.png"))); // NOI18N
        pezcierra.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                pezcierraMouseClicked(evt);
            }
        });
        getContentPane().add(pezcierra);
        pezcierra.setBounds(400, 110, 68, 50);

        concha.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/concha.png"))); // NOI18N
        getContentPane().add(concha);
        concha.setBounds(300, 390, 60, 60);

        coral.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/coral.png"))); // NOI18N
        coral.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                coralMouseClicked(evt);
            }
        });
        getContentPane().add(coral);
        coral.setBounds(140, 480, 65, 60);

        delfin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/delfin.png"))); // NOI18N
        getContentPane().add(delfin);
        delfin.setBounds(70, 50, 89, 48);

        estrella.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/estrella.png"))); // NOI18N
        getContentPane().add(estrella);
        estrella.setBounds(190, 410, 59, 60);

        medusa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/medusa.png"))); // NOI18N
        getContentPane().add(medusa);
        medusa.setBounds(210, 210, 60, 60);

        orca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/orca.png"))); // NOI18N
        orca.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                orcaMouseClicked(evt);
            }
        });
        getContentPane().add(orca);
        orca.setBounds(350, 30, 100, 54);

        pezangel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/pezangel.png"))); // NOI18N
        pezangel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                pezangelMouseClicked(evt);
            }
        });
        getContentPane().add(pezangel);
        pezangel.setBounds(170, 330, 55, 50);

        pezazul.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/pezazul.png"))); // NOI18N
        getContentPane().add(pezazul);
        pezazul.setBounds(70, 120, 45, 30);

        pezdorado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/pezdorado.png"))); // NOI18N
        getContentPane().add(pezdorado);
        pezdorado.setBounds(330, 240, 55, 40);

        pezglobo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/pezglobo.png"))); // NOI18N
        pezglobo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                pezgloboMouseClicked(evt);
            }
        });
        getContentPane().add(pezglobo);
        pezglobo.setBounds(390, 310, 60, 53);

        pezmora.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/pezmora.png"))); // NOI18N
        getContentPane().add(pezmora);
        pezmora.setBounds(30, 360, 58, 40);

        pezpaya.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/pezpaya.png"))); // NOI18N
        getContentPane().add(pezpaya);
        pezpaya.setBounds(410, 450, 50, 30);

        pezseductor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/pezseductor.png"))); // NOI18N
        getContentPane().add(pezseductor);
        pezseductor.setBounds(290, 140, 60, 60);

        pulpo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/pulpo.png"))); // NOI18N
        pulpo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                pulpoMouseClicked(evt);
            }
        });
        getContentPane().add(pulpo);
        pulpo.setBounds(10, 460, 110, 90);

        raya.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/raya.png"))); // NOI18N
        raya.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                rayaMouseClicked(evt);
            }
        });
        getContentPane().add(raya);
        raya.setBounds(140, 150, 77, 40);

        tiburonagresivo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/tiburonagresivo.png"))); // NOI18N
        getContentPane().add(tiburonagresivo);
        tiburonagresivo.setBounds(410, 200, 73, 40);

        tiburonrelax.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/tiburonrelax.png"))); // NOI18N
        getContentPane().add(tiburonrelax);
        tiburonrelax.setBounds(90, 270, 73, 40);

        tortuga.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/tortuga.png"))); // NOI18N
        getContentPane().add(tortuga);
        tortuga.setBounds(250, 310, 60, 50);

        caballomar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/caballomar.png"))); // NOI18N
        getContentPane().add(caballomar);
        caballomar.setBounds(130, 410, 39, 61);

        jButton6.setBackground(new java.awt.Color(0, 204, 153));
        jButton6.setText("Iniciar Juego");
        jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton6MouseClicked(evt);
            }
        });
        getContentPane().add(jButton6);
        jButton6.setBounds(190, 283, 130, 30);
        getContentPane().add(puntaje);
        puntaje.setBounds(30, 3, 200, 30);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ocean/Oceano.jpg"))); // NOI18N
        getContentPane().add(jLabel2);
        jLabel2.setBounds(0, 0, 510, 590);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        estado = false;
        Inicio();
    }//GEN-LAST:event_formWindowOpened

    private void jButton6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton6MouseClicked
        estado = true;
        Inicio();
        jButton6.setVisible(false);
        jButton1.setText("Coral");
        jButton2.setText("Pulpo");
        jButton3.setText("Raya");
        jButton4.setText("Orca");
        turnos=0;
    }//GEN-LAST:event_jButton6MouseClicked

    private void coralMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_coralMouseClicked
        if (jButton1.getText().equals("Coral") || jButton2.getText().equals("Coral") || jButton3.getText().equals("Coral") || jButton4.getText().equals("Coral")) {
            coral.setVisible(false);
            nombre = "Coral";
            CleanBoton();
             contar += 10;
            puntaje.setText("puntos: "+contar);

        }
    }//GEN-LAST:event_coralMouseClicked

    private void pulpoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pulpoMouseClicked
        if (jButton1.getText().equals("Pulpo") || jButton2.getText().equals("Pulpo") || jButton3.getText().equals("Pulpo") || jButton4.getText().equals("Pulpo")) {
            pulpo.setVisible(false);
            nombre = "Pulpo";
            CleanBoton();
             contar += 10;
            puntaje.setText("puntos: "+contar);

        }
    }//GEN-LAST:event_pulpoMouseClicked

    private void rayaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rayaMouseClicked
        if (jButton1.getText().equals("Raya") || jButton2.getText().equals("Raya") || jButton3.getText().equals("Raya") || jButton4.getText().equals("Raya")) {
            raya.setVisible(false);
            nombre = "Raya";
            CleanBoton();
             contar += 10;
            puntaje.setText("puntos: "+contar);

        }
    }//GEN-LAST:event_rayaMouseClicked

    private void cangrejoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cangrejoMouseClicked
        if (jButton1.getText().equals("Cangrejo") || jButton2.getText().equals("Cangrejo") || jButton3.getText().equals("Cangrejo") || jButton4.getText().equals("Cangrejo")) {
            cangrejo.setVisible(false);
            nombre = "Cangrejo";
            CleanBoton();
            jButton1.setText(" ");
           
             contar += 10;
            puntaje.setText("puntos: "+contar);
  Mensaje();
        }
    }//GEN-LAST:event_cangrejoMouseClicked

    private void pezangelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pezangelMouseClicked
        if (jButton1.getText().equals("Pez Angel") || jButton2.getText().equals("Pez Angel") || jButton3.getText().equals("Pez Angel") || jButton4.getText().equals("Pez Angel")) {
            pezangel.setVisible(false);
            nombre = "Pez Angel";
            CleanBoton();
            jButton2.setText(" ");
          
             contar += 10;
            puntaje.setText("puntos: "+contar);
 Mensaje();
        }
    }//GEN-LAST:event_pezangelMouseClicked

    private void pezgloboMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pezgloboMouseClicked
        if (jButton1.getText().equals("Pez Globo") || jButton2.getText().equals("Pez Globo") || jButton3.getText().equals("Pez Globo") || jButton4.getText().equals("Pez Globo")) {
            pezglobo.setVisible(false);
            nombre = "Pez Globo";
            CleanBoton();
            jButton3.setText(" ");
        
             contar += 10;
            puntaje.setText("puntos: "+contar);
 Mensaje();
        }
    }//GEN-LAST:event_pezgloboMouseClicked

    private void pezcierraMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pezcierraMouseClicked
        if (jButton1.getText().equals("Pez Cierra") || jButton2.getText().equals("Pez Cierra") || jButton3.getText().equals("Pez Cierra") || jButton4.getText().equals("Pez Cierra")) {
            pezcierra.setVisible(false);
            nombre = "Pez Cierra";
            CleanBoton();
            jButton4.setText(" ");
          
           contar += 10;
            puntaje.setText("puntos: "+contar);
 Mensaje();
        }
    }//GEN-LAST:event_pezcierraMouseClicked

    private void orcaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_orcaMouseClicked
        if (jButton1.getText().equals("Orca") || jButton2.getText().equals("Orca") || jButton3.getText().equals("Orca") || jButton4.getText().equals("Orca")) {
            orca.setVisible(false);
            nombre = "Orca";
            CleanBoton();
             contar += 10;
            puntaje.setText("puntos: "+contar);

        }
    }//GEN-LAST:event_orcaMouseClicked
public void Mensaje(){
    if (jButton1.getText().equals(" ") && jButton2.getText().equals(" ") && jButton3.getText().equals(" ") && jButton4.getText().equals(" ")) {
    JOptionPane.showMessageDialog(null, "Ganaste el Nivel 2", "Ganaste",  JOptionPane.INFORMATION_MESSAGE);
    JOptionPane.showMessageDialog(null, "Continua con el Nivel 3", "Continuar",  JOptionPane.INFORMATION_MESSAGE);
    Ventana ven= new Ventana();
       ven.setVisible(true);
       ven.setLocationRelativeTo(null);
       this.dispose();
    }
   }
    public void CleanBoton() {
        if (jButton1.getText().equals(nombre)) {
            jButton1.setText("Cangrejo");
        } else if (jButton2.getText().equals(nombre)) {
            jButton2.setText("Pez Angel");
        } else if (jButton3.getText().equals(nombre)) {
            jButton3.setText("Pez Globo");
        } else if (jButton4.getText().equals(nombre)) {
            jButton4.setText("Pez Cierra");
        }
    }

    public void CalculoNombre() {
        if (contar == 1) {
            nombre = "Cangrejo";
        } else if (contar == 2) {
            nombre = "Pez Angel";
        } else if (contar == 3) {
            nombre = "Pez Globo";
        } else if (contar == 4) {
            nombre = "Pez Cierra";
        } else if (contar >= 5) {
            nombre = "";
        }
    }

    public void CalcularSiguiente() {
        if (jButton1.getText().equals(" ")) {
            jButton1.setText(nombre);
        } else if (jButton2.getText().equals(" ")) {
            jButton2.setText(nombre);
        } else if (jButton3.getText().equals(" ")) {
            jButton3.setText(nombre);
        } else if (jButton4.getText().equals(" ")) {
            jButton4.setText(nombre);
        }
    }

    private void Inicio() {
        anemona.setVisible(estado);
        ballena.setVisible(estado);
        cangrejo.setVisible(estado);
        caracol.setVisible(estado);
        estrella.setVisible(estado);
        caracolmar.setVisible(estado);
        caballomar.setVisible(estado);
        pezcierra.setVisible(estado);
        concha.setVisible(estado);
        coral.setVisible(estado);
        delfin.setVisible(estado);
        medusa.setVisible(estado);
        orca.setVisible(estado);
        pezangel.setVisible(estado);
        pezazul.setVisible(estado);
        pezdorado.setVisible(estado);
        pezmora.setVisible(estado);
        pezglobo.setVisible(estado);
        pezseductor.setVisible(estado);
        pezpaya.setVisible(estado);
        pulpo.setVisible(estado);
        raya.setVisible(estado);
        tiburonagresivo.setVisible(estado);
        tiburonrelax.setVisible(estado);
        tortuga.setVisible(estado);
        burbuja.setVisible(estado);
        puntaje.setVisible(estado);
        jButton1.setVisible(estado);
        jButton2.setVisible(estado);
        jButton3.setVisible(estado);
        jButton4.setVisible(estado);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Oceano.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Oceano.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Oceano.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Oceano.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Oceano().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel anemona;
    private javax.swing.JLabel ballena;
    private javax.swing.JLabel burbuja;
    private javax.swing.JLabel caballomar;
    private javax.swing.JLabel cangrejo;
    private javax.swing.JLabel caracol;
    private javax.swing.JLabel caracolmar;
    private javax.swing.JLabel concha;
    private javax.swing.JLabel coral;
    private javax.swing.JLabel delfin;
    private javax.swing.JLabel estrella;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton6;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel medusa;
    private javax.swing.JLabel orca;
    private javax.swing.JLabel pezangel;
    private javax.swing.JLabel pezazul;
    private javax.swing.JLabel pezcierra;
    private javax.swing.JLabel pezdorado;
    private javax.swing.JLabel pezglobo;
    private javax.swing.JLabel pezmora;
    private javax.swing.JLabel pezpaya;
    private javax.swing.JLabel pezseductor;
    private javax.swing.JLabel pulpo;
    private javax.swing.JButton puntaje;
    private javax.swing.JLabel raya;
    private javax.swing.JLabel tiburonagresivo;
    private javax.swing.JLabel tiburonrelax;
    private javax.swing.JLabel tortuga;
    // End of variables declaration//GEN-END:variables
}
