feat: ajout des canons à électron change dans l'appel de processcycle

This commit is contained in:
Nicolas Hordé 2016-10-09 14:01:53 +02:00
parent 57645dd806
commit 1ac8d8e66c
33 changed files with 139 additions and 60 deletions

View File

@ -56,23 +56,23 @@ public class IconValue extends ImageTextButton{
case temp:
this.setVisible(worlds.getWorld()>=2 || worlds.isDebug());
if (showmaximum)
this.setText(String.valueOf(worlds.getLevelData().Temp)+"/"+String.valueOf(worlds.getLevelData().Maxtemp));
this.setText(String.valueOf((int)worlds.getLevelData().Temp)+"/"+String.valueOf(worlds.getLevelData().Maxtemp));
else
this.setText(String.valueOf(worlds.getLevelData().Temp));
this.setText(String.valueOf((int)worlds.getLevelData().Temp));
break;
case rayon:
this.setVisible(worlds.getWorld()>=3 || worlds.isDebug());
if (showmaximum)
this.setText(String.valueOf(worlds.getLevelData().Rayon)+"/"+String.valueOf(worlds.getLevelData().Maxrayon));
this.setText(String.valueOf((int)worlds.getLevelData().Rayon)+"/"+String.valueOf(worlds.getLevelData().Maxrayon));
else
this.setText(String.valueOf(worlds.getLevelData().Rayon));
this.setText(String.valueOf((int)worlds.getLevelData().Rayon));
break;
case nrj:
this.setVisible(worlds.getWorld()>=4 || worlds.isDebug());
if (showmaximum)
this.setText(String.valueOf(worlds.getLevelData().Nrj)+"/"+String.valueOf(worlds.getLevelData().Maxnrj));
this.setText(String.valueOf((int)worlds.getLevelData().Nrj)+"/"+String.valueOf(worlds.getLevelData().Maxnrj));
else
this.setText(String.valueOf(worlds.getLevelData().Nrj));
this.setText(String.valueOf((int)worlds.getLevelData().Nrj));
break;
}

View File

@ -276,6 +276,10 @@ public class Menu extends Actor {
this.setMenuTransmuter(1, 2, "=4",Angular.A00,0);
this.setMenuTransmuter(1, 7, "=4a",Angular.A00,1);
this.setMenuTransmuter(1, 6, "=8a",Angular.A00,1);
this.setMenuTransmuter(0, 7, "->1",Angular.A00,0);
this.setMenuTransmuter(2, 7, "->2",Angular.A00,0);
this.setMenuTransmuter(0, 6, "->3",Angular.A00,0);
this.setMenuTransmuter(2, 6, "->4",Angular.A00,0);
this.unSelect();
}

View File

