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;
|
package Comportements;
|
||||||
|
|
||||||
import Cases.CaseAbstraite;
|
import Person.Personnage;
|
||||||
|
|
||||||
public interface ComportementAction {
|
public interface ComportementAction {
|
||||||
public void executerAction(CaseAbstraite c);
|
public void executerAction(Personnage joueur);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package Comportements;
|
package Comportements;
|
||||||
|
|
||||||
import Cases.CaseAbstraite;
|
|
||||||
import Cases.CaseColore;
|
import Cases.CaseColore;
|
||||||
|
import Person.Personnage;
|
||||||
import Person.PersonnageBattleZone;
|
import Person.PersonnageBattleZone;
|
||||||
|
|
||||||
public class ComportementActionChangerCouleurCase implements ComportementAction {
|
public class ComportementActionChangerCouleurCase implements ComportementAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executerAction(CaseAbstraite c) {
|
public void executerAction(Personnage p) {
|
||||||
CaseColore caseColore = (CaseColore) c;
|
CaseColore caseColore = (CaseColore) p.getCaseCourante();
|
||||||
PersonnageBattleZone personnage = (PersonnageBattleZone) c.getOccupant();
|
PersonnageBattleZone personnage = (PersonnageBattleZone) p;
|
||||||
caseColore.setCouleur(personnage.getCouleur());
|
caseColore.setCouleur(personnage.getCouleur());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package Comportements;
|
package Comportements;
|
||||||
|
|
||||||
import Cases.CaseAbstraite;
|
import Person.Personnage;
|
||||||
|
|
||||||
public class ComportementActionRamasserNeige implements ComportementAction {
|
public class ComportementActionRamasserNeige implements ComportementAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executerAction(CaseAbstraite c) {
|
public void executerAction(Personnage joueur) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,27 @@
|
|||||||
package Comportements;
|
package Comportements;
|
||||||
|
|
||||||
import Cases.CaseAbstraite;
|
import Cases.CaseAbstraite;
|
||||||
|
import Cases.PointsCardinaux;
|
||||||
|
import Cases.RandomPointCardinal;
|
||||||
|
import Person.Personnage;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class ComportementActionSeDeplacer implements ComportementAction {
|
public class ComportementActionSeDeplacer implements ComportementAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executerAction(CaseAbstraite c) {
|
public void executerAction(Personnage perso) {
|
||||||
// TODO Auto-generated method stub
|
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;
|
package Comportements;
|
||||||
|
|
||||||
import Cases.CaseAbstraite;
|
import Person.Personnage;
|
||||||
|
|
||||||
public class ComportementActionTirerBalon implements ComportementAction {
|
public class ComportementActionTirerBalon implements ComportementAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executerAction(CaseAbstraite c) {
|
public void executerAction(Personnage joueur) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package Comportements;
|
package Comportements;
|
||||||
|
|
||||||
import Cases.CaseAbstraite;
|
import Person.Personnage;
|
||||||
|
|
||||||
public class ComportementActionTirerBouleDeNeige implements ComportementAction {
|
public class ComportementActionTirerBouleDeNeige implements ComportementAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executerAction(CaseAbstraite c) {
|
public void executerAction(Personnage joueur) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ public class EtatPersonnageOK extends EtatPersonnageAbstrait {
|
|||||||
@Override
|
@Override
|
||||||
public void ExecutionJoueur() {
|
public void ExecutionJoueur() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
Action.executerAction(this.joueur.getCaseCourante());
|
Action.executerAction(this.joueur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ConflitJoueur() {
|
public void ConflitJoueur() {
|
||||||
|
Loading…
Reference in New Issue
Block a user