1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
public ConqueteMain(int x,int y,int taux) {
X = x;
Y=y;
TAUX=taux;
initData(x, y, taux);
initLayout(x,y,taux);
EvenementsPartie.debutPartie(etatDePartie);
}
private void initData(int x,int y,int taux) {
JoueurHumain joueurHumain1 = new JoueurHumain("j1");
JoueurHumain joueurHumain2 = new JoueurHumain("j2");
joueurHumain1.setNumeroJoueur(1);
joueurHumain2.setNumeroJoueur(2);
joueurs.add(joueurHumain1);
joueurs.add(joueurHumain2);
etatDePartie = new EtatDePartie(joueurs.size(), joueurs);
GenerateurCarte generateurCarte = new GenerateurCarte();
try {
grilleJeu = generateurCarte.genererCarte(x, y, taux, joueurs);
} catch (WaterWoldExeption e) {
e.printStackTrace();
}
}
private void initLayout(int x,int y, int taux) {
CreationGrille grille = new CreationGrille(grilleJeu, joueurs,etatDePartie);
this.setLayout(new BorderLayout());
this.add(grille);
grille.addImageClicker(new CliqueGrille());
}
private class CliqueGrille extends CreationGrille.ImageClicker {
public void click(MouseEvent arg0, CaseTerrain caseTerrain) {
CoordonneesTerrain coordonneesTerrain;
TerrainJeu terrain = caseTerrain.getTerrain();
switch (terrain.getTypeTerrain()) {
case MER:
System.out.println("mer"); // un vieil affichage pour l
// instant
break;
case PLAINE:
if (arg0.getButton() == MouseEvent.BUTTON1) {
clicDroit = false;
ChoixAction choixAction = new ChoixAction(caseTerrain);
} else {
clicDroit =clickDroit(clicDroit, caseTerrain);
}
break;
default:
break;
}
}
} |
Partager