@ -29,6 +29,10 @@ import com.badlogic.gdx.utils.viewport.ScalingViewport;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import com.badlogic.gdx.Application;
import fr.evolving.automata.Canon_I;
import fr.evolving.automata.Canon_II;
import fr.evolving.automata.Canon_III;
import fr.evolving.automata.Canon_IV;
import fr.evolving.automata.Filter1;
import fr.evolving.automata.Filter2;
import fr.evolving.automata.Filter4;
@ -217,6 +221,10 @@ public class AssetLoader {
allTransmuter.add(new Filter4());
allTransmuter.add(new Filter4Activable());
allTransmuter.add(new Filter8Activable());
allTransmuter.add(new Canon_I());
allTransmuter.add(new Canon_II());
allTransmuter.add(new Canon_III());
allTransmuter.add(new Canon_IV());
for (Transmuter transmuter : allTransmuter) {
Values<Integer> allTiles = transmuter.getTilesid().iterator();
while (allTiles.hasNext()) {

View File

@ -108,12 +108,13 @@ public class Filter1 extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -107,12 +107,13 @@ public class Filter2 extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -106,12 +106,13 @@ public class Filter4 extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -107,12 +107,13 @@ public class Filter4Activable extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -106,12 +106,13 @@ public class Filter8Activable extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -106,12 +106,13 @@ public class FilterActivable extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -106,12 +106,13 @@ public class FilterBig extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -106,12 +106,13 @@ public class FilterNegative extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -105,12 +105,13 @@ public class FilterPositive extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -25,7 +25,7 @@ public class Grid implements Serializable,Cloneable {
private transient Array<Particle> particles;
private transient Array<Transmuter> transmuters;
private transient Array<Vector2> transmuterscoords;
private transient Level level;
public Grid(Integer X, Integer Y) {
Reinit();
this.sizeX = X;
@ -49,9 +49,7 @@ public class Grid implements Serializable,Cloneable {
//Réalise un cycle de simulation dans la grille
public void Cycle() {
for(Transmuter transmuter:transmuters) {
transmuter.ProcessCycle();
}
level.Cycle++;
for(Particle particle: particles) {
Gdx.app.debug("wirechem-Grid", "Grid Cycle -> Particle "+particle.getType()+"/"+particle.getSize()+ " coords:"+particle.getCoordx()+","+particle.getCoordy()+"/"+particle.getOrientation()+" charge:"+particle.getCharge());
if (particle.getType()==Type.Photon) {
@ -89,6 +87,16 @@ public class Grid implements Serializable,Cloneable {
particles.removeValue(particle, true);
}
}
for(int i=0;i<transmuters.size;i++) {
Particle particle=transmuters.get(i).ProcessCycle();
if (particle!=null) {
particle.setGrid(this);
particle.setCoordx((int) transmuterscoords.get(i).x);
particle.setCoordy((int) transmuterscoords.get(i).y);
particle.setOrientationfromAngle(transmuters.get(i).getRotation());
particles.add(particle);
}
}
}
//Affiche le cycle en cours à l'écran
@ -114,20 +122,9 @@ public class Grid implements Serializable,Cloneable {
//Initialise la simulation pour permettre ensuite de faire des cycles
public void Initialize(Level level) {
this.level=level;
particles.clear();
this.tiling_particle();
particles.add(new Particle(this));
particles.get(0).setType(Type.Photon);
particles.get(0).setCoordx(6);
particles.get(0).setCoordy(3);
particles.get(0).setOrientation(Orientation.E);
particles.add(new Particle(this));
particles.get(1).setType(Type.Electron);
particles.get(1).setSize(Size.Gros);
particles.get(1).setCharge(Charge.Negatif);
particles.get(1).setCoordx(7);
particles.get(1).setCoordy(13);
particles.get(1).setOrientation(Orientation.O);
transmuters.clear();
transmuterscoords.clear();
for (int x = 0; x < this.sizeX; x++)

View File

@ -118,12 +118,13 @@ public class Insufler100 extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -119,12 +119,13 @@ public class Insufler33 extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -118,12 +118,13 @@ public class Insufler50 extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -101,12 +101,13 @@ public class Inverter_I extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -100,12 +100,13 @@ public class Inverter_II extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -36,9 +36,9 @@ public class Level implements Serializable,Cloneable {
public transient int Cout;
public transient Grid Grid;
public transient int Cycle;
public transient int Temp;
public transient int Rayon;
public transient int Nrj;
public transient float Temp;
public transient float Rayon;
public transient float Nrj;
public transient boolean Locked;

View File

@ -101,12 +101,13 @@ public class Negativer extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -103,12 +103,13 @@ public class Negativer_I extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -103,12 +103,13 @@ public class Negativer_II extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -101,12 +101,13 @@ public class Negativer_III extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -101,12 +101,13 @@ public class Neutraliser_I extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -101,12 +101,13 @@ public class Neutraliser_II extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -102,12 +102,13 @@ public class Oneway extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -4,6 +4,8 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import fr.evolving.automata.Transmuter.Angular;
public class Particle {
public enum Type {
Electron, Photon, Proton, Neutron
@ -32,7 +34,7 @@ public class Particle {
static private Grid grid;
public Particle(Grid grid) {
public Particle(Grid thegrid) {
this.life=PHOTONLIFE;
this.Alive=true;
this.type=Type.Electron;
@ -41,7 +43,8 @@ public class Particle {
this.charge=Charge.Neutre;
this.coordX=0;
this.coordY=0;
Particle.grid=grid;
if (grid!=null)
Particle.grid=thegrid;
}
public void kill() {
@ -161,6 +164,19 @@ public class Particle {
return new Vector2(movex,movey);
}
private boolean isOpposite(Orientation orientation, Orientation orientation2) {
int movex=0,movey=0;
if (orientation.toString().contains("N")) movey=+1;
if (orientation.toString().contains("S")) movey=-1;
if (orientation.toString().contains("E")) movex=+1;
if (orientation.toString().contains("O")) movex=-1;
if (orientation2.toString().contains("N")) movey+=+1;
if (orientation2.toString().contains("S")) movey+=-1;
if (orientation2.toString().contains("E")) movex+=+1;
if (orientation2.toString().contains("O")) movex+=-1;
return (movex==0 && movey==0);
}
private Orientation[] getOrientations(Orientation orientation, Type type) {
if (type==Type.Photon) {
switch (orientation) {
@ -208,13 +224,14 @@ public class Particle {
Vector2 move=null;
Orientation[] orientations=getOrientations(this.orientation, type);
Array<Orientation> orientations_good=new Array<Orientation>();
Orientation neworientation=Orientation.Fixed;
for(Orientation orientationtest:orientations)
if (TestOrientation(orientationtest,type)!=null)
orientations_good.add(orientationtest);
if (orientations_good.contains(orientation, true))
orientation=orientation;
else if (orientations_good.contains(oldorientation, true))
orientation=oldorientation;
neworientation=orientation;
else if (orientations_good.contains(oldorientation, true) && !isOpposite(orientation,oldorientation))
neworientation=oldorientation;
else {
for(Orientation orientationtest2:orientations_good) {
if (orientationtest2==Orientation.Kill) {
@ -223,15 +240,41 @@ public class Particle {
return;
}
else {
orientation=orientationtest2;
neworientation=orientationtest2;
break;
}
}
}
move=TestOrientation(orientation,type);
move=TestOrientation(neworientation,type);
if (orientation!=neworientation) {
oldorientation=orientation;
orientation=neworientation;
}
Gdx.app.debug("wirechem-Particle", "coords:"+this.coordX+","+this.coordY+" move to "+orientation+":"+move.x+","+move.y+" life:"+this.life);
this.coordX+=move.x;
this.coordY+=move.y;
}
public void setOrientationfromAngle(Angular rotation) {
switch (rotation) {
case A00:
this.orientation=Orientation.O;
break;
case A90:
this.orientation=Orientation.S;
break;
case A180:
this.orientation=Orientation.E;
break;
case A270:
default:
this.orientation=Orientation.N;
break;
}
}
public void setGrid(Grid grid2) {
this.grid=grid2;
}
}

View File

@ -101,12 +101,13 @@ public class Positiver extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -103,12 +103,13 @@ public class Positiver_I extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -103,12 +103,13 @@ public class Positiver_II extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -100,12 +100,13 @@ public class Positiver_III extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {

View File

@ -98,7 +98,8 @@ public abstract class Transmuter implements Cloneable, Serializable {
public void restorestatic() {
}
public void ProcessCycle() {
public Particle ProcessCycle() {
return null;
}
public void Run(Particle particle) {

View File

@ -109,12 +109,13 @@ public class distributor extends Transmuter {
this.showed=this.temp_showed;
}
public void ProcessCycle() {
public Particle ProcessCycle() {
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
if (this.ActivationLevel>0) this.ActivationLevel -= 1;
return null;
}
public void Run(Particle particle) {