Ejemplo n.º 1
0
  private void startGame() {
    // Start clock
    gameClock.start();

    // Queue customers
    for (Customer c : shop.getCustomers())
      shop.getLog().addLog(c.getName() + " enters the building");

    new Thread(
            new Runnable() {

              @Override
              public void run() {
                for (Customer c : shop.getCustomers()) {
                  game.addCustomer();
                  try {
                    Thread.sleep(300);
                  } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  }
                }

                return;
              }
            })
        .start();

    // Status
    updateStatus();
  }
Ejemplo n.º 2
0
  public GameState(StateManager sm) {
    super(sm);
    shop = new Shop();
    game = new ShopSimulation(shop);
    gameClock = new GameClock();

    gameClock.setListener(
        new GameClock.GameClockListener() {
          @Override
          public void crappyHourBegins() {
            game.startCrappyHour();
            Platform.runLater(() -> shop.getLog().addLog("The chaos has begun.."));
          }

          @Override
          public void shopClosed() {

            Platform.runLater(() -> endGame());
          }
        });

    // Check if game closed
    sm.getStage().setOnCloseRequest(e -> stageClosed());

    statusLabel = new Label();
    shop.setListener(this);

    moneyFormat = NumberFormat.getCurrencyInstance();

    // Setup basic panes + contents
    BorderPane rootPane = new BorderPane();
    rootPane.setStyle("-fx-background-color: #474F53;");

    rootPane.setTop(new VBox(initMenu(), initStatusBar()));

    rootPane.setBottom(initGame());

    startGame();

    scene = new Scene(rootPane);
    setupStyle();
    setupSubWindow();
  }
Ejemplo n.º 3
0
 private void stageClosed() {
   gameClock.stop();
 }