/*
 * 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 Constelacion extends javax.swing.JFrame {

private boolean estado;
private int turnos=0;
private int contar;
private String nombre;
    /**
     * Creates new form Constelacion
     */
    public Constelacion() {
        initComponents();
        setResizable(false);  
        setBounds(0, 0, 550, 450);
        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() {

        nave = new javax.swing.JLabel();
        asteroide = new javax.swing.JLabel();
        cometa = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();
        estrella = new javax.swing.JLabel();
        marciano = new javax.swing.JLabel();
        marte = new javax.swing.JLabel();
        navemarciano = new javax.swing.JLabel();
        satelite = new javax.swing.JLabel();
        astronauta = new javax.swing.JLabel();
        saturno = new javax.swing.JLabel();
        sol = new javax.swing.JLabel();
        tierra = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        urano = new javax.swing.JLabel();
        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);

        nave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/cohete.png"))); // NOI18N
        getContentPane().add(nave);
        nave.setBounds(440, 50, 75, 130);

        asteroide.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/asteroide.png"))); // NOI18N
        asteroide.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                asteroideMouseClicked(evt);
            }
        });
        getContentPane().add(asteroide);
        asteroide.setBounds(100, 300, 50, 50);

        cometa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/cometa.png"))); // NOI18N
        getContentPane().add(cometa);
        cometa.setBounds(210, 310, 100, 50);

        jButton5.setBackground(new java.awt.Color(0, 0, 255));
        jButton5.setText("Iniciar Juego");
        jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton5MouseClicked(evt);
            }
        });
        getContentPane().add(jButton5);
        jButton5.setBounds(220, 210, 130, 23);

        estrella.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/estrella.png"))); // NOI18N
        getContentPane().add(estrella);
        estrella.setBounds(340, 20, 45, 50);

        marciano.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/marciano.png"))); // NOI18N
        getContentPane().add(marciano);
        marciano.setBounds(260, 140, 55, 76);

        marte.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/marte.png"))); // NOI18N
        getContentPane().add(marte);
        marte.setBounds(250, 210, 80, 80);

        navemarciano.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/nave.png"))); // NOI18N
        getContentPane().add(navemarciano);
        navemarciano.setBounds(30, 210, 75, 40);

        satelite.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/satelite.png"))); // NOI18N
        getContentPane().add(satelite);
        satelite.setBounds(210, 50, 85, 50);

        astronauta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/astronauta.png"))); // NOI18N
        astronauta.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                astronautaMouseClicked(evt);
            }
        });
        getContentPane().add(astronauta);
        astronauta.setBounds(370, 90, 70, 60);

        saturno.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/saturno.png"))); // NOI18N
        getContentPane().add(saturno);
        saturno.setBounds(370, 260, 100, 50);

        sol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/sol.png"))); // NOI18N
        sol.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                solMouseClicked(evt);
            }
        });
        getContentPane().add(sol);
        sol.setBounds(0, 0, 150, 130);

        tierra.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/tierra.png"))); // NOI18N
        getContentPane().add(tierra);
        tierra.setBounds(150, 140, 80, 80);

        jButton1.setBackground(new java.awt.Color(204, 0, 204));
        jButton1.setText("jButton1");
        getContentPane().add(jButton1);
        jButton1.setBounds(30, 400, 100, 23);

        jButton2.setBackground(new java.awt.Color(204, 0, 204));
        jButton2.setText("jButton2");
        getContentPane().add(jButton2);
        jButton2.setBounds(170, 400, 100, 23);

        jButton3.setBackground(new java.awt.Color(204, 0, 204));
        jButton3.setText("jButton3");
        getContentPane().add(jButton3);
        jButton3.setBounds(310, 400, 100, 23);

        jButton4.setBackground(new java.awt.Color(204, 0, 204));
        jButton4.setText("jButton4");
        getContentPane().add(jButton4);
        jButton4.setBounds(450, 400, 90, 23);

        urano.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/urano.png"))); // NOI18N
        urano.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                uranoMouseClicked(evt);
            }
        });
        getContentPane().add(urano);
        urano.setBounds(470, 310, 70, 70);
        getContentPane().add(puntaje);
        puntaje.setBounds(150, 10, 190, 30);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Constela/Constelacion.jpg"))); // NOI18N
        getContentPane().add(jLabel2);
        jLabel2.setBounds(0, 0, 550, 440);

        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 jButton5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton5MouseClicked
       estado=true;
    Inicio();
    jButton5.setVisible(false);
     jButton1.setText("Asteroide");
     jButton2.setText("Sol");
         jButton3.setText("Astronauta");
       jButton4.setText("Urano");
  
    }//GEN-LAST:event_jButton5MouseClicked

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

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

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

    private void astronautaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_astronautaMouseClicked
         if(jButton1.getText().equals("Astronauta") || jButton2.getText().equals("Astronauta") || jButton3.getText().equals("Astronauta") || jButton4.getText().equals("Astronauta")){
           astronauta.setVisible(false);
            nombre="Astronauta";
            CleanBoton();
            jButton3.setText(" ");
            
             contar += 10;
            puntaje.setText("puntos: "+contar);
            Mensaje();
                    
         
         }
    }//GEN-LAST:event_astronautaMouseClicked
 private void Inicio(){
    nave.setVisible(estado);
    asteroide.setVisible(estado);
    cometa.setVisible(estado);
    estrella.setVisible(estado);
    marciano.setVisible(estado);
    marte.setVisible(estado);
    navemarciano.setVisible(estado);
    satelite.setVisible(estado);
    astronauta.setVisible(estado);
    saturno.setVisible(estado);
    sol.setVisible(estado);
    tierra.setVisible(estado);
    urano.setVisible(estado);
    puntaje.setVisible(estado);
    jButton1.setVisible(estado);
    jButton2.setVisible(estado);
    jButton3.setVisible(estado);
    jButton4.setVisible(estado);
    }
    /**
     * @param args the command line arguments
     */
 public void Mensaje(){
    if (jButton1.getText().equals(" ") && jButton2.getText().equals(" ") && jButton3.getText().equals(" ") && jButton4.getText().equals(" ")) {
    JOptionPane.showMessageDialog(null, "Ganaste el Nivel 1", "Ganaste",  JOptionPane.INFORMATION_MESSAGE);
    JOptionPane.showMessageDialog(null, "Continua con el Nivel 2", "Continuar",  JOptionPane.INFORMATION_MESSAGE);
    Oceano oc= new Oceano();
       oc.setVisible(true);
       oc.setLocationRelativeTo(null);
       this.dispose();
    }
   }
 public void CleanBoton(){
    if(jButton1.getText().equals(nombre)){
       jButton1.setText("  ");
    }else
    if(jButton2.getText().equals(nombre)){
       jButton2.setText(" ");
    }else
        if(jButton3.getText().equals(nombre)){
       jButton3.setText(" ");
        }else
        if(jButton4.getText().equals(nombre)){
       jButton4.setText(" ");
}
   }
 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);
  }
  }
 
 
    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(Constelacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Constelacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Constelacion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Constelacion.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 Constelacion().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel asteroide;
    private javax.swing.JLabel astronauta;
    private javax.swing.JLabel cometa;
    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 jButton5;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel marciano;
    private javax.swing.JLabel marte;
    private javax.swing.JLabel nave;
    private javax.swing.JLabel navemarciano;
    private javax.swing.JButton puntaje;
    private javax.swing.JLabel satelite;
    private javax.swing.JLabel saturno;
    private javax.swing.JLabel sol;
    private javax.swing.JLabel tierra;
    private javax.swing.JLabel urano;
    // End of variables declaration//GEN-END:variables
}
                                       
                                
     
    
    
    
