From 1ac8d8e66c0794ec67efde1f1a6dd040d683f6a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sun, 9 Oct 2016 14:01:53 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20ajout=20des=20canons=20=C3=A0=20=C3=A9l?= =?UTF-8?q?ectron=20change=20dans=20l'appel=20de=20processcycle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/fr/evolving/UI/IconValue.java | 12 ++-- core/src/fr/evolving/UI/Menu.java | 4 ++ core/src/fr/evolving/assets/AssetLoader.java | 10 +++- core/src/fr/evolving/automata/Filter1.java | 3 +- core/src/fr/evolving/automata/Filter2.java | 3 +- core/src/fr/evolving/automata/Filter4.java | 3 +- .../evolving/automata/Filter4Activable.java | 3 +- .../evolving/automata/Filter8Activable.java | 3 +- .../fr/evolving/automata/FilterActivable.java | 3 +- core/src/fr/evolving/automata/FilterBig.java | 3 +- .../fr/evolving/automata/FilterNegative.java | 3 +- .../fr/evolving/automata/FilterPositive.java | 3 +- core/src/fr/evolving/automata/Grid.java | 29 +++++----- .../src/fr/evolving/automata/Insufler100.java | 3 +- core/src/fr/evolving/automata/Insufler33.java | 3 +- core/src/fr/evolving/automata/Insufler50.java | 3 +- core/src/fr/evolving/automata/Inverter_I.java | 3 +- .../src/fr/evolving/automata/Inverter_II.java | 3 +- core/src/fr/evolving/automata/Level.java | 6 +- core/src/fr/evolving/automata/Negativer.java | 3 +- .../src/fr/evolving/automata/Negativer_I.java | 3 +- .../fr/evolving/automata/Negativer_II.java | 3 +- .../fr/evolving/automata/Negativer_III.java | 3 +- .../fr/evolving/automata/Neutraliser_I.java | 3 +- .../fr/evolving/automata/Neutraliser_II.java | 3 +- core/src/fr/evolving/automata/Oneway.java | 3 +- core/src/fr/evolving/automata/Particle.java | 57 ++++++++++++++++--- core/src/fr/evolving/automata/Positiver.java | 3 +- .../src/fr/evolving/automata/Positiver_I.java | 3 +- .../fr/evolving/automata/Positiver_II.java | 3 +- .../fr/evolving/automata/Positiver_III.java | 3 +- core/src/fr/evolving/automata/Transmuter.java | 3 +- .../src/fr/evolving/automata/distributor.java | 3 +- 33 files changed, 139 insertions(+), 60 deletions(-) diff --git a/core/src/fr/evolving/UI/IconValue.java b/core/src/fr/evolving/UI/IconValue.java index e406427..d61ec80 100644 --- a/core/src/fr/evolving/UI/IconValue.java +++ b/core/src/fr/evolving/UI/IconValue.java @@ -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; } diff --git a/core/src/fr/evolving/UI/Menu.java b/core/src/fr/evolving/UI/Menu.java index 84a7ec6..a1e6725 100644 --- a/core/src/fr/evolving/UI/Menu.java +++ b/core/src/fr/evolving/UI/Menu.java @@ -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(); } diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index fbf74f2..4b434ca 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -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; @@ -216,7 +220,11 @@ public class AssetLoader { allTransmuter.add(new Filter2()); allTransmuter.add(new Filter4()); allTransmuter.add(new Filter4Activable()); - allTransmuter.add(new Filter8Activable()); + 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 allTiles = transmuter.getTilesid().iterator(); while (allTiles.hasNext()) { diff --git a/core/src/fr/evolving/automata/Filter1.java b/core/src/fr/evolving/automata/Filter1.java index f249512..55479e9 100644 --- a/core/src/fr/evolving/automata/Filter1.java +++ b/core/src/fr/evolving/automata/Filter1.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Filter2.java b/core/src/fr/evolving/automata/Filter2.java index aa567e2..eaff57a 100644 --- a/core/src/fr/evolving/automata/Filter2.java +++ b/core/src/fr/evolving/automata/Filter2.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Filter4.java b/core/src/fr/evolving/automata/Filter4.java index 118956b..ee83377 100644 --- a/core/src/fr/evolving/automata/Filter4.java +++ b/core/src/fr/evolving/automata/Filter4.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Filter4Activable.java b/core/src/fr/evolving/automata/Filter4Activable.java index ee2fb43..6016c11 100644 --- a/core/src/fr/evolving/automata/Filter4Activable.java +++ b/core/src/fr/evolving/automata/Filter4Activable.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Filter8Activable.java b/core/src/fr/evolving/automata/Filter8Activable.java index 5eff8ba..004bac3 100644 --- a/core/src/fr/evolving/automata/Filter8Activable.java +++ b/core/src/fr/evolving/automata/Filter8Activable.java @@ -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) { diff --git a/core/src/fr/evolving/automata/FilterActivable.java b/core/src/fr/evolving/automata/FilterActivable.java index 51ee364..4923d33 100644 --- a/core/src/fr/evolving/automata/FilterActivable.java +++ b/core/src/fr/evolving/automata/FilterActivable.java @@ -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) { diff --git a/core/src/fr/evolving/automata/FilterBig.java b/core/src/fr/evolving/automata/FilterBig.java index f14a699..0c2305a 100644 --- a/core/src/fr/evolving/automata/FilterBig.java +++ b/core/src/fr/evolving/automata/FilterBig.java @@ -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) { diff --git a/core/src/fr/evolving/automata/FilterNegative.java b/core/src/fr/evolving/automata/FilterNegative.java index cc76622..537f553 100644 --- a/core/src/fr/evolving/automata/FilterNegative.java +++ b/core/src/fr/evolving/automata/FilterNegative.java @@ -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) { diff --git a/core/src/fr/evolving/automata/FilterPositive.java b/core/src/fr/evolving/automata/FilterPositive.java index 437b186..2b0ad72 100644 --- a/core/src/fr/evolving/automata/FilterPositive.java +++ b/core/src/fr/evolving/automata/FilterPositive.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Grid.java b/core/src/fr/evolving/automata/Grid.java index 1e1c508..fec32d0 100644 --- a/core/src/fr/evolving/automata/Grid.java +++ b/core/src/fr/evolving/automata/Grid.java @@ -25,7 +25,7 @@ public class Grid implements Serializable,Cloneable { private transient Array particles; private transient Array transmuters; private transient Array 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;i0) this.ActivationLevel -= 1; + return null; } public void Run(Particle particle) { diff --git a/core/src/fr/evolving/automata/Insufler33.java b/core/src/fr/evolving/automata/Insufler33.java index 832e659..fd7aff5 100644 --- a/core/src/fr/evolving/automata/Insufler33.java +++ b/core/src/fr/evolving/automata/Insufler33.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Insufler50.java b/core/src/fr/evolving/automata/Insufler50.java index 5d761ae..b5e06c1 100644 --- a/core/src/fr/evolving/automata/Insufler50.java +++ b/core/src/fr/evolving/automata/Insufler50.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Inverter_I.java b/core/src/fr/evolving/automata/Inverter_I.java index 6ba4ae0..684be92 100644 --- a/core/src/fr/evolving/automata/Inverter_I.java +++ b/core/src/fr/evolving/automata/Inverter_I.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Inverter_II.java b/core/src/fr/evolving/automata/Inverter_II.java index ef0c4dd..77ca366 100644 --- a/core/src/fr/evolving/automata/Inverter_II.java +++ b/core/src/fr/evolving/automata/Inverter_II.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Level.java b/core/src/fr/evolving/automata/Level.java index 14f6061..cbe21f0 100644 --- a/core/src/fr/evolving/automata/Level.java +++ b/core/src/fr/evolving/automata/Level.java @@ -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; diff --git a/core/src/fr/evolving/automata/Negativer.java b/core/src/fr/evolving/automata/Negativer.java index fecabae..d3ee975 100644 --- a/core/src/fr/evolving/automata/Negativer.java +++ b/core/src/fr/evolving/automata/Negativer.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Negativer_I.java b/core/src/fr/evolving/automata/Negativer_I.java index 3b74c17..3fe55a9 100644 --- a/core/src/fr/evolving/automata/Negativer_I.java +++ b/core/src/fr/evolving/automata/Negativer_I.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Negativer_II.java b/core/src/fr/evolving/automata/Negativer_II.java index bc91450..5114dd8 100644 --- a/core/src/fr/evolving/automata/Negativer_II.java +++ b/core/src/fr/evolving/automata/Negativer_II.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Negativer_III.java b/core/src/fr/evolving/automata/Negativer_III.java index 7a18de3..ef36607 100644 --- a/core/src/fr/evolving/automata/Negativer_III.java +++ b/core/src/fr/evolving/automata/Negativer_III.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Neutraliser_I.java b/core/src/fr/evolving/automata/Neutraliser_I.java index 0c5c46a..3354020 100644 --- a/core/src/fr/evolving/automata/Neutraliser_I.java +++ b/core/src/fr/evolving/automata/Neutraliser_I.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Neutraliser_II.java b/core/src/fr/evolving/automata/Neutraliser_II.java index 8cdd69c..32e3a4f 100644 --- a/core/src/fr/evolving/automata/Neutraliser_II.java +++ b/core/src/fr/evolving/automata/Neutraliser_II.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Oneway.java b/core/src/fr/evolving/automata/Oneway.java index b560a7d..cca7c66 100644 --- a/core/src/fr/evolving/automata/Oneway.java +++ b/core/src/fr/evolving/automata/Oneway.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Particle.java b/core/src/fr/evolving/automata/Particle.java index 851333a..c018394 100644 --- a/core/src/fr/evolving/automata/Particle.java +++ b/core/src/fr/evolving/automata/Particle.java @@ -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() { @@ -160,6 +163,19 @@ public class Particle { return null; 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) { @@ -208,13 +224,14 @@ public class Particle { Vector2 move=null; Orientation[] orientations=getOrientations(this.orientation, type); Array orientations_good=new Array(); + 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; + } } \ No newline at end of file diff --git a/core/src/fr/evolving/automata/Positiver.java b/core/src/fr/evolving/automata/Positiver.java index 747c8ad..755f460 100644 --- a/core/src/fr/evolving/automata/Positiver.java +++ b/core/src/fr/evolving/automata/Positiver.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Positiver_I.java b/core/src/fr/evolving/automata/Positiver_I.java index aa37729..55a88e3 100644 --- a/core/src/fr/evolving/automata/Positiver_I.java +++ b/core/src/fr/evolving/automata/Positiver_I.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Positiver_II.java b/core/src/fr/evolving/automata/Positiver_II.java index e8dd67a..0862af3 100644 --- a/core/src/fr/evolving/automata/Positiver_II.java +++ b/core/src/fr/evolving/automata/Positiver_II.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Positiver_III.java b/core/src/fr/evolving/automata/Positiver_III.java index 653fff7..24b7a7b 100644 --- a/core/src/fr/evolving/automata/Positiver_III.java +++ b/core/src/fr/evolving/automata/Positiver_III.java @@ -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) { diff --git a/core/src/fr/evolving/automata/Transmuter.java b/core/src/fr/evolving/automata/Transmuter.java index 9d4b46b..a42db0e 100644 --- a/core/src/fr/evolving/automata/Transmuter.java +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -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) { diff --git a/core/src/fr/evolving/automata/distributor.java b/core/src/fr/evolving/automata/distributor.java index d5e904f..f9d3bce 100644 --- a/core/src/fr/evolving/automata/distributor.java +++ b/core/src/fr/evolving/automata/distributor.java @@ -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) {