public ProcessingAnimationView( ProcessingAnimationModel animationModel) { // ProcessingAnimationModel animationModel, MachineTestController // testController) { this.processingAnimationModel = animationModel; // this.machineTestController = testController; imageViewTop = new ImageView(); imageViewTop.setFitWidth(270); imageViewTop.setFitHeight(100); imageViewTop.setX(200); imgTop = new Image("file:Image\\animation\\presTop.png"); imageViewTop.setImage(imgTop); imageViewBot = new ImageView(); imageViewBot.setTranslateY(40); imageViewBot.setFitWidth(270); imageViewBot.setFitHeight(300); imgBot = new Image("file:Image\\animation\\presBot.png"); imageViewBot.setPreserveRatio(true); imageViewBot.setX(200); imageViewBot.setImage(imgBot); Image imgStorage = new Image("file:Image\\animation\\storage.png"); imageViewLeftStorage = new ImageView(); imageViewLeftStorage.setFitWidth(200); imageViewLeftStorage.setFitHeight(80); imageViewLeftStorage.setY(185); imageViewLeftStorage.setImage(imgStorage); imageViewRightStorage = new ImageView(); imageViewRightStorage.setFitWidth(200); imageViewRightStorage.setFitHeight(80); imageViewRightStorage.setY(185); imageViewRightStorage.setX(500); imageViewRightStorage.setImage(imgStorage); rectangle = new Rectangle(340, 185, 15, 5); // rectangle.setVisible(false); rectangle.setFill(Color.CORAL); circle = new Circle(190, 180, 10); circle.setFill(Color.CORAL); this.getChildren() .addAll( imageViewLeftStorage, imageViewRightStorage, rectangle, circle, imageViewBot, imageViewTop); this.setMinSize(300, 300); timeline = new Timeline(); transitionCircle = new TranslateTransition(); transitionRect = new TranslateTransition(); products = new Stack<>(); }
private Scene createMainTetrisScene() { mainPane = new BorderPane(); VBox mainBox = new VBox(); mainBox.setPadding(new Insets(200, 0, 0, 20)); mainBox.getChildren().add(mainGrid); mainGrid.setOnKeyPressed(new KeyboardHandler()); mainPane.setBottom(mainBox); mainPane.setTop(createActionPane()); mainPane.setRight(createStatePane()); Group group = new Group(); for (int i = 19; i >= 0; i--) { for (int j = 0; j < 10; j++) { Image img; if (mainGrid.getColor(i, j) != Color.DARKGRAY) { img = new Image(getClass().getResourceAsStream("RED.png")); } else { img = new Image(getClass().getResourceAsStream("EMPTY.png")); } ImageView iView = new ImageView(img); iView.setX(j * 17); iView.setY(i * 16); iView.setOpacity(1); iView.setPreserveRatio(true); group.getChildren().addAll(iView); } } Scene scene = new Scene(group, 600, 600); mainPane.setCenter(group); return new Scene(mainPane, 380, 540); // 540 }
public ArrayList<Location> displayRange( ArrayList<ImageView> tiles, BattleMem player, Location[][] map, ArrayList<BattleMem> people) { ArrayList<Location> ans = new ArrayList<Location>(); int range = player.member.getMove(); int xLimit = map[0].length; int yLimit = map.length; for (int i = player.mapLoc.x - range; i <= player.mapLoc.x + range; i++) { for (int j = player.mapLoc.y - range; j <= player.mapLoc.y + range; j++) { if (j >= 0 && j < yLimit) { if (i >= 0 && i < xLimit) { if (Math.abs(j - player.mapLoc.y) + Math.abs(i - player.mapLoc.x) <= range) { Image t = new Image("fantasytactics/images/tile.png", 66, 98, false, false); boolean nonaccess = false; for (BattleMem k : people) { if (k.mapLoc.equals(new Location(i, j))) { nonaccess = true; break; } } if (!nonaccess) { if (map[j][i] != null) { ans.add(map[j][i]); ImageView tile = new ImageView(t); tile.setX(map[j][i].x); tile.setY(map[j][i].y); tiles.add(tile); } } } } } } } return ans; }
private void moveB() { if (imageView.getX() == -360 || imageView.getY() != 0) { imageView.setX(-90); imageView.setY(0); } else { imageView.setX(imageView.getX() - 30); } }
public void drawBarUp() { barUpR = new Rectangle(0, 0, 1000, 50); barUpR.setFill(new ImagePattern(barUp, 0, 0, barUp.getWidth(), barUp.getHeight(), false)); i = new ImageView(); i.setImage(barUpRight); i.setX(1000); i.setY(0); }
private void moveR() { if (imageView.getX() == -270 || imageView.getY() != -2530) { imageView.setX(0); imageView.setY(-2530); } else { imageView.setX(imageView.getX() - 30); } }
@Override public void start(final Stage primaryStage) { Start.create(); menu = false; playTurn = false; URL u = getClass().getResource("start.mp3"); bgm = new MediaPlayer(new Media(u.toString())); bgm.setCycleCount(MediaPlayer.INDEFINITE); bgm.play(); root = new Group(); Image title = new Image("fantasytactics/images/title.png", 720, 600, false, false); ImageView view = new ImageView(title); Image cursor = new Image("fantasytactics/images/cursor.png"); final ImageView point = new ImageView(cursor); point.setX(165); point.setY(420); root.getChildren().add(view); root.getChildren().add(point); scene = new Scene(root, 720, 600); scene.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent e) { switch (e.getCode()) { case DOWN: if (point.getY() == 420) { point.setY(460); } break; case UP: if (point.getY() == 460) { point.setY(420); } break; case ENTER: if (point.getY() == 420) { newGame(primaryStage); } else if (point.getY() == 460) { if (loadGame(primaryStage)) { missionSelectPane(primaryStage); } else { } } } } }); primaryStage.setTitle("Fantasy Tactics"); primaryStage.setScene(scene); primaryStage.show(); }
private SequentialTransition createTransition( final Point2D pntStartPoint, final Point2D pntEndPoint, ImageView imView) { imView = new ImageView( new Image(getClass().getResourceAsStream("/res/img/b1fh.png"), 75, 75, true, true)); imView.setX(pntStartPoint.getX()); imView.setY(pntStartPoint.getY() - 30); APMainScreen.getChildren().add(imView); TranslateTransition translateTransition = new TranslateTransition(Duration.millis(300), imView); translateTransition.setFromX(0); translateTransition.setToX(pntEndPoint.getX() - pntStartPoint.getX()); translateTransition.setFromY(0); translateTransition.setToY(pntEndPoint.getY() - pntStartPoint.getY()); translateTransition.setCycleCount(1); translateTransition.setAutoReverse(false); int rnd = randInt(1, 3); RotateTransition rotateTransition = new RotateTransition(Duration.millis(150), imView); rotateTransition.setByAngle(90F); rotateTransition.setCycleCount(rnd); rotateTransition.setAutoReverse(false); ParallelTransition parallelTransition = new ParallelTransition(); parallelTransition.getChildren().addAll(translateTransition, rotateTransition); SequentialTransition seqTrans = new SequentialTransition(); seqTrans.getChildren().addAll(parallelTransition); final ImageView ivRemove = imView; seqTrans.setOnFinished( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { APMainScreen.getChildren().remove(ivRemove); } }); return seqTrans; }
public void repaint3D() { mainPane = new BorderPane(); VBox mainBox = new VBox(); mainBox.setPadding(new Insets(200, 0, 0, 20)); mainBox.getChildren().add(mainGrid); mainGrid.setOnKeyPressed(new KeyboardHandler()); mainPane.setBottom(mainBox); mainPane.setTop(createActionPane()); mainPane.setRight(createStatePane()); Group group = new Group(); for (int i = 22; i >= 0; i--) { for (int j = -1; j < 11; j++) { Image img; if (i == 22 || (j == -1 || j == 10)) img = new Image(getClass().getResourceAsStream("GRAY.png")); else if (mainGrid.getColor(i, j) == Color.YELLOW) img = new Image(getClass().getResourceAsStream("YELLOW.png")); else if (mainGrid.getColor(i, j) == Color.MAGENTA) img = new Image(getClass().getResourceAsStream("RED.png")); else if (mainGrid.getColor(i, j) == Color.GREEN) img = new Image(getClass().getResourceAsStream("GREEN.png")); else if (mainGrid.getColor(i, j) == Color.ORANGE) img = new Image(getClass().getResourceAsStream("ORANGE.png")); else if (mainGrid.getColor(i, j) == Color.BLUE) img = new Image(getClass().getResourceAsStream("BLUE.png")); else if (mainGrid.getColor(i, j) == Color.CYAN) img = new Image(getClass().getResourceAsStream("CYAN.png")); else if (mainGrid.getColor(i, j) == Color.PINK) img = new Image(getClass().getResourceAsStream("VIOLET.png")); else img = new Image(getClass().getResourceAsStream("EMPTY.png")); ImageView iView = new ImageView(img); iView.setX(j * 17); iView.setY(i * 16); iView.setOpacity(1); iView.setPreserveRatio(true); group.getChildren().addAll(iView); } } mainPane.setCenter(group); // Stage old = stage3D; // stage3D = new Stage(); stage3D.setScene(new Scene(mainPane, 380, 540)); }
/** * Instantiates the tileSet images using an image selected by the user. Given the number of rows * that the user input at the program startup, this automatically calculates the positions of the * individual tile images, and sets the tileSize for all tiles. * * <p>Note: tiles must be designed to be squares. * * @param file The image file containing what will be the map tiles */ public void openTileSet(File file) { try { origTileImage = ImageIO.read(file); tileSize = (int) origTileImage.getHeight() / numTileRows; // Minus 1 because tileSet matrix starts at index 0 numTileColumns = (int) origTileImage.getWidth() / tileSize; tileSet = new BufferedImage[numTileRows][numTileColumns]; for (int row = 0; row < numTileRows; row++) { for (int col = 0; col < numTileColumns; col++) { tileSet[row][col] = origTileImage.getSubimage(col * tileSize, row * tileSize, tileSize, tileSize); } } } catch (Exception ex) { ex.printStackTrace(); } // add tileSet to tileMap so that it is shown on screen for (int i = 0; i < numTileRows; i++) { for (int j = 0; j < numTileColumns; j++) { Image image = SwingFXUtils.toFXImage(tileSet[i][j], null); ImageView imageView = new ImageView(image); imageView.setX(j * tileSize); imageView.setY(i * tileSize); imageView.setFitWidth(tileSize); imageView.setFitHeight(tileSize); tileMap.getChildren().add(imageView); } } // Make the first tile selected currentTile = 0; double tx = ((ImageView) tileMap.getChildren().get(0)).getX(); double ty = ((ImageView) tileMap.getChildren().get(0)).getY(); double tw = ((ImageView) tileMap.getChildren().get(0)).getFitWidth(); double th = ((ImageView) tileMap.getChildren().get(0)).getFitHeight(); tileOutline = new Rectangle(tx, ty, tw, th); tileOutline.setStroke(Color.RED); tileOutline.setFill(null); tileMap.getChildren().add(tileOutline); }
/** * Loads a map from file: converts the values from the passed int matrix into images given by the * tileSet. The value in the map is the tile number. The matrix is passed to this method by {@code * loadMap()} in the KeyPressedListener class. * * @param oldMap int matrix holding tile numbers that correspond to a specific tile. */ public void loadOldMap(int[][] oldMap) { constructedMap.getChildren().clear(); mapX = tileSize; mapY = tileSize; mapW = oldMap[0].length; mapH = oldMap.length; mapOutline.setX(mapX); mapOutline.setY(mapY); mapOutline.setWidth(mapW * tileSize); mapOutline.setHeight(mapH * tileSize); map = new int[mapH][mapW]; for (int row = 0; row < mapH; row++) { for (int col = 0; col < mapW; col++) { currentTile = map[row][col] = oldMap[row][col]; // Get the right tile from tileSet int tileRow = (int) currentTile / numTileColumns; int tileCol = currentTile % numTileColumns; // Get the right image Image image = SwingFXUtils.toFXImage(tileSet[tileRow][tileCol], null); ImageView imageView = new ImageView(image); // Add the selected tile to the screen double imageX = mapOutline.getX() + col * tileSize; double imageY = mapOutline.getY() + row * tileSize; imageView.setX(imageX); imageView.setY(imageY); imageView.setFitWidth(tileSize); imageView.setFitHeight(tileSize); updateConstructedMap(imageView); } } currentTile = 0; updateCurrentTile(); }
/** Create the game's scene */ public Scene init(int width, int height) { // Create a scene graph to organize the scene Group root = new Group(); // Create a place to see the shapes myScene = new Scene(root, width, height, Color.WHITE); // Make some shapes and set their properties Image image = new Image(getClass().getClassLoader().getResourceAsStream("duke.gif")); myBouncer = new ImageView(image); // x and y represent the top left corner, so center it myBouncer.setX(width / 2 - myBouncer.getBoundsInLocal().getWidth() / 2); myBouncer.setY(height / 2 - myBouncer.getBoundsInLocal().getHeight() / 2); myTopBlock = new Rectangle(width / 2 - 25, height / 2 - 100, 50, 50); myTopBlock.setFill(Color.RED); myBottomBlock = new Rectangle(width / 2 - 25, height / 2 + 50, 50, 50); myBottomBlock.setFill(Color.BISQUE); // order added to the group is the order in whuch they are drawn root.getChildren().add(myBouncer); root.getChildren().add(myTopBlock); root.getChildren().add(myBottomBlock); // Respond to input myScene.setOnKeyPressed(e -> handleKeyInput(e.getCode())); myScene.setOnMouseClicked(e -> handleMouseInput(e.getX(), e.getY())); return myScene; }
@Override public void handle(MouseEvent e) { if (e.isPrimaryButtonDown()) { // If in bounds of the map if (e.getX() > mp.mapOutline.getX() && e.getY() > mp.mapOutline.getY() && e.getX() < mp.mapOutline.getX() + mp.mapOutline.getWidth() && e.getY() < mp.mapOutline.getY() + mp.mapOutline.getHeight()) { // Get the right tile from tileSet int tileRow = 0; int tileCol = 0; int selectionIndex = mp.currentTile; while (selectionIndex > mp.numTileColumns - 1) { selectionIndex = selectionIndex - mp.numTileColumns; tileRow++; } tileCol = selectionIndex; Image image = SwingFXUtils.toFXImage(mp.tileSet[tileRow][tileCol], null); ImageView imageView = new ImageView(image); // Save the currentTile to the map // int type-casting rounds x/y down -> tile placement on the map "grid" // This overwrites any previous tile number in the map matrix int mapCol = (int) (e.getX() - mp.mapOutline.getX()) / mp.tileSize; int mapRow = (int) (e.getY() - mp.mapOutline.getY()) / mp.tileSize; mp.map[mapRow][mapCol] = mp.currentTile; // Add the selected tile to the screen double imageX = mp.mapOutline.getX() + mapCol * mp.tileSize; double imageY = mp.mapOutline.getY() + mapRow * mp.tileSize; imageView.setX(imageX); imageView.setY(imageY); imageView.setFitWidth(mp.tileSize); imageView.setFitHeight(mp.tileSize); mp.updateConstructedMap(imageView); } // End if mouse inside map // Else if mouse inside tilePane // Not working yet because tileMap can't gain focus // and MapPane loses focus upon mouse leaving /*else if (e.getY() > mp.getHeight() - mp.tileSize*mp.numTileRows){ int col = (int) e.getX()/mp.tileSize; int row = (int) e.getY()/mp.tileSize; mp.currentTile = col + row*col; mp.updateCurrentTile(); } */ } // End if mouse is left button else if (e.isSecondaryButtonDown()) { if (e.getX() > mp.mapOutline.getX() && e.getY() > mp.mapOutline.getY() && e.getX() < mp.mapOutline.getX() + mp.mapOutline.getWidth() && e.getY() < mp.mapOutline.getY() + mp.mapOutline.getHeight()) { // Get the empty image Image image = SwingFXUtils.toFXImage(mp.tileSet[0][0], null); ImageView imageView = new ImageView(image); // Save to map int mapCol = (int) (e.getX() - mp.mapOutline.getX()) / mp.tileSize; int mapRow = (int) (e.getY() - mp.mapOutline.getY()) / mp.tileSize; mp.map[mapRow][mapCol] = 0; // Add the selected tile to the screen double imageX = mp.mapOutline.getX() + mapCol * mp.tileSize; double imageY = mp.mapOutline.getY() + mapRow * mp.tileSize; imageView.setX(imageX); imageView.setY(imageY); imageView.setFitWidth(mp.tileSize); imageView.setFitHeight(mp.tileSize); mp.updateConstructedMap(imageView); } // End if mouse inside map } // End else if } // End handle
@FXML void initialize() { preview.setX(0); preview.setY(0); preview.setImage(new Image("1.jpg")); }
public void startMission(final Mission m, final Stage stage) { root = new Group(); bgm.stop(); URL u = getClass().getResource("battle.mp3"); bgm = new MediaPlayer(new Media(u.toString())); bgm.setCycleCount(MediaPlayer.INDEFINITE); bgm.play(); final BattleClan enemy = new BattleClan(); final BattleClan player = new BattleClan(); play = player; Image map = new Image("fantasytactics/images/" + m.mapName, m.width, m.height, false, false); ImageView mapView = new ImageView(map); mapView.setX(0); mapView.setY(0); root.getChildren().add(mapView); final Location[][] mapCoor = m.map; final ImageView cursor = new ImageView(new Image("fantasytactics/images/bcursor.png", 66, 98, false, false)); cursorLoc = new Location(m.xLimit / 2, m.yLimit / 2); cursor.setX(mapCoor[cursorLoc.y][cursorLoc.x].x); cursor.setY(mapCoor[cursorLoc.y][cursorLoc.x].y); root.getChildren().add(cursor); for (Member i : m.enemy.members) { int index = m.enemy.members.indexOf(i); enemy.group.add(new BattleMem(1, i, m.enmapCoor[index], m.enCoor[index])); } for (Member i : curClan.members) { int index = curClan.members.indexOf(i); player.group.add(new BattleMem(0, i, m.playmapCoor[index], m.playCoor[index])); } final TurnOrder ord = new TurnOrder(); ord.create(enemy.group, player.group); for (BattleMem i : enemy.group) { root.getChildren().add(i.anm.view); } for (BattleMem i : player.group) { root.getChildren().add(i.anm.view); } scene = new Scene(root, m.width, m.height); final Button mve = new Button("Move"); final Button atk = new Button("Attack"); final Button wait = new Button("Wait"); mve.setLayoutX(m.width - 100); mve.setLayoutY(m.height - 200); atk.setLayoutX(m.width - 100); atk.setLayoutY(m.height - 150); wait.setLayoutX(m.width - 100); wait.setLayoutY(m.height - 100); mve.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { menu = false; root.getChildren().remove(mve); root.getChildren().remove(atk); root.getChildren().remove(wait); tiles = new ArrayList<ImageView>(); range = displayRange(tiles, curMove, mapCoor, ord.order); root.getChildren().addAll(1, tiles); scene.setOnKeyPressed( new EventHandler<KeyEvent>() { public void handle(KeyEvent e) { if (e.getCode() == KeyCode.UP) { if (cursorLoc.y >= 0) { if (range.contains(mapCoor[cursorLoc.y - 1][cursorLoc.x])) { cursorLoc.y--; } } } if (e.getCode() == KeyCode.DOWN) { if (cursorLoc.y <= m.yLimit) { if (range.contains(mapCoor[cursorLoc.y + 1][cursorLoc.x])) { cursorLoc.y++; } } } if (e.getCode() == KeyCode.LEFT) { if (cursorLoc.x >= 0) { if (range.contains(mapCoor[cursorLoc.y][cursorLoc.x - 1])) { cursorLoc.x--; } } } if (e.getCode() == KeyCode.RIGHT) { if (cursorLoc.x <= m.xLimit) { if (range.contains(mapCoor[cursorLoc.y][cursorLoc.x + 1])) { cursorLoc.x++; } } } if (e.getCode() == KeyCode.ENTER) { curMove.pixLoc = mapCoor[cursorLoc.y][cursorLoc.x]; curMove.mapLoc = new Location(cursorLoc.x, cursorLoc.y); curMove.updatePosition(); menu = true; mve.setDisable(true); root.getChildren().removeAll(tiles); root.getChildren().add(atk); root.getChildren().add(wait); } cursor.setX(mapCoor[cursorLoc.y][cursorLoc.x].x); cursor.setY(mapCoor[cursorLoc.y][cursorLoc.x].y); } }); e.consume(); } }); atk.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { root.getChildren().remove(mve); root.getChildren().remove(atk); root.getChildren().remove(wait); avail = displayAttackable(curMove, enemy); tiles = new ArrayList<ImageView>(); Image t = new Image("fantasytactics/images/tile.png", 66, 98, false, false); if (!avail.isEmpty()) { for (BattleMem i : avail) { ImageView tile = new ImageView(t); tile.setX(i.pixLoc.x); tile.setY(i.pixLoc.y); tiles.add(tile); } root.getChildren().addAll(1, tiles); cursorLoc.x = avail.get(0).mapLoc.x; cursorLoc.y = avail.get(0).mapLoc.y; cursor.setX(mapCoor[cursorLoc.y][cursorLoc.x].x); cursor.setY(mapCoor[cursorLoc.y][cursorLoc.x].y); curSelection = 0; confirm = false; scene.setOnKeyPressed( new EventHandler<KeyEvent>() { public void handle(KeyEvent e) { if (e.getCode() == KeyCode.UP) { if (curSelection != avail.size() - 1) { curSelection++; } else { curSelection = 0; } } if (e.getCode() == KeyCode.DOWN) { if (curSelection != 0) { curSelection--; } } if (e.getCode() == KeyCode.ENTER) { if (confirm == false) { BattleMem en = avail.get(curSelection); root.getChildren().remove(name); root.getChildren().remove(hp); root.getChildren().remove(mp); name = new Text(en.member.getName()); hp = new Text("HP: " + en.curHP + "/" + en.member.getmaxHp()); mp = new Text("MP: " + en.curMP + "/" + en.member.getmaxMp()); name.setFont(Font.font("Impact", 22)); hp.setFont(Font.font("Impact", 22)); mp.setFont(Font.font("Impact", 22)); name.setFill(Color.BLACK); hp.setFill(Color.BLACK); mp.setFill(Color.BLACK); name.setX(0); hp.setX(0); mp.setX(0); name.setY(m.height - 150); hp.setY(m.height - 100); mp.setY(m.height - 50); root.getChildren().add(name); root.getChildren().add(hp); root.getChildren().add(mp); dmg = new Text(); int def = en.member.getDef(); int aat = curMove.member.getAtk(); int damg = (aat - (def / 2)) / 2; double prob = 1 - ((double) en.member.getEvade() / 100); dmg.setText( "Damage: " + damg + " Chance to Hit: " + (prob * 100) + "%"); dmg.setFont(Font.font("Impact", 25)); dmg.setFill(Color.BLACK); dmg.setX(m.width - 400); dmg.setY(m.height - 100); DropShadow ds = new DropShadow(); ds.setOffsetY(3.0f); ds.setColor(Color.color(0.4f, 0.4f, 0.4f)); dmg.setEffect(ds); root.getChildren().add(dmg); dmg.toFront(); confirm = true; } else { root.getChildren().removeAll(tiles); root.getChildren().remove(dmg); curMove.executeAttack(avail.get(curSelection)); try { Thread.sleep(400); } catch (InterruptedException ex) { Logger.getLogger(FantasyTactics.class.getName()) .log(Level.SEVERE, null, ex); } if (avail.get(curSelection).curHP <= 0) { root.getChildren().remove(avail.get(curSelection).anm.view); ord.order.remove(avail.get(curSelection)); enemy.group.remove(avail.get(curSelection)); } attack = true; turnEnd = true; } } cursorLoc.x = avail.get(curSelection).mapLoc.x; cursorLoc.y = avail.get(curSelection).mapLoc.y; cursor.setX(mapCoor[cursorLoc.y][cursorLoc.x].x); cursor.setY(mapCoor[cursorLoc.y][cursorLoc.x].y); } }); } else { turnEnd = true; } } }); wait.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { turnEnd = true; root.getChildren().remove(tiles); } }); stage.setScene(scene); stage.show(); curIndex = ord.order.size() - 1; turnEnd = true; timeline = new Timeline( new KeyFrame( Duration.millis(1000), new EventHandler() { public void handle(Event e) { if (!missionWon && !missionLose) { if (turnEnd) { if (enemy.group.size() == 0) { missionWon = true; } else if (player.group.size() == 0) { missionLose = true; } for (BattleMem i : ord.order) { if (i.curHP <= 0) { root.getChildren().remove(i.anm.view); ord.order.remove(i); enemy.group.remove(i); play.group.remove(i); curIndex = 0; } } if (curIndex == ord.order.size() - 1) { curIndex = 0; } else { curIndex++; } root.getChildren().remove(mve); root.getChildren().remove(atk); root.getChildren().remove(wait); curMove = ord.order.get(curIndex); cursorLoc.x = curMove.mapLoc.x; cursorLoc.y = curMove.mapLoc.y; cursor.setX(mapCoor[cursorLoc.y][cursorLoc.x].x); cursor.setY(mapCoor[cursorLoc.y][cursorLoc.x].y); if (enemy.group.contains(curMove)) { executeTurn(player, curMove, enemy); try { Thread.sleep(400); } catch (InterruptedException ex) { Logger.getLogger(FantasyTactics.class.getName()) .log(Level.SEVERE, null, ex); } turnEnd = true; } else { turnEnd = false; root.getChildren().add(mve); root.getChildren().add(atk); root.getChildren().add(wait); mve.setDisable(false); move = false; attack = false; if (curMove.curMP >= curMove.member.getmaxMp() - 10) { curMove.curMP = curMove.member.getmaxMp(); } else { curMove.curMP += 10; } root.getChildren().remove(name); root.getChildren().remove(hp); root.getChildren().remove(mp); name = new Text(curMove.member.getName()); hp = new Text("HP: " + curMove.curHP + "/" + curMove.member.getmaxHp()); mp = new Text("MP: " + curMove.curMP + "/" + curMove.member.getmaxMp()); name.setFont(Font.font("Impact", 22)); hp.setFont(Font.font("Impact", 22)); mp.setFont(Font.font("Impact", 22)); name.setFill(Color.BLACK); hp.setFill(Color.BLACK); mp.setFill(Color.BLACK); name.setX(0); hp.setX(0); mp.setX(0); name.setY(m.height - 150); hp.setY(m.height - 100); mp.setY(m.height - 50); root.getChildren().add(name); root.getChildren().add(hp); root.getChildren().add(mp); } } else { if (move && attack) { turnEnd = true; } } } else { if (missionWon) { win(); } else if (missionLose) { lose(); } } for (int i = m.xLimit; i >= 0; i--) { for (BattleMem j : ord.order) { if (j.mapLoc.x == i) { j.toFront(); } } } } })); timeline.setCycleCount(Timeline.INDEFINITE); timeline.play(); }
public static void updateAge(int age) { double rate = xrate; if (yrate < xrate) rate = yrate; if (age == 1) { Image stageI = ResManager.getImage("ph1.png"); stageLabel = new ImageView(); stageLabel.setImage(stageI); stageLabel.setScaleX(rate); stageLabel.setScaleY(rate); stageLabel.setTranslateX((stageI.getWidth() * xrate - 134) / 2.0 + 15); stageLabel.setTranslateY((stageI.getHeight() * yrate - 128) / 2.0); stageLabel.toBack(); background.toBack(); mbg.root.getChildren().add(stageLabel); stageLabel.setX(0); stageLabel.setY(0); Timeline tl = new Timeline( new KeyFrame( Duration.seconds(0), new KeyValue(stageLabel.opacityProperty(), 0), new KeyValue(stageLabel.scaleXProperty(), 0)), new KeyFrame( Duration.seconds(1), new KeyValue(stageLabel.opacityProperty(), 1), new KeyValue(stageLabel.scaleXProperty(), rate, Interpolator.EASE_OUT))); tl.play(); } else if (age == 2) { GUIManager.bgMusic.stop(); GUIManager.bgMusic = ResManager.getAudio("age2.mp3"); GUIManager.bgMusic.setCycleCount(AudioClip.INDEFINITE); GUIManager.bgMusic.setVolume(GUIManager.volumn); GUIManager.bgMusic.play(); final Image stageII = ResManager.getImage("ph2.png"); EventHandler<ActionEvent> act = new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { stageLabel.setImage(stageII); } }; Timeline tl = new Timeline( new KeyFrame( Duration.seconds(1), new KeyValue(stageLabel.opacityProperty(), 0), new KeyValue(stageLabel.scaleXProperty(), 0, Interpolator.EASE_IN)), new KeyFrame(Duration.seconds(1), act), new KeyFrame( Duration.seconds(2), new KeyValue(stageLabel.opacityProperty(), 1), new KeyValue(stageLabel.scaleXProperty(), rate, Interpolator.EASE_OUT))); tl.play(); } else if (age == 3) { GUIManager.bgMusic.stop(); GUIManager.bgMusic = ResManager.getAudio("age3.mp3"); GUIManager.bgMusic.setCycleCount(AudioClip.INDEFINITE); GUIManager.bgMusic.setVolume(GUIManager.volumn); GUIManager.bgMusic.play(); final Image stageIII = ResManager.getImage("ph3.png"); EventHandler<ActionEvent> act = new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { stageLabel.setImage(stageIII); } }; Timeline tl = new Timeline( new KeyFrame( Duration.seconds(1), new KeyValue(stageLabel.opacityProperty(), 0), new KeyValue(stageLabel.scaleXProperty(), 0, Interpolator.EASE_IN)), new KeyFrame(Duration.seconds(1), act), new KeyFrame( Duration.seconds(2), new KeyValue(stageLabel.opacityProperty(), 1), new KeyValue(stageLabel.scaleXProperty(), rate, Interpolator.EASE_OUT))); tl.play(); } }
public void setImage(double x, double y, LabelOptions labelOptions) { _elementView.setImage(_elementImages[labelOptions.ordinal()]); _elementView.setX(x); _elementView.setY(y); }
public void setXAndY(double x, double y) { _box._setXAndY(x, y); _elementView.setX(x); _elementView.setY(y); }
@Override public void start(Stage stage) { sun.setFitHeight(100); sun.setFitWidth(100); sun.setX(200); sun.setY(200); quas.setFitHeight(50); quas.setFitWidth(50); wex.setFitHeight(50); wex.setFitWidth(50); exort.setFitHeight(50); exort.setFitWidth(50); Circle orbit1 = new Circle(); orbit1.setRotate(-90); orbit1.setRadius(100); orbit1.setCenterX(250); orbit1.setCenterY(250); PathTransition path1 = new PathTransition(); path1.setPath(orbit1); path1.setNode(quas); path1.setDuration(Duration.seconds(5)); path1.setCycleCount(Timeline.INDEFINITE); Circle orbit2 = new Circle(); orbit2.setRotate(30); orbit2.setRadius(100); orbit2.setCenterX(250); orbit2.setCenterY(250); PathTransition path2 = new PathTransition(); path2.setPath(orbit2); path2.setNode(wex); path2.setDuration(Duration.seconds(5)); path2.setCycleCount(Timeline.INDEFINITE); Circle orbit3 = new Circle(); orbit3.setRotate(150); orbit3.setRadius(100); orbit3.setCenterX(250); orbit3.setCenterY(250); PathTransition path3 = new PathTransition(); path3.setPath(orbit3); path3.setNode(exort); path3.setDuration(Duration.seconds(5)); path3.setCycleCount(Timeline.INDEFINITE); ComboBox<String> invoke = new ComboBox<String>(); invoke.setEditable(false); invoke .getItems() .addAll( "Cold Snap", "Ghost Walk", "Tornado", "EMP", "Alacrity", "Chaos Meteor", "Sun Strike", "Forge Spirit", "Ice Wall", "Deafening Blast"); invoke.setOnAction( e -> { switch (invoke.getValue()) { case "Cold Snap": path1.setNode(quas); path2.setNode(quas); path3.setNode(quas); break; case "Ghost Walk": path1.setNode(quas); path2.setNode(quas); path3.setNode(wex); break; case "Tornado": path1.setNode(wex); path2.setNode(wex); path3.setNode(quas); break; case "EMP": path1.setNode(wex); path2.setNode(wex); path3.setNode(wex); break; case "Alacrity": path1.setNode(wex); path2.setNode(wex); path3.setNode(exort); break; case "Chaos Meteor": path1.setNode(exort); path2.setNode(exort); path3.setNode(wex); break; case "Sun Strike": path1.setNode(exort); path2.setNode(exort); path3.setNode(exort); break; case "Forge Spirit": path1.setNode(exort); path2.setNode(exort); path3.setNode(quas); break; case "Ice Wall": path1.setNode(quas); path2.setNode(quas); path3.setNode(exort); break; case "Deafening Blast": path1.setNode(quas); path2.setNode(wex); path3.setNode(exort); break; default: path1.setNode(quas); path2.setNode(wex); path3.setNode(exort); break; } }); path1.play(); path2.play(); path3.play(); Pane pane = new Pane(); pane.getChildren().addAll(quas, wex, exort, sun, invoke); stage.setScene(new Scene(pane, 500, 500)); stage.setTitle("Spell Combinations"); stage.show(); }