예제 #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();
  }
예제 #2
0
  private void updateStatus() {
    logLabel.setText(shop.getLog().getMessages());

    statusLabel.setText(
        String.format(
            "Total Customers: %d\nTotal Employees: %d\n\nRegister Til: %s\nOrders Proccessed: %d",
            shop.getCustomers().size(),
            shop.getEmployees().size(),
            moneyFormat.format(shop.getRegister().getTil().getTotal()),
            shop.getOrders().size()));
  }
예제 #3
0
  private void checkoutWindow() {
    // Check for errors
    if (shop.getActiveCashier() == null) {
      showError("You must choose an active cashier");
      return;
    } else if (shop.getActiveCashier().getPatience() < 1) {
      showError("Cashier is out of patience");
      return;
    }

    this.subManager.setScene(new CheckoutState(this.subManager, shop).scene);
    this.subManager.getStage().show();
  }
예제 #4
0
  private void stockerWindow() {
    if (shop.getActiveStocker() == null) {
      showError("You must choose an active stocker");
      return;
    }

    this.subManager.setScene(new StockerState(this.subManager, shop).scene);
    this.subManager.getStage().show();
  }
예제 #5
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();
  }