Beispiel #1
0
  public void mousePressed(MouseEvent evt) {
    try {
      if (!neu && !wiedergeben && !verloren && !intro) {
        if (evt.getComponent() == rot) {
          if (farben[klick] != 1) verloren = true;
          else {
            klick++;
            rot.setIcon(new ImageIcon("files/Minigames/Senso/red_1.png"));
            soundAbspielen(soundR);
          }
        } else if (evt.getComponent() == gruen) {
          if (farben[klick] != 2) verloren = true;
          else {
            klick++;
            gruen.setIcon(new ImageIcon("files/Minigames/Senso/green_1.png"));
            soundAbspielen(soundG);
          }
        } else if (evt.getComponent() == blau) {
          if (farben[klick] != 3) verloren = true;
          else {
            klick++;
            blau.setIcon(new ImageIcon("files/Minigames/Senso/blue_1.png"));
            soundAbspielen(soundB);
          }
        } else if (evt.getComponent() == gelb) {
          if (farben[klick] != 4) verloren = true;
          else {
            klick++;
            gelb.setIcon(new ImageIcon("files/Minigames/Senso/yellow_1.png"));
            soundAbspielen(soundY);
          }
        }
        //				else if (evt.getComponent() == beenden)
        //				{
        //					this.setVisible(false);
        //					s.minispielEnde(null);
        //					if (spiel != null)
        //						spiel.interrupt();
        //					neustarten(false);
        //					spiel = new Thread(this);
        //					if (intro)
        //						spiel.start();
        //				}

      }
    } catch (Exception e) {
    }
  }
Beispiel #2
0
 public void mouseReleased(MouseEvent evt) {
   if (!neu && !wiedergeben && !verloren && !intro) {
     if (evt.getSource() == rot) {
       rot.setIcon(new ImageIcon("files/Minigames/Senso/red_0.png"));
       if (klick == runde) {
         wiedergeben = true;
         neu = false;
         points++;
         punkte.setText("Score: " + String.valueOf(points));
         punkte.updateUI();
       }
     }
     if (evt.getSource() == gruen) {
       gruen.setIcon(new ImageIcon("files/Minigames/Senso/green_0.png"));
       if (klick == runde) {
         wiedergeben = true;
         neu = false;
         points++;
         punkte.setText("Score: " + String.valueOf(points));
         punkte.updateUI();
       }
     }
     if (evt.getSource() == blau) {
       blau.setIcon(new ImageIcon("files/Minigames/Senso/blue_0.png"));
       if (klick == runde) {
         wiedergeben = true;
         neu = false;
         points++;
         punkte.setText("Score: " + String.valueOf(points));
         punkte.updateUI();
       }
     }
     if (evt.getSource() == gelb) {
       gelb.setIcon(new ImageIcon("files/Minigames/Senso/yellow_0.png"));
       if (klick == runde) {
         wiedergeben = true;
         neu = false;
         points++;
         punkte.setText("Score: " + String.valueOf(points));
         punkte.updateUI();
       }
     }
   }
 }
Beispiel #3
0
 public void mouseClicked(MouseEvent evt) {
   if (evt.getComponent() == beenden) {
     this.setVisible(false);
     Game.Information[] infos = null;
     if (runde > 0) {
       infos = new Game.Information[2];
       infos[0] =
           new Game.Information(
               Game.Information.AENDERN_BEWERBUNGSFAKTOR, Game.Information.ART_UM_WERT, runde);
       infos[1] =
           new Game.Information(
               Game.Information.AENDERN_SOZIALES, Game.Information.ART_UM_WERT, 2 * runde);
     }
     s.minispielEnde(infos);
     läuft = false;
     //			if (spiel != null)
     //				spiel.interrupt();
     //			neustarten(false);
     //			spiel = new Thread(this);
     //			if (intro)
     //				spiel.start();
   } else if (evt.getComponent() == neustart && verloren) neustarten(true);
 }
      public void update(MouseEvent e) {
        mouseReleased = e.getX();
        Selection currSelection = zoomStack.get(zoomStack.size() - 1);

        if (mousePressed > mouseReleased) {
          selBeginPixel = mouseReleased;
          selEndPixel = mousePressed;
        } else {
          selBeginPixel = mousePressed;
          selEndPixel = mouseReleased;
        }

        if (selBeginPixel < 1) selBeginPixel = 1;

        if (selEndPixel > frameWidth) {
          selEndPixel = frameWidth;
        }

        selBeginSample = (int) Math.floor(selBeginPixel * samplePerPixel);
        selEndSample = (int) Math.floor(selEndPixel * samplePerPixel);

        //				//stopped dragging outside the window.
        //				if(selEndSample > currSelection.endSelInSamples) {
        //
        //				//System.err.println(selEndSample + " " + data.size());
        //					selEndSample = currSelection.endSelInSamples;
        //				}
        //
        //				//stopped dragging outside the window
        //				if(selBeginSample < currSelection.beginSelInSamples)
        //					selBeginSample = currSelection.beginSelInSamples;

        wavePanel.repaint();

        if (!myHelper.isPlaying()) {
          playSelectionBtn.setEnabled(true);

          if (points.size() > zoomStop) {
            zoomInBtn.setEnabled(true);
          }
        }
        if (DEBUG) System.err.println(selBeginSample + " " + selEndSample);
      }
