コード例 #1
0
ファイル: Util.java プロジェクト: zbolmb/MULE
 /**
  * Handlers check for keypresses left, right, up, down arrow keys If left is pressed, add value
  * of-5 to left move (decrease X to move left) right is pressed, add 5 to right move (increase X
  * to move up) up is pressed, add -5 to up (decrease Y to move up) down is pressed, add 5 to down
  * (increase Y to move down)
  *
  * @param scene Scene
  */
 public static void addMovementHandlers(Scene scene) {
   scene.addEventHandler(
       KeyEvent.KEY_PRESSED,
       k -> {
         if (k.getCode() == KeyCode.LEFT) {
           Configurations.getLoopService().setL(-5);
         }
         if (k.getCode() == KeyCode.RIGHT) {
           Configurations.getLoopService().setR(5);
         }
         if (k.getCode() == KeyCode.UP) {
           Configurations.getLoopService().setU(-5);
         }
         if (k.getCode() == KeyCode.DOWN) {
           Configurations.getLoopService().setD(5);
         }
       });
   scene.addEventHandler(
       KeyEvent.KEY_RELEASED,
       k -> {
         if (k.getCode() == KeyCode.LEFT) {
           Configurations.getLoopService().setL(0);
         }
         if (k.getCode() == KeyCode.RIGHT) {
           Configurations.getLoopService().setR(0);
         }
         if (k.getCode() == KeyCode.UP) {
           Configurations.getLoopService().setU(0);
         }
         if (k.getCode() == KeyCode.DOWN) {
           Configurations.getLoopService().setD(0);
         }
       });
 }
コード例 #2
0
ファイル: Util.java プロジェクト: zbolmb/MULE
  /**
   * gives turns for buying to players
   *
   * @throws IOException exception
   */
  private static void buyTurnIncre() throws IOException {
    if (playerOrder.isEmpty()) {
      for (Player p : Configurations.getPlayers()) {
        if (p.getMoney() > 300 && !p.isPassed()) {
          playerOrder.add(p);
        }
      }
      if (playerOrder.isEmpty()) {
        Configurations.setRound(Configurations.getRound() + 1);

        // Applying random event to player 1 during initial game start
        Configurations.getCurPlayer().setMessage(applyRandomEvent());
        Configurations.getGameScreenController()
            .updateText(Configurations.getCurPlayer().getMessage());
        Configurations.getLoopService().start();
        movePhaseTurnIncre();
        return;
      }
    }
    Configurations.setCurPlayer(playerOrder.remove());
    if (Configurations.getCurPlayer().isPassed()) {
      buyTurnIncre();
    }
    Configurations.getGameScreenController().updateText();
  }