PlateauTest2 déplacement des pions
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
package ihm.controller;
|
||||
|
||||
import carte.CarteLieu;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
import main.Joueur;
|
||||
|
||||
public class GestionnaireDePions {
|
||||
|
||||
@ -11,10 +14,12 @@ public class GestionnaireDePions {
|
||||
private Pion pionLieu;
|
||||
|
||||
private GridPane gridPaneVie;
|
||||
private GridPane gridPaneLieux;
|
||||
|
||||
public GestionnaireDePions(Color color,GridPane gridPaneVie) {
|
||||
public GestionnaireDePions(Color color,GridPane gridPaneVie,GridPane gridPaneLieux) {
|
||||
|
||||
this.gridPaneVie = gridPaneVie;
|
||||
this.gridPaneLieux = gridPaneLieux;
|
||||
this.pionVie = new Pion(color);
|
||||
this.pionLieu = new Pion(color);
|
||||
}
|
||||
@ -33,7 +38,28 @@ public class GestionnaireDePions {
|
||||
fpNew.getChildren().add(pionVie);
|
||||
}
|
||||
|
||||
public void deplacerPionLieux() {
|
||||
public void deplacerPionLieux(Joueur j) {
|
||||
|
||||
CarteLieu cl = j.getCarteLieu();
|
||||
int indexCL = j.getPlateau().getLieux().indexOf(cl);
|
||||
HBox hbox;
|
||||
System.out.println("GridPaneLieux "+this.gridPaneLieux);
|
||||
if(indexCL < 2) {
|
||||
hbox = (HBox) this.gridPaneLieux.getChildren().get(0);
|
||||
|
||||
}else if(indexCL < 4) {
|
||||
hbox = (HBox) this.gridPaneLieux.getChildren().get(1);
|
||||
|
||||
}else {
|
||||
hbox = (HBox) this.gridPaneLieux.getChildren().get(2);
|
||||
|
||||
}
|
||||
|
||||
StackPane sp = (StackPane) hbox.getChildren().get(indexCL%2);
|
||||
FlowPane fp = (FlowPane) sp.getChildren().get(0);
|
||||
fp.getChildren().add(this.pionLieu);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ public class JoueurIHM {
|
||||
private GestionnaireDePions gestionnaireDePions;
|
||||
private Color color;
|
||||
|
||||
public JoueurIHM(int i, Joueur joueur, Pane zoneJoueur, Color color, GridPane gridPaneVie) {
|
||||
public JoueurIHM(int i, Joueur joueur, Pane zoneJoueur, Color color, GridPane gridPaneVie, GridPane gridPaneLieux) {
|
||||
|
||||
this.setPosition(i);
|
||||
this.setJoueur(joueur);
|
||||
this.zoneJoueur = zoneJoueur;
|
||||
this.color = color;
|
||||
this.gestionnaireDePions = new GestionnaireDePions(this.color,gridPaneVie);
|
||||
this.gestionnaireDePions = new GestionnaireDePions(this.color,gridPaneVie, gridPaneLieux);
|
||||
|
||||
zoneJoueur.setBorder(new Border(new BorderStroke(color, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(5))));
|
||||
|
||||
@ -115,6 +115,10 @@ public class JoueurIHM {
|
||||
public void deplacerPionVie(int damage) {
|
||||
this.gestionnaireDePions.deplacerPionVie(damage);
|
||||
}
|
||||
|
||||
public void replacerPionLieu() {
|
||||
this.gestionnaireDePions.deplacerPionLieux(this.joueur);
|
||||
}
|
||||
|
||||
public void choisir() {
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class PlateauController implements Initializable {
|
||||
|
||||
@FXML private AnchorPane rootPane;
|
||||
@FXML private GridPane gridPaneVie;
|
||||
//@FXML static public GridPane gridPaneLieux;
|
||||
@FXML public GridPane gridPaneLieux;
|
||||
|
||||
private ChoisirBoolean cb;
|
||||
|
||||
@ -62,7 +62,7 @@ public class PlateauController implements Initializable {
|
||||
|
||||
for(int i : map.keySet()) {
|
||||
System.out.println(i);
|
||||
joueursIHM.add(new JoueurIHM(i,map.get(i),getPaneJoueur(i),new Color(Math.random(), Math.random(), Math.random(),1),gridPaneVie));
|
||||
joueursIHM.add(new JoueurIHM(i,map.get(i),getPaneJoueur(i),new Color(Math.random(), Math.random(), Math.random(),1),gridPaneVie, gridPaneLieux));
|
||||
}
|
||||
|
||||
for(int i = 0; i<joueursIHM.size(); i++) {
|
||||
@ -281,4 +281,16 @@ public class PlateauController implements Initializable {
|
||||
jihm.getZoneJoueur().getChildren().setAll();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void deplacer(Joueur currentJoueur) {
|
||||
JoueurIHM jIHM = getJoueurIHM(currentJoueur);
|
||||
jIHM.replacerPionLieu();
|
||||
|
||||
}
|
||||
|
||||
public void updateVieJoueur(Joueur joueur, int damage) {
|
||||
/*JoueurIHM jIHM = getJoueurIHM(joueur);
|
||||
jIHM.deplacerPionVie(damage);*/
|
||||
|
||||
}
|
||||
}
|
@ -276,7 +276,7 @@
|
||||
<Circle fill="#64ff1f" radius="10.0" stroke="BLACK" strokeType="INSIDE" GridPane.rowIndex="3" />
|
||||
</children>
|
||||
</GridPane>
|
||||
<GridPane hgap="20.0" GridPane.columnIndex="1">
|
||||
<GridPane fx:id="gridPaneLieux" hgap="20.0" GridPane.columnIndex="1">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" />
|
||||
|
Reference in New Issue
Block a user