Beispiel #5
0
 public void mouseEntered(MouseEvent evt) {
   if (evt.getSource() == beenden) beenden.setForeground(Color.white);
   else if (evt.getSource() == neustart && verloren) neustart.setForeground(Color.white);
 }
 public void mousePressed(MouseEvent e) {
   mousePressed = e.getX();
 }
 public void mouseMoved(MouseEvent e) {
   mX = e.getX();
   mY = e.getY();
 }
  @Override
  public void mousePressed(MouseEvent e) {
    CustomButton buttonPressed; // Button that was pressed.
    String buttonName; // The name of the button.
    int option; // Option chosen by user.
    User buyer; // User object for buyer
    User seller; // User object for seller
    Item selected_item; // Item object for selected item

    if (help) // if in help mode
    {
      help = false;
      repaint();
      return;
    }

    wasItemSelected(e.getX(), e.getY());
    buttonPressed = CustomButton.wasPressed(e.getX(), e.getY());

    if (buttonPressed == null) // if no button was pressed
    {
      return;
    }

    buttonName = buttonPressed.getName();
    playAudio(-1);

    switch (buttonName) // handle event associated with button name
    {
      case "rightTab":
        currentPage++;
        itemSelected = -1;
        break;

      case "leftTab":
        currentPage--;
        itemSelected = -1;
        break;

      case "buyTab":
        mode = false;
        break;

      case "sellTab":
        mode = true;
        break;

      case "button":
        selected_item = itemsArray[itemSelected];

        option =
            JOptionPane.showConfirmDialog(
                this, ((!mode) ? "Buy " : "Sell ") + "for " + "$" + selected_item.getPrice() + "?");

        if (option == 0 && (!mode)) // if they choose to buy
        {
          buyer = usersArray[0];
          switch (store) // change message based on value of store.
          {
            case 0:
              seller = usersArray[2];
              break;

            case 1:
              seller = usersArray[1];
              break;

            case 2:
              seller = usersArray[3];
              break;

            case 3:
              seller = usersArray[4];
              break;

            default:
              seller = usersArray[1];
          }

          buyItemFromUser(buyer, seller, selected_item);

        } else if (option == 0 && mode) // if they choose to sell
        {
          seller = usersArray[0];

          switch (store) // change message based on value of store.
          {
            case 0:
              buyer = usersArray[2];
              break;

            case 1:
              buyer = usersArray[1];
              break;

            case 2:
              buyer = usersArray[3];
              break;

            case 3:
              buyer = usersArray[4];
              break;

            default:
              buyer = usersArray[1];
          }

          buyItemFromUser(buyer, seller, selected_item);
        }

        itemSelected = -1;
        break;

      case "nextStore":
        if (++store == NUMSTORES) // if we're on the last store, loop around
        {
          store = 0;
        }

        switchStore(store);
        break;

      case "sort":
        // something
        orderToSort =
            JOptionPane.showOptionDialog(
                this,
                "Sort by:",
                "Sort",
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null,
                SORTOPTIONS,
                null);

        break;

      case "help":
        help = true;
        break;

      default:
    }

    repaint();
  }