diff --git a/src/ihm/Dice.java b/src/ihm/Dice.java new file mode 100644 index 0000000..586c07a --- /dev/null +++ b/src/ihm/Dice.java @@ -0,0 +1,60 @@ +package ihm; + +/** + * @author https://www.programcreek.com/java-api-examples/?code=AlmasB%2FFXTutorials%2FFXTutorials-master%2Fsrc%2Fcom%2Falmasb%2Ftutorial5%2FDice.java + * + */ + +import javafx.animation.RotateTransition; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.geometry.Pos; +import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Text; +import javafx.util.Duration; + +public class Dice extends StackPane { + + public static int MAX_VALUE = 6; + public static final int MIN_VALUE = 1; + + public final SimpleIntegerProperty valueProperty = new SimpleIntegerProperty(); + + int i = 0; + + public Dice(int valeurMax) { + + MAX_VALUE = valeurMax; + Rectangle rect = new Rectangle(50, 50); + + Text text = new Text(); + text.setFill(Color.WHITE); + text.textProperty().bind(valueProperty.asString()); + + this.setAlignment(Pos.CENTER); + getChildren().addAll(rect, text); + + this.setOnMouseClicked(event -> roll()); + } + + public void roll() { + RotateTransition rt = new RotateTransition(Duration.seconds(0.5), this); + rt.setFromAngle(0); + rt.setToAngle(360); + int cycles = 2000; + + rt.setOnFinished(event -> { + + valueProperty.set((int)(Math.random() * (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE); + + if(cycles < i) { + + rt.play(); + i++; + } + + }); + rt.play(); + } +} \ No newline at end of file diff --git a/src/ihm/Main.java b/src/ihm/Main.java index f8fd0b7..c3cd587 100644 --- a/src/ihm/Main.java +++ b/src/ihm/Main.java @@ -23,6 +23,7 @@ public class Main extends Application { primaryStage.setTitle("Shadow Hunters"); primaryStage.setScene(new Scene(root)); primaryStage.centerOnScreen(); + primaryStage.setMaximized(true); primaryStage.show(); } diff --git a/src/ihm/PopUpBoolean.java b/src/ihm/PopUpBoolean.java index 9d98bc3..6bc8ed7 100644 --- a/src/ihm/PopUpBoolean.java +++ b/src/ihm/PopUpBoolean.java @@ -21,10 +21,6 @@ public class PopUpBoolean { private double xOffSet = 0; private double yOffSet = 0; - - - - public PopUpBoolean (Parent p, String titre) { @@ -62,8 +58,6 @@ public class PopUpBoolean { }); } - - public boolean display() { popup.setScene(scene); diff --git a/src/ihm/SpriteAnimation.java b/src/ihm/SpriteAnimation.java index b9d58af..9733d20 100644 --- a/src/ihm/SpriteAnimation.java +++ b/src/ihm/SpriteAnimation.java @@ -45,3 +45,4 @@ public class SpriteAnimation extends Transition { } } } + diff --git a/src/ihm/controller/ChoisirBoolean.java b/src/ihm/controller/ChoisirBoolean.java index 57c3f45..483c5c2 100644 --- a/src/ihm/controller/ChoisirBoolean.java +++ b/src/ihm/controller/ChoisirBoolean.java @@ -23,14 +23,13 @@ public class ChoisirBoolean implements Initializable{ public void initialize(URL arg0, ResourceBundle arg1) { } + @FXML public void choixOui(MouseEvent mouseEvent) throws IOException{ PopUpBoolean.result = true; final Node source = (Node) mouseEvent.getSource(); final Stage stage = (Stage) source.getScene().getWindow(); stage.close(); - return; - } @FXML @@ -40,6 +39,5 @@ public class ChoisirBoolean implements Initializable{ final Node source = (Node) mouseEvent.getSource(); final Stage stage = (Stage) source.getScene().getWindow(); stage.close(); - return; } } diff --git a/src/ihm/controller/MenuJoueurController.java b/src/ihm/controller/MenuJoueurController.java new file mode 100644 index 0000000..ebb8263 --- /dev/null +++ b/src/ihm/controller/MenuJoueurController.java @@ -0,0 +1,37 @@ +package ihm.controller; + +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Parent; +import javafx.scene.control.SplitPane; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.AnchorPane; + +public class MenuJoueurController implements Initializable{ + + @Override + public void initialize(URL arg0, ResourceBundle arg1) { + //nomJoueur.setText(joueur.getNom()); + } + + @FXML + public void changeZoneToScrollPaneJoueur(MouseEvent me) throws IOException { + + AnchorPane bp = FXMLLoader.load(getClass().getResource("../ressources/ScrollPaneJoueur.fxml")); + ImageView iv = ((ImageView)me.getSource()); + Parent p = iv.getParent().getParent(); + AnchorPane ap = (AnchorPane)p; + ap.getChildren().setAll(bp); + AnchorPane.setTopAnchor(bp, 0.0); + AnchorPane.setBottomAnchor(bp, 0.0); + AnchorPane.setLeftAnchor(bp, 0.0); + AnchorPane.setRightAnchor(bp, 0.0); + } + +} diff --git a/src/ihm/controller/PlateauController.java b/src/ihm/controller/PlateauController.java index 99ef137..acc9836 100644 --- a/src/ihm/controller/PlateauController.java +++ b/src/ihm/controller/PlateauController.java @@ -11,15 +11,23 @@ import java.util.ResourceBundle; import ihm.PopUp; import ihm.PopUpBoolean; +import ihm.SpriteAnimation; +import javafx.animation.Animation; +import javafx.event.Event; +import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; +import javafx.geometry.Rectangle2D; +import javafx.scene.Group; import javafx.scene.Parent; import javafx.scene.control.Button; import javafx.scene.control.Label; +import javafx.scene.image.ImageView; +import javafx.scene.layout.AnchorPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; -import main.GestionnaireJeu; +import javafx.util.Duration; import main.Joueur; import main.View; @@ -39,6 +47,10 @@ public class PlateauController implements Initializable { @FXML private VBox joueur7; @FXML private VBox joueur8; + public static int DICE_SIX = 2; + public static int DICE_QUATRE = 1; + public static int DICE_BOTH = 0; + /** * initialise les donn�es du plateau */ @@ -105,9 +117,7 @@ public class PlateauController implements Initializable { Parent root = loader.load(); PopUpBoolean popup = new PopUpBoolean(root, "Consulter sa carte"); - return popup.display(); - - + return popup.display(); } /** @@ -141,4 +151,11 @@ public class PlateauController implements Initializable { } } } + + public void rollDice(Joueur joueur, int typeDice, int[] rolls) { + + + + } + } diff --git a/src/ihm/controller/PlateauControllerTest.java b/src/ihm/controller/PlateauControllerTest.java new file mode 100644 index 0000000..a551adc --- /dev/null +++ b/src/ihm/controller/PlateauControllerTest.java @@ -0,0 +1,182 @@ +package ihm.controller; + + +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; + +import ihm.PopUpBoolean; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Parent; +import javafx.scene.control.ScrollPane; +import javafx.scene.image.ImageView; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Pane; +import main.Joueur; + +public class PlateauControllerTest implements Initializable { + + + @FXML private BorderPane root; + + + + /** + * initialise les donn�es du plateau + */ + @Override + public void initialize(URL arg0, ResourceBundle arg1) { + //initialisation des attributs des joueurs + + for(int i = 0; i < 8; i++) { + + + AnchorPane ap = getAnchorPaneJoueur(i); + Pane p; + try { + p = FXMLLoader.load(getClass().getResource("../ressources/MenuJoueur.fxml")); + if(i > 1 && i < 3) { + rotateContent(p, 90); + } + setContentAnchorPane(ap, p); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + } + + public GridPane getGridPaneJoueur(int pos) { + + int position = pos%8 / 2; + + position++; + + AnchorPane apParent = (AnchorPane) root.getChildren().get(position); + + GridPane gp = (GridPane) apParent.getChildren().get(0); + + return (GridPane) gp.getChildren().get(pos%2); + } + + + public AnchorPane getAnchorPaneJoueur(int pos) { + + GridPane gp = getGridPaneJoueur(pos); + return (AnchorPane) gp.getChildren().get(0); + } + + public ImageView getImageViewJoueur(int pos) { + + GridPane gp = getGridPaneJoueur(pos); + return (ImageView) gp.getChildren().get(1); + } + + public ScrollPane getScrollPaneJoueur(int pos) { + + GridPane gp = getGridPaneJoueur(pos); + return (ScrollPane) gp.getChildren().get(2); + } + + + public void setContentAnchorPane(AnchorPane ap, Pane p) { + + ap.getChildren().setAll(p); + + AnchorPane.setTopAnchor(p, 0.0); + AnchorPane.setBottomAnchor(p, 0.0); + AnchorPane.setLeftAnchor(p, 0.0); + AnchorPane.setRightAnchor(p, 0.0); + + } + + public void rotateContent(Pane p, double rotation) { + p.setRotate(rotation); + } + + + + /* + int OFFSET_X = 0; + int OFFSET_Y = 0; + int WIDTH = 557; + int HEIGHT = 557; + int COUNT = 6; + int COLUMNS = 6; + + //anchorPane1.getChildren().setAll(imageView); + + + ImageView imageView; + try { + imageView = FXMLLoader.load(getClass().getResource("../ressources/Dés.fxml")); + imageView.setViewport(new Rectangle2D(OFFSET_X, OFFSET_Y, WIDTH, HEIGHT)); + + imageView.fitWidthProperty().bind(anchorPane1.widthProperty()); + final SpriteAnimation animation = new SpriteAnimation( + imageView, + Duration.millis(250), + COUNT, COLUMNS, + OFFSET_X, OFFSET_Y, + WIDTH, HEIGHT + ); + animation.setCycleCount(Animation.INDEFINITE); + animation.play(); + anchorPane1.getChildren().addAll(new Group(imageView)); + anchorPane1.setOnMousePressed(new EventHandler( + + ) { + + @Override + public void handle(Event arg0) { + animation.stop(); + + } + }); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +*/ + + + + + + + /** + * Affiche aux yeux de tous la carte personnage du joueur + * + * @param j : Le joueur sur lequel on a cliqu� + */ + + + public boolean choisir(Joueur j) throws IOException { + + FXMLLoader loader = new FXMLLoader(getClass().getResource("../ressources/choisirBoolean.fxml")); + Parent root = loader.load(); + + PopUpBoolean popup = new PopUpBoolean(root, "Consulter sa carte"); + return popup.display(); + + + } + + public void rollDice(Joueur j, int typeDice, int[] resultats) { + + } + + /** + * Permet de consulter sa carte perssonage en cas d'oublie + * + * @param j : Le joueur sur lequel on a cliqu� + */ + + +} diff --git a/src/ihm/controller/PlayersController.java b/src/ihm/controller/PlayersController.java index 4a737b8..dcab38b 100644 --- a/src/ihm/controller/PlayersController.java +++ b/src/ihm/controller/PlayersController.java @@ -16,8 +16,6 @@ import javafx.fxml.Initializable; import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.TextField; diff --git a/src/ihm/controller/ScrollPaneJoueurController.java b/src/ihm/controller/ScrollPaneJoueurController.java new file mode 100644 index 0000000..51dec9c --- /dev/null +++ b/src/ihm/controller/ScrollPaneJoueurController.java @@ -0,0 +1,44 @@ +package ihm.controller; + +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Parent; +import javafx.scene.control.SplitPane; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Pane; + +public class ScrollPaneJoueurController implements Initializable{ + + + + @Override + public void initialize(URL arg0, ResourceBundle arg1) { + + } + + @FXML + public void changeZoneJoueurToMenuJoueur(MouseEvent me) throws IOException { + + BorderPane bp = FXMLLoader.load(getClass().getResource("../ressources/MenuJoueur.fxml")); + ImageView iv = ((ImageView)me.getSource()); + Parent p = iv.getParent().getParent().getParent().getParent(); + AnchorPane ap = (AnchorPane)p; + + System.out.println(bp.getRotate()+" "+ ap.getRotate()); + ap.getChildren().setAll(bp); + + AnchorPane.setTopAnchor(bp, 0.0); + AnchorPane.setBottomAnchor(bp, 0.0); + AnchorPane.setLeftAnchor(bp, 0.0); + AnchorPane.setRightAnchor(bp, 0.0); + + } +} diff --git a/src/ihm/ressources/Dialog.fxml b/src/ihm/ressources/Dialog.fxml new file mode 100644 index 0000000..38e8622 --- /dev/null +++ b/src/ihm/ressources/Dialog.fxml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ihm/ressources/Dés.fxml b/src/ihm/ressources/Dés.fxml new file mode 100644 index 0000000..3c2699a --- /dev/null +++ b/src/ihm/ressources/Dés.fxml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/ihm/ressources/MenuJoueur.fxml b/src/ihm/ressources/MenuJoueur.fxml new file mode 100644 index 0000000..badbf9c --- /dev/null +++ b/src/ihm/ressources/MenuJoueur.fxml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/ihm/ressources/PlateauTestPaul.fxml b/src/ihm/ressources/PlateauTestPaul.fxml new file mode 100644 index 0000000..1616744 --- /dev/null +++ b/src/ihm/ressources/PlateauTestPaul.fxml @@ -0,0 +1,585 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/src/ihm/ressources/ScrollPaneJoueur.fxml b/src/ihm/ressources/ScrollPaneJoueur.fxml new file mode 100644 index 0000000..80c9874 --- /dev/null +++ b/src/ihm/ressources/ScrollPaneJoueur.fxml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ihm/ressources/ZoneJoueur.fxml b/src/ihm/ressources/ZoneJoueur.fxml new file mode 100644 index 0000000..2259923 --- /dev/null +++ b/src/ihm/ressources/ZoneJoueur.fxml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/ihm/ressources/choisirBoolean.fxml b/src/ihm/ressources/choisirBoolean.fxml index 28c2a49..fa0213f 100644 --- a/src/ihm/ressources/choisirBoolean.fxml +++ b/src/ihm/ressources/choisirBoolean.fxml @@ -2,22 +2,23 @@ - + - + + -