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