Ils sont vivants !
This commit is contained in:
parent
25c10eee4a
commit
bcd693aba7
17
src/Cases/RandomPointCardinal.java
Normal file
17
src/Cases/RandomPointCardinal.java
Normal file
@ -0,0 +1,17 @@
|
||||
package Cases;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomPointCardinal<E extends Enum> {
|
||||
|
||||
private static final Random RND = new Random();
|
||||
private final E[] values;
|
||||
|
||||
public RandomPointCardinal(Class<E> token) {
|
||||
values = token.getEnumConstants();
|
||||
}
|
||||
|
||||
public E random() {
|
||||
return values[RND.nextInt(values.length)];
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package Comportements;
|
||||
|
||||
import Cases.CaseAbstraite;
|
||||
import Person.Personnage;
|
||||
|
||||
public interface ComportementAction {
|
||||
public void executerAction(CaseAbstraite c);
|
||||
public void executerAction(Personnage joueur);
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package Comportements;
|
||||
|
||||
import Cases.CaseAbstraite;
|
||||
import Cases.CaseColore;
|
||||
import Person.Personnage;
|
||||
import Person.PersonnageBattleZone;
|
||||
|
||||
public class ComportementActionChangerCouleurCase implements ComportementAction {
|
||||
|
||||
@Override
|
||||
public void executerAction(CaseAbstraite c) {
|
||||
CaseColore caseColore = (CaseColore) c;
|
||||
PersonnageBattleZone personnage = (PersonnageBattleZone) c.getOccupant();
|
||||
public void executerAction(Personnage p) {
|
||||
CaseColore caseColore = (CaseColore) p.getCaseCourante();
|
||||
PersonnageBattleZone personnage = (PersonnageBattleZone) p;
|
||||
caseColore.setCouleur(personnage.getCouleur());
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package Comportements;
|
||||
|
||||
import Cases.CaseAbstraite;
|
||||
import Person.Personnage;
|
||||
|
||||
public class ComportementActionRamasserNeige implements ComportementAction {
|
||||
|
||||
@Override
|
||||
public void executerAction(CaseAbstraite c) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void executerAction(Personnage joueur) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,27 @@
|
||||
package Comportements;
|
||||
|
||||
import Cases.CaseAbstraite;
|
||||
import Cases.PointsCardinaux;
|
||||
import Cases.RandomPointCardinal;
|
||||
import Person.Personnage;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ComportementActionSeDeplacer implements ComportementAction {
|
||||
|
||||
@Override
|
||||
public void executerAction(CaseAbstraite c) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
public void executerAction(Personnage perso) {
|
||||
CaseAbstraite c = perso.getCaseCourante();
|
||||
HashMap<PointsCardinaux, CaseAbstraite> voisins = c.getVoisins();
|
||||
RandomPointCardinal<PointsCardinaux> p = new RandomPointCardinal<PointsCardinaux>(PointsCardinaux.class);
|
||||
PointsCardinaux point = null;
|
||||
do {
|
||||
point = p.random();
|
||||
} while (voisins.get(point) == null);
|
||||
CaseAbstraite destination = voisins.get(point);
|
||||
destination.setOccupant(perso);
|
||||
perso.setCaseCourante(destination);
|
||||
c.setOccupant(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package Comportements;
|
||||
|
||||
import Cases.CaseAbstraite;
|
||||
import Person.Personnage;
|
||||
|
||||
public class ComportementActionTirerBalon implements ComportementAction {
|
||||
|
||||
@Override
|
||||
public void executerAction(CaseAbstraite c) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void executerAction(Personnage joueur) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package Comportements;
|
||||
|
||||
import Cases.CaseAbstraite;
|
||||
import Person.Personnage;
|
||||
|
||||
public class ComportementActionTirerBouleDeNeige implements ComportementAction {
|
||||
|
||||
@Override
|
||||
public void executerAction(CaseAbstraite c) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void executerAction(Personnage joueur) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ public class EtatPersonnageOK extends EtatPersonnageAbstrait {
|
||||
@Override
|
||||
public void ExecutionJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
Action.executerAction(this.joueur.getCaseCourante());
|
||||
}
|
||||
Action.executerAction(this.joueur);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ConflitJoueur() {
|
||||
|
Loading…
Reference in New Issue
Block a user