예제 #1
0
  @Override
  public void update(Observable o, GameEvent e) {
    if (!(e instanceof ActionEvent)) return;

    ActionEvent ev = (ActionEvent) e;
    switch (ev.getMessage()) {
      case "back":
        {
          context.goNext(Screens.START, GameManager.RESUME);
          break;
        }
      case "effects_activate":
        {
          context.getSoundManager().enableEffects(true);
          break;
        }
      case "effects_deactivate":
        {
          context.getSoundManager().enableEffects(false);
          System.out.println("Sound deactivated");
          break;
        }
      case "background_activate":
        {
          context.getSoundManager().enableBackgroundMusic(true);
          break;
        }
      case "background_deactivate":
        {
          context.getSoundManager().stopBackgroundSound();
          context.getSoundManager().enableBackgroundMusic(false);
          break;
        }
      case "mouse":
        {
          context.setMouseEnabled(true);
          break;
        }
      case "keyboard":
        {
          context.setMouseEnabled(false);
          break;
        }
      default:
        break;
    }
  }
예제 #2
0
  @Override
  public void update(Observable o, GameEvent e) {
    if (!(e instanceof ActionEvent)) return;

    ActionEvent ev = (ActionEvent) e;

    switch (ev.getMessage()) {
      case "back":
        if (textBox.isEnabled() && !entryAdded) return;
        else context.goNext(Screens.START, GameManager.RESUME);
        break;
      case "player_text":
        String text = textBox.getText();
        context.getLeaderboard().insert(new Player(text, context.getHUDManager().getScore()));
        context.getLeaderboard().save(GameSettings.LEADERBOARD_PATH);
        textBox.setEnabled(false);
        entryAdded = true;
        break;
      default:
        break;
    }
  }