Comportement pour les personnages BattleZone.
This commit is contained in:
parent
9a5c60e86e
commit
a430792085
@ -27,4 +27,8 @@ public abstract class CaseAbstraite {
|
||||
public void ajouterOccupant(Personnage occ) {
|
||||
this.occupant = occ;
|
||||
}
|
||||
|
||||
public Personnage getOccupant() {
|
||||
return occupant;
|
||||
}
|
||||
}
|
20
src/Cases/CaseColore.java
Normal file
20
src/Cases/CaseColore.java
Normal file
@ -0,0 +1,20 @@
|
||||
package Cases;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class CaseColore extends CaseAbstraite {
|
||||
Color couleur;
|
||||
|
||||
public CaseColore(int vert, int hor) {
|
||||
super(vert, hor);
|
||||
this.couleur = Color.WHITE;
|
||||
}
|
||||
|
||||
public Color getCouleur() {
|
||||
return couleur;
|
||||
}
|
||||
|
||||
public void setCouleur(Color couleur) {
|
||||
this.couleur = couleur;
|
||||
}
|
||||
}
|
15
src/Comportements/ComportementActionChangerCouleurCase.java
Normal file
15
src/Comportements/ComportementActionChangerCouleurCase.java
Normal file
@ -0,0 +1,15 @@
|
||||
package Comportements;
|
||||
|
||||
import Cases.CaseAbstraite;
|
||||
import Cases.CaseColore;
|
||||
import Person.PersonnageBattleZone;
|
||||
|
||||
public class ComportementActionChangerCouleurCase implements ComportementAction {
|
||||
|
||||
@Override
|
||||
public void executerAction(CaseAbstraite c) {
|
||||
CaseColore caseColore = (CaseColore) c;
|
||||
PersonnageBattleZone personnage = (PersonnageBattleZone) c.getOccupant();
|
||||
caseColore.setCouleur(personnage.getCouleur());
|
||||
}
|
||||
}
|
29
src/Person/PersonnageBattleZone.java
Normal file
29
src/Person/PersonnageBattleZone.java
Normal file
@ -0,0 +1,29 @@
|
||||
package Person;
|
||||
|
||||
import Observateur.Organisation;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class PersonnageBattleZone extends Personnage {
|
||||
Color couleur;
|
||||
|
||||
protected PersonnageBattleZone(Organisation etatMajor, String nom) {
|
||||
super(etatMajor, nom);
|
||||
|
||||
// Couleur Aléatoire
|
||||
Random rand = new Random();
|
||||
int r = rand.nextInt(255);
|
||||
int g = rand.nextInt(255);
|
||||
int b = rand.nextInt(255);
|
||||
this.couleur = new Color(r, g, b);
|
||||
}
|
||||
|
||||
public Color getCouleur() {
|
||||
return couleur;
|
||||
}
|
||||
|
||||
public void setCouleur(Color couleur) {
|
||||
this.couleur = couleur;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user