Voisins. Solved execution error.

This commit is contained in:
aminecmi 2015-01-31 11:33:35 +01:00
parent c20dc161eb
commit 673ea047b7
5 changed files with 58 additions and 19 deletions

View File

@ -18,13 +18,38 @@ public abstract class CaseAbstraite {
public CaseAbstraite(int vert, int hor) {
coord = new Coordonnees(vert, hor);
// peupler ici ?
voisins = new HashMap<PointsCardinaux, CaseAbstraite>();
occupant = null;
objetOccupant= null;
}
public void generateVoisins(CaseAbstraite[][] plateau) {
for (int i = coord.getHor() - 1; i < coord.getHor() + 1; i++) {
for (int j = coord.getVert() - 1; j < coord.getVert() + 1; j++) {
if (i > 0 && i < plateau.length && j > 0 && j < plateau[0].length) {
if (i == coord.getHor() && j < coord.getVert()) {
voisins.put(PointsCardinaux.N, plateau[i][j]);
} else if (i > coord.getHor() && j < coord.getVert()) {
voisins.put(PointsCardinaux.NE, plateau[i][j]);
} else if (i > coord.getHor() && j == coord.getVert()) {
voisins.put(PointsCardinaux.E, plateau[i][j]);
} else if (i > coord.getHor() && j > coord.getVert()) {
voisins.put(PointsCardinaux.NE, plateau[i][j]);
} else if (i == coord.getHor() && j > coord.getVert()) {
voisins.put(PointsCardinaux.S, plateau[i][j]);
} else if (i < coord.getHor() && j > coord.getVert()) {
voisins.put(PointsCardinaux.SW, plateau[i][j]);
} else if (i < coord.getHor() && j == coord.getVert()) {
voisins.put(PointsCardinaux.W, plateau[i][j]);
} else if (i < coord.getHor() && j < coord.getVert()) {
voisins.put(PointsCardinaux.NW, plateau[i][j]);
}
}
}
}
}
public void ajouterVoisin(PointsCardinaux p, CaseAbstraite c) {
voisins.put(p, c);
}

View File

@ -29,4 +29,9 @@ public class EtatPersonnageCombattant extends EtatPersonnageAbstrait {
}
@Override
public void mediationConflits() {
}
}

View File

@ -36,4 +36,9 @@ public class EtatPersonnageKO extends EtatPersonnageAbstrait {
}
@Override
public void mediationConflits() {
}
}

View File

@ -1,12 +1,6 @@
package Etats;
import Comportements.ComportementAction;
import Comportements.ComportementActionChangerCouleurCase;
import Comportements.ComportementActionRamasserNeige;
import Comportements.ComportementActionSeDeplacer;
import Comportements.ComportementActionTirerBalon;
import Comportements.ComportementActionTirerBouleDeNeige;
import Comportements.EAction;
import Comportements.*;
import Person.Personnage;
public class EtatPersonnageOK extends EtatPersonnageAbstrait {
@ -17,7 +11,7 @@ public class EtatPersonnageOK extends EtatPersonnageAbstrait {
super(perso);
// TODO Auto-generated constructor stub
this.ChangerAction(EAction.Null);
this.ChangerAction(EAction.SeDeplacer);
}
@Override
@ -38,6 +32,11 @@ public class EtatPersonnageOK extends EtatPersonnageAbstrait {
}
@Override
public void mediationConflits() {
}
public void ChangerAction(EAction nouvelAction) {
switch(nouvelAction)
@ -57,9 +56,9 @@ public class EtatPersonnageOK extends EtatPersonnageAbstrait {
case TirerBouleDeNeige:
Action = new ComportementActionTirerBouleDeNeige();
break;
case Null:
Action = null;
break;
//case Null:
//Action = null;
//break;
default:
break;

View File

@ -13,6 +13,11 @@ public class FabriquePlateauBattleZone extends FabriquePlateauAbstraite {
plateau[ligne][col] = new CaseColore(col, ligne);
}
}
for (CaseAbstraite[] tabC : plateau) {
for (CaseAbstraite c : tabC) {
c.generateVoisins(plateau);
}
}
return plateau;
}
}