Amélioration plateau
This commit is contained in:
39
src/ihm/controller/GestionnaireDePions.java
Normal file
39
src/ihm/controller/GestionnaireDePions.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package ihm.controller;
|
||||
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class GestionnaireDePions {
|
||||
|
||||
private Pion pionVie;
|
||||
private Pion pionLieu;
|
||||
|
||||
private GridPane gridPaneVie;
|
||||
|
||||
public GestionnaireDePions(Color color,GridPane gridPaneVie) {
|
||||
|
||||
this.gridPaneVie = gridPaneVie;
|
||||
this.pionVie = new Pion(color);
|
||||
this.pionLieu = new Pion(color);
|
||||
}
|
||||
|
||||
public void deplacerPionVie(int damage) {
|
||||
GridPane gp = this.gridPaneVie;
|
||||
System.out.println(gp);
|
||||
int row = pionVie.getPosition().x;
|
||||
|
||||
StackPane nAncient = (StackPane) gp.getChildren().get(row);
|
||||
FlowPane fpAncient = (FlowPane) nAncient.getChildren().get(0);
|
||||
fpAncient.getChildren().remove(pionVie);
|
||||
|
||||
StackPane nNew = (StackPane) gp.getChildren().get(damage);
|
||||
FlowPane fpNew = (FlowPane) nNew.getChildren().get(0);
|
||||
fpNew.getChildren().add(pionVie);
|
||||
}
|
||||
|
||||
public void deplacerPionLieux() {
|
||||
|
||||
}
|
||||
}
|
@@ -4,7 +4,14 @@ import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Border;
|
||||
import javafx.scene.layout.BorderStroke;
|
||||
import javafx.scene.layout.BorderStrokeStyle;
|
||||
import javafx.scene.layout.BorderWidths;
|
||||
import javafx.scene.layout.CornerRadii;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import main.Joueur;
|
||||
|
||||
public class JoueurIHM {
|
||||
@@ -12,16 +19,39 @@ public class JoueurIHM {
|
||||
private int position;
|
||||
private Joueur joueur;
|
||||
private Pane pane;
|
||||
private GestionnaireDePions gestionnaireDePions;
|
||||
private Color color;
|
||||
|
||||
public JoueurIHM(int i, Joueur joueur, Pane pane) {
|
||||
public JoueurIHM(int i, Joueur joueur, Pane pane, Color color, GridPane gridPaneVie) {
|
||||
|
||||
this.setPosition(i);
|
||||
this.setJoueur(joueur);
|
||||
this.pane = pane;
|
||||
this.color = color;
|
||||
this.gestionnaireDePions = new GestionnaireDePions(this.color,gridPaneVie);
|
||||
|
||||
pane.setBorder(new Border(new BorderStroke(color, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(5))));
|
||||
|
||||
String name = joueur.getNom();
|
||||
setLabelJoueur(name);
|
||||
initRevealButton();
|
||||
}
|
||||
|
||||
private void initRevealButton() {
|
||||
Button btn = getRevealButton();
|
||||
btn.setOnAction(x -> {
|
||||
|
||||
this.joueur.reveal();
|
||||
ImageView iv = this.getCartePersonnage();
|
||||
// TODO
|
||||
//this.joueur.getCartePersonnage().getId();
|
||||
//iv.setImage(arg0);
|
||||
System.out.println(joueur.getRevele());
|
||||
btn.setDisable(true);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public Button getRevealButton() {
|
||||
Pane p = (Pane) pane.getChildren().get(1);
|
||||
return (Button) p.getChildren().get(1);
|
||||
@@ -66,5 +96,9 @@ public class JoueurIHM {
|
||||
public void setJoueur(Joueur joueur) {
|
||||
this.joueur = joueur;
|
||||
}
|
||||
|
||||
public void deplacerPionVie(int damage) {
|
||||
this.gestionnaireDePions.deplacerPionVie(damage);
|
||||
}
|
||||
|
||||
}
|
||||
|
31
src/ihm/controller/Pion.java
Normal file
31
src/ihm/controller/Pion.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package ihm.controller;
|
||||
|
||||
import java.awt.Point;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Circle;
|
||||
|
||||
public class Pion extends Circle{
|
||||
|
||||
private static final double RADIUS = 8.0;
|
||||
private static final double RED= 0.0;
|
||||
private Point position;
|
||||
|
||||
public Pion(Color color) {
|
||||
|
||||
this.position = new Point(0,0);
|
||||
this.setRadius(RADIUS);
|
||||
this.setFill(color);
|
||||
this.setStroke(new Color(0,0,0,1));
|
||||
this.setStrokeWidth(1);
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y) {
|
||||
this.position = new Point(x,y);
|
||||
}
|
||||
|
||||
public Point getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
}
|
@@ -4,11 +4,11 @@ package ihm.controller;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
|
||||
import ihm.PopUp;
|
||||
import ihm.PopUpBoolean;
|
||||
@@ -16,48 +16,25 @@ import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
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.BorderPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
import main.GestionnaireJeu;
|
||||
import javafx.scene.shape.Circle;
|
||||
import main.Joueur;
|
||||
|
||||
public class PlateauController implements Initializable {
|
||||
|
||||
private List<Joueur> listJoueur = new ArrayList<Joueur>();
|
||||
private Map<Joueur,Pane> joueursPane;
|
||||
|
||||
@FXML private AnchorPane rootPane;
|
||||
@FXML private HBox joueur1;
|
||||
@FXML private HBox joueur2;
|
||||
@FXML private HBox joueur3;
|
||||
@FXML private HBox joueur4;
|
||||
@FXML private VBox joueur5;
|
||||
@FXML private VBox joueur6;
|
||||
@FXML private VBox joueur7;
|
||||
@FXML private VBox joueur8;
|
||||
|
||||
private List<VBox> vboxJoueur = new ArrayList<VBox>();
|
||||
private List<HBox> hboxJoueur = new ArrayList<HBox>();
|
||||
private List<Button> btnRevelation = new ArrayList<Button>();
|
||||
private List<ImageView> cartePerso = new ArrayList<ImageView>();
|
||||
private List<Label> nomJoueur = new ArrayList<Label>();
|
||||
private List<AnchorPane> tour = new ArrayList<AnchorPane>();
|
||||
|
||||
|
||||
private List<JoueurIHM> joueursIHM;
|
||||
|
||||
@FXML private HBox lieux;
|
||||
@FXML private HBox vie;
|
||||
|
||||
private List<Circle> pionLieux = new ArrayList<Circle>();
|
||||
private List<Circle> pionVie = new ArrayList<Circle>();
|
||||
|
||||
@FXML private AnchorPane rootPane;
|
||||
@FXML private GridPane gridPaneVie;
|
||||
//@FXML static public GridPane gridPaneLieux;
|
||||
|
||||
|
||||
public static int DICE_SIX = 2;
|
||||
public static int DICE_QUATRE = 1;
|
||||
public static int DICE_BOTH = 0;
|
||||
@@ -70,20 +47,34 @@ public class PlateauController implements Initializable {
|
||||
//System.out.println("Création du plateau ...");
|
||||
|
||||
this.joueursIHM = new ArrayList<JoueurIHM>();
|
||||
|
||||
System.out.println(gridPaneVie);
|
||||
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
|
||||
Map<Integer, Joueur> map = gj.getMapJoueurs();
|
||||
|
||||
|
||||
for(int i = 0 ; i < gridPaneVie.getChildren().size();i++) {
|
||||
|
||||
Pane p = (Pane) gridPaneVie.getChildren().get(i);
|
||||
Label l = (Label) p.getChildren().get(1);
|
||||
l.setText(i+"");
|
||||
}
|
||||
|
||||
System.out.println(map.keySet());
|
||||
for(int i : map.keySet()) {
|
||||
|
||||
joueursIHM.add(new JoueurIHM(i,map.get(i),getPaneJoueur(i)));
|
||||
joueursIHM.add(new JoueurIHM(i,map.get(i),getPaneJoueur(i),new Color(Math.random(), Math.random(), Math.random(),1),gridPaneVie));
|
||||
}
|
||||
|
||||
for(int i = 0; i<joueursIHM.size(); i++) {
|
||||
joueursIHM.get(i).deplacerPionVie((int) (Math.random()*13));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// BUTTONS ETC
|
||||
//System.out.println(this.joueursPane);
|
||||
|
||||
|
||||
/*
|
||||
this.hboxJoueur.add(joueur1);
|
||||
this.hboxJoueur.add(joueur2);
|
||||
this.hboxJoueur.add(joueur3);
|
||||
@@ -126,9 +117,9 @@ public class PlateauController implements Initializable {
|
||||
int compteur = j;
|
||||
b.setOnMouseClicked(e -> {try {consulterSaCarte(compteur);} catch (IOException e1) {e1.printStackTrace();}});
|
||||
j++;
|
||||
}
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
/*
|
||||
//initialisation des pions
|
||||
VBox pionLieux14 = (VBox) lieux.getChildren().get(0);
|
||||
VBox pionLieux58 = (VBox) lieux.getChildren().get(4);
|
||||
@@ -160,21 +151,43 @@ public class PlateauController implements Initializable {
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
private Pane getPaneJoueur(int i) {
|
||||
Pane parent = getPaneCoupleJoueurs(i);
|
||||
int position = i%2;
|
||||
return (Pane) parent.getChildren().get(position);
|
||||
}
|
||||
|
||||
private Pane getPaneCoupleJoueurs(int i) {
|
||||
int position = (i%8)/2;
|
||||
Pane parent = (Pane) rootPane.getChildren().get(0);
|
||||
return (Pane) parent.getChildren().get(position+1);
|
||||
|
||||
int position = i%4;
|
||||
BorderPane bp = (BorderPane) rootPane.getChildren().get(0);
|
||||
Pane pane;
|
||||
|
||||
// Ordre des panes
|
||||
// bp -> milieu, droite, gauche
|
||||
// mid -> milieu, bas, haut
|
||||
if(position < 2) {
|
||||
BorderPane mid = (BorderPane) bp.getChildren().get(0);
|
||||
|
||||
if(i < 2) {
|
||||
// Bas
|
||||
pane = (Pane)mid.getChildren().get(1);
|
||||
}else {
|
||||
// Haut
|
||||
pane = (Pane)mid.getChildren().get(2);
|
||||
}
|
||||
|
||||
}else {
|
||||
|
||||
if(i < 4) {
|
||||
// Droite
|
||||
pane = (Pane) bp.getChildren().get(1);
|
||||
}else {
|
||||
// Gauche
|
||||
pane = (Pane) bp.getChildren().get(2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (Pane) pane.getChildren().get(i%2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,22 +243,15 @@ public class PlateauController implements Initializable {
|
||||
*
|
||||
* @param j : map donnant le joueur et son numero
|
||||
*/
|
||||
public void showInformation(Map<Integer, Joueur> j) {
|
||||
System.out.println("\tPlacement des joueurs");
|
||||
int taille = this.vboxJoueur.size() + this.hboxJoueur.size();
|
||||
public void placerJoueurs(Map<Integer, Joueur> j) {
|
||||
Set<Integer> set = j.keySet();
|
||||
|
||||
for (int i=0; i<taille; i++) {
|
||||
if (j.get(i) != null)
|
||||
nomJoueur.get(i).setText(j.get(i).getNom());
|
||||
else {
|
||||
if (i < 4) {
|
||||
hboxJoueur.get(i).setVisible(false);
|
||||
}else {
|
||||
vboxJoueur.get(i-4).setVisible(false);
|
||||
}
|
||||
|
||||
for(int i = 0; i < 8; i++) {
|
||||
if(!set.contains(i)) {
|
||||
getPaneJoueur(i).getChildren().removeAll(getPaneJoueur(i).getChildren());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void rollDice(Joueur joueur, int typeDice, int[] rolls) {
|
||||
|
@@ -21,6 +21,7 @@ import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.stage.Stage;
|
||||
import main.Configuration;
|
||||
@@ -31,7 +32,7 @@ public class PlayersController implements Initializable{
|
||||
|
||||
@FXML private AnchorPane rootPane;
|
||||
@FXML private Button btnCommencer;
|
||||
|
||||
|
||||
@FXML private HBox hb1;
|
||||
@FXML private HBox hb2;
|
||||
@FXML private HBox hb3;
|
||||
@@ -66,6 +67,7 @@ public class PlayersController implements Initializable{
|
||||
ligne.add(hb7);
|
||||
ligne.add(hb8);
|
||||
for (HBox hb : ligne) {
|
||||
System.out.println(hb);
|
||||
txt.add((TextField) hb.getChildren().get(0));
|
||||
plus.add((Button) hb.getChildren().get(1));
|
||||
ia.add((CheckBox) hb.getChildren().get(2));
|
||||
@@ -74,7 +76,8 @@ public class PlayersController implements Initializable{
|
||||
int i=0;
|
||||
for (Button btn : plus) {
|
||||
int compteur = i;
|
||||
btn.setOnAction(e -> {ajoutJoueur(compteur);});
|
||||
btn.setOnAction(e -> {
|
||||
ajoutJoueur(compteur);});
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -115,10 +118,11 @@ public class PlayersController implements Initializable{
|
||||
// Creer une configuration
|
||||
//View.applyConfiguration(new Configuration(joueurs, nbJoueursV, nbJoueursH));
|
||||
|
||||
System.out.println(this.joueurs);
|
||||
GestionnaireJeu gj = GestionnaireJeu.getGestionnaireJeu();
|
||||
gj.setConfiguration(new Configuration(this.joueurs));
|
||||
|
||||
final URL fxmlURL = getClass().getResource("../ressources/Plateau.fxml");
|
||||
final URL fxmlURL = getClass().getResource("../ressources/PlateauTest.fxml");
|
||||
final ResourceBundle bundle = ResourceBundle.getBundle("domaine.properties.langue", Locale.FRENCH);
|
||||
final FXMLLoader fxmlLoader = new FXMLLoader(fxmlURL, bundle);
|
||||
Parent root = fxmlLoader.load();
|
||||
@@ -129,7 +133,7 @@ public class PlayersController implements Initializable{
|
||||
Map<Integer, Joueur> map = gj.getMapJoueurs();
|
||||
|
||||
|
||||
pc.showInformation(map);
|
||||
pc.placerJoueurs(map);
|
||||
Scene scene = new Scene(root);
|
||||
Stage appStage = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow();
|
||||
appStage.setScene(scene);
|
||||
|
Reference in New Issue
Block a user