lien Etat et strategie
This commit is contained in:
parent
728a8f31a6
commit
3215a06a9c
@ -1,5 +1,6 @@
|
||||
package Cases;
|
||||
|
||||
import Objets.ObjetAbstrait;
|
||||
import Person.Personnage;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -7,6 +8,7 @@ import java.util.HashMap;
|
||||
public abstract class CaseAbstraite {
|
||||
Personnage occupant;
|
||||
|
||||
|
||||
HashMap<PointsCardinaux, CaseAbstraite> voisins;
|
||||
|
||||
Coordonnees coord;
|
||||
|
5
src/Comportements/EAction.java
Normal file
5
src/Comportements/EAction.java
Normal file
@ -0,0 +1,5 @@
|
||||
package Comportements;
|
||||
|
||||
public enum EAction {
|
||||
ChangerCouleurCase,RamasserNeige,SeDeplacer,TirerBalon,TirerBouleDeNeige,Null
|
||||
}
|
@ -9,4 +9,8 @@ public abstract class EtatPersonnageAbstrait {
|
||||
protected EtatPersonnageAbstrait(Personnage perso){
|
||||
this.joueur = perso;
|
||||
}
|
||||
|
||||
public abstract void AnalyseJoueur();
|
||||
public abstract void ExecutionJoueur();
|
||||
public abstract void ConflitJoueur();
|
||||
}
|
||||
|
32
src/Etats/EtatPersonnageCombattant.java
Normal file
32
src/Etats/EtatPersonnageCombattant.java
Normal file
@ -0,0 +1,32 @@
|
||||
package Etats;
|
||||
|
||||
import Person.Personnage;
|
||||
|
||||
public class EtatPersonnageCombattant extends EtatPersonnageAbstrait {
|
||||
|
||||
//Etat d'un personnage avec un marteau, cible les joueurs et ignore le reste.
|
||||
|
||||
protected EtatPersonnageCombattant(Personnage perso) {
|
||||
super(perso);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AnalyseJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ExecutionJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ConflitJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -3,10 +3,37 @@ package Etats;
|
||||
import Person.Personnage;
|
||||
|
||||
public class EtatPersonnageKO extends EtatPersonnageAbstrait {
|
||||
|
||||
private int nbTourKO;
|
||||
|
||||
public EtatPersonnageKO(Personnage perso) {
|
||||
super(perso);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
this.nbTourKO = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AnalyseJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ExecutionJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
nbTourKO--;
|
||||
if (nbTourKO==0){
|
||||
this.joueur.ChangeEtat(EEtat.EtatOK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ConflitJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,73 @@
|
||||
package Etats;
|
||||
|
||||
import Comportements.ComportementAction;
|
||||
import Comportements.ComportementActionChangerCouleurCase;
|
||||
import Comportements.ComportementActionRamasserNeige;
|
||||
import Comportements.ComportementActionSeDeplacer;
|
||||
import Comportements.ComportementActionTirerBalon;
|
||||
import Comportements.ComportementActionTirerBouleDeNeige;
|
||||
import Comportements.EAction;
|
||||
import Person.Personnage;
|
||||
|
||||
public class EtatPersonnageOK extends EtatPersonnageAbstrait {
|
||||
|
||||
private ComportementAction Action;
|
||||
|
||||
public EtatPersonnageOK(Personnage perso) {
|
||||
super(perso);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
this.ChangerAction(EAction.Null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AnalyseJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ExecutionJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
Action.executerAction(this.joueur.getCaseCourante());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ConflitJoueur() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void ChangerAction(EAction nouvelAction){
|
||||
|
||||
switch(nouvelAction)
|
||||
{
|
||||
case ChangerCouleurCase:
|
||||
Action = new ComportementActionChangerCouleurCase();
|
||||
break;
|
||||
case RamasserNeige:
|
||||
Action = new ComportementActionRamasserNeige();
|
||||
break;
|
||||
case SeDeplacer:
|
||||
Action = new ComportementActionSeDeplacer();
|
||||
break;
|
||||
case TirerBalon:
|
||||
Action = new ComportementActionTirerBalon();
|
||||
break;
|
||||
case TirerBouleDeNeige:
|
||||
Action = new ComportementActionTirerBouleDeNeige();
|
||||
break;
|
||||
case Null:
|
||||
Action = null;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
this.joueur.setAction(nouvelAction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package Person;
|
||||
|
||||
import Cases.CaseAbstraite;
|
||||
import Comportements.ComportementAction;
|
||||
import Comportements.EAction;
|
||||
import Composition.PersonnagesAbstraits;
|
||||
import Etats.EEtat;
|
||||
import Etats.EtatPersonnageAbstrait;
|
||||
@ -9,13 +10,16 @@ import Etats.EtatPersonnageKO;
|
||||
import Etats.EtatPersonnageOK;
|
||||
|
||||
public class Personnage extends PersonnagesAbstraits {
|
||||
|
||||
|
||||
protected CaseAbstraite caseCourante;
|
||||
protected String nom;
|
||||
protected String groupe;
|
||||
protected double pointsDeVie;
|
||||
protected double force;
|
||||
protected double vitesse;
|
||||
protected ComportementAction action;
|
||||
protected double porter;
|
||||
protected EAction action;
|
||||
private EtatPersonnageAbstrait etatCourant;
|
||||
|
||||
protected Personnage(String name, ComportementAction c) {
|
||||
@ -23,10 +27,11 @@ public class Personnage extends PersonnagesAbstraits {
|
||||
this.pointsDeVie = 100;
|
||||
this.force = 10;
|
||||
this.vitesse = 1;
|
||||
this.porter = 2;
|
||||
|
||||
this.caseCourante = null;
|
||||
this.etatCourant = new EtatPersonnageOK(this);
|
||||
this.action = c;
|
||||
this.action = EAction.Null;
|
||||
}
|
||||
|
||||
protected Personnage(String name, double lifePoint, double strength, double speed, ComportementAction a) {
|
||||
@ -37,7 +42,7 @@ public class Personnage extends PersonnagesAbstraits {
|
||||
|
||||
this.caseCourante=null;
|
||||
this.etatCourant= new EtatPersonnageOK(this);
|
||||
this.action = a;
|
||||
this.action = EAction.Null;
|
||||
}
|
||||
|
||||
|
||||
@ -115,14 +120,35 @@ public class Personnage extends PersonnagesAbstraits {
|
||||
public void setCaseCourante(CaseAbstraite caseCourante) {
|
||||
this.caseCourante = caseCourante;
|
||||
}
|
||||
|
||||
public double getPorter() {
|
||||
return porter;
|
||||
}
|
||||
|
||||
public void setPorter(double porter) {
|
||||
this.porter = porter;
|
||||
}
|
||||
|
||||
public EAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(EAction action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public void AnalyseSituation() {
|
||||
// Todo
|
||||
etatCourant.AnalyseJoueur();
|
||||
}
|
||||
|
||||
public void Execution() {
|
||||
// Todo
|
||||
|
||||
etatCourant.ExecutionJoueur();
|
||||
}
|
||||
|
||||
public void ResoudreLesConflits(){
|
||||
etatCourant.ConflitJoueur();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user