Added default action to persons. Getting them from the factories.
This commit is contained in:
parent
24e620c8c6
commit
728a8f31a6
@ -1,10 +1,10 @@
|
||||
package Fabriques.Personnages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import Observateur.Organisation;
|
||||
import Person.Personnage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FabriquePersonnagesBattleSnow extends FabriquePersonnagesAbstraite {
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,7 @@
|
||||
package Fabriques.Personnages;
|
||||
|
||||
import Comportements.ComportementAction;
|
||||
import Comportements.ComportementActionChangerCouleurCase;
|
||||
import Observateur.Organisation;
|
||||
import Person.Personnage;
|
||||
import Person.PersonnageBattleZone;
|
||||
@ -7,17 +9,18 @@ import Person.PersonnageBattleZone;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FabriquePersonnagesBattleZone extends FabriquePersonnagesAbstraite {
|
||||
protected ComportementAction parDefaut = new ComportementActionChangerCouleurCase();
|
||||
@Override
|
||||
public ArrayList<Personnage> CreerPersonages(Organisation o) {
|
||||
ArrayList<Personnage> list = new ArrayList<Personnage>();
|
||||
|
||||
PersonnageBattleZone p1 = new PersonnageBattleZone("Bob",100.0,1.0,1.0);
|
||||
PersonnageBattleZone p1 = new PersonnageBattleZone("Bob", 100.0, 1.0, 1.0, parDefaut);
|
||||
list.add(p1);
|
||||
PersonnageBattleZone p2 = new PersonnageBattleZone("Jo",100.0,1.0,1.0);
|
||||
PersonnageBattleZone p2 = new PersonnageBattleZone("Jo", 100.0, 1.0, 1.0, parDefaut);
|
||||
list.add(p2);
|
||||
PersonnageBattleZone p3 = new PersonnageBattleZone("Max",100.0,1.0,1.0);
|
||||
PersonnageBattleZone p3 = new PersonnageBattleZone("Max", 100.0, 1.0, 1.0, parDefaut);
|
||||
list.add(p3);
|
||||
PersonnageBattleZone p4 = new PersonnageBattleZone("Zac",100.0,1.0,1.0);
|
||||
PersonnageBattleZone p4 = new PersonnageBattleZone("Zac", 100.0, 1.0, 1.0, parDefaut);
|
||||
list.add(p4);
|
||||
return list;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package Fabriques.Personnages;
|
||||
|
||||
import Comportements.ComportementAction;
|
||||
import Comportements.ComportementActionTirerBalon;
|
||||
import Observateur.Organisation;
|
||||
import Person.Arbitre;
|
||||
import Person.JoueurDeChamp;
|
||||
@ -8,6 +10,7 @@ import Person.Personnage;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FabriquePersonnagesFootball extends FabriquePersonnagesAbstraite {
|
||||
ComportementAction parDefaut = new ComportementActionTirerBalon();
|
||||
|
||||
@Override
|
||||
public ArrayList<Personnage> CreerPersonages(Organisation o) {
|
||||
@ -17,11 +20,11 @@ public class FabriquePersonnagesFootball extends FabriquePersonnagesAbstraite {
|
||||
|
||||
|
||||
// TODO: Add team 1
|
||||
JoueurDeChamp joueur = new JoueurDeChamp("Zidane");
|
||||
// TODO: Add players to team 1
|
||||
|
||||
|
||||
// TODO: Add team 2
|
||||
JoueurDeChamp joueur = new JoueurDeChamp("Zidane", parDefaut);
|
||||
// TODO: Add players to team 1
|
||||
|
||||
|
||||
// TODO: Add team 2
|
||||
|
||||
// TODO: Add players to team 2
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
package Person;
|
||||
|
||||
import Comportements.ComportementActionSeDeplacer;
|
||||
|
||||
public class Arbitre extends Personnage {
|
||||
|
||||
public Arbitre(String nom) {
|
||||
super(nom);
|
||||
// TODO: Not sure if this one is a "personnage" with actions/
|
||||
super(nom, new ComportementActionSeDeplacer());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package Person;
|
||||
|
||||
|
||||
import Comportements.ComportementAction;
|
||||
|
||||
public class JoueurDeChamp extends Personnage {
|
||||
|
||||
public JoueurDeChamp(String nom) {
|
||||
super(nom);
|
||||
public JoueurDeChamp(String nom, ComportementAction parDefaut) {
|
||||
super(nom, parDefaut);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package Person;
|
||||
|
||||
import Cases.CaseAbstraite;
|
||||
import Comportements.ComportementAction;
|
||||
import Composition.PersonnagesAbstraits;
|
||||
import Etats.EEtat;
|
||||
import Etats.EtatPersonnageAbstrait;
|
||||
@ -14,9 +15,10 @@ public class Personnage extends PersonnagesAbstraits {
|
||||
protected double pointsDeVie;
|
||||
protected double force;
|
||||
protected double vitesse;
|
||||
protected ComportementAction action;
|
||||
private EtatPersonnageAbstrait etatCourant;
|
||||
|
||||
protected Personnage(String name) {
|
||||
protected Personnage(String name, ComportementAction c) {
|
||||
this.nom = name;
|
||||
this.pointsDeVie = 100;
|
||||
this.force = 10;
|
||||
@ -24,20 +26,22 @@ public class Personnage extends PersonnagesAbstraits {
|
||||
|
||||
this.caseCourante = null;
|
||||
this.etatCourant = new EtatPersonnageOK(this);
|
||||
this.action = c;
|
||||
}
|
||||
|
||||
protected Personnage(String name, double lifePoint, double strength, double speed) {
|
||||
this.nom = name;
|
||||
this.pointsDeVie=lifePoint;
|
||||
|
||||
protected Personnage(String name, double lifePoint, double strength, double speed, ComportementAction a) {
|
||||
this.nom = name;
|
||||
this.pointsDeVie=lifePoint;
|
||||
this.force=strength;
|
||||
this.vitesse=speed;
|
||||
|
||||
this.caseCourante=null;
|
||||
this.etatCourant= new EtatPersonnageOK(this);
|
||||
}
|
||||
|
||||
|
||||
public void ChangeEtat(EEtat NouvelEtat)
|
||||
this.action = a;
|
||||
}
|
||||
|
||||
|
||||
public void ChangeEtat(EEtat NouvelEtat)
|
||||
{
|
||||
switch(NouvelEtat)
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
package Person;
|
||||
|
||||
import Observateur.Organisation;
|
||||
import Comportements.ComportementAction;
|
||||
|
||||
public class PersonnageBattleGoal extends Personnage {
|
||||
|
||||
protected PersonnageBattleGoal(String name, double lifePoint, double strength, double speed) {
|
||||
super(name, lifePoint, strength, speed);
|
||||
protected PersonnageBattleGoal(String name, double lifePoint, double strength, double speed, ComportementAction parDefaut) {
|
||||
super(name, lifePoint, strength, speed, parDefaut);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package Person;
|
||||
|
||||
import Observateur.Organisation;
|
||||
import Comportements.ComportementAction;
|
||||
|
||||
public class PersonnageBattleSnow extends Personnage{
|
||||
|
||||
protected PersonnageBattleSnow(String name, double lifePoint, double strength, double speed) {
|
||||
super(name, lifePoint, strength, speed);
|
||||
protected PersonnageBattleSnow(String name, double lifePoint, double strength, double speed, ComportementAction parDefaut) {
|
||||
super(name, lifePoint, strength, speed, parDefaut);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package Person;
|
||||
|
||||
import Observateur.Organisation;
|
||||
import Comportements.ComportementAction;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
@ -8,10 +8,10 @@ import java.util.Random;
|
||||
public class PersonnageBattleZone extends Personnage {
|
||||
Color couleur;
|
||||
|
||||
public PersonnageBattleZone(String name, double lifePoint, double strength, double speed) {
|
||||
super(name, lifePoint, strength, speed);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
public PersonnageBattleZone(String name, double lifePoint, double strength, double speed, ComportementAction parDefaut) {
|
||||
super(name, lifePoint, strength, speed, parDefaut);
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
|
||||
// Couleur Aléatoire
|
||||
Random rand = new Random();
|
||||
|
@ -59,8 +59,7 @@ public class SimulationJeu {
|
||||
|
||||
boolean continuer = true;
|
||||
while (continuer) {
|
||||
// Todo propagation des informations
|
||||
// Todo Propagation des ordres
|
||||
|
||||
for (Personnage p : personnages) {
|
||||
p.AnalyseSituation();
|
||||
p.Execution();
|
||||
|
Loading…
Reference in New Issue
Block a user