From 2a4c7239d492ee4789a0a15512b38c1abc8a5335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Tue, 4 Oct 2016 21:32:54 +0200 Subject: [PATCH] feat: trajectoire electron et photons avec activation et test sur le positiveur --- core/src/fr/evolving/UI/TouchMaptiles.java | 23 ++- core/src/fr/evolving/assets/AssetLoader.java | 52 +++--- core/src/fr/evolving/automata/Filter1.java | 14 +- core/src/fr/evolving/automata/Filter2.java | 12 +- core/src/fr/evolving/automata/Filter4.java | 10 +- .../evolving/automata/Filter4Activable.java | 12 +- .../evolving/automata/Filter8Activable.java | 10 +- .../fr/evolving/automata/FilterActivable.java | 10 +- core/src/fr/evolving/automata/FilterBig.java | 10 +- .../fr/evolving/automata/FilterNegative.java | 10 +- .../fr/evolving/automata/FilterPositive.java | 10 +- core/src/fr/evolving/automata/Grid.java | 52 ++++-- .../src/fr/evolving/automata/Insufler100.java | 10 +- core/src/fr/evolving/automata/Insufler33.java | 14 +- core/src/fr/evolving/automata/Insufler50.java | 12 +- core/src/fr/evolving/automata/Inverter_I.java | 12 +- .../src/fr/evolving/automata/Inverter_II.java | 10 +- core/src/fr/evolving/automata/Negativer.java | 10 +- .../src/fr/evolving/automata/Negativer_I.java | 12 +- .../fr/evolving/automata/Negativer_II.java | 12 +- .../fr/evolving/automata/Negativer_III.java | 10 +- .../fr/evolving/automata/Neutraliser_I.java | 12 +- .../fr/evolving/automata/Neutraliser_II.java | 10 +- core/src/fr/evolving/automata/Oneway.java | 12 +- core/src/fr/evolving/automata/Particle.java | 148 ++++++++++-------- core/src/fr/evolving/automata/Positiver.java | 10 +- .../src/fr/evolving/automata/Positiver_I.java | 13 +- .../fr/evolving/automata/Positiver_II.java | 12 +- .../fr/evolving/automata/Positiver_III.java | 10 +- core/src/fr/evolving/automata/Transmuter.java | 33 +++- .../src/fr/evolving/automata/distributor.java | 10 +- core/src/fr/evolving/screens/GameScreen.java | 7 +- 32 files changed, 341 insertions(+), 263 deletions(-) diff --git a/core/src/fr/evolving/UI/TouchMaptiles.java b/core/src/fr/evolving/UI/TouchMaptiles.java index a351ba3..de06eed 100644 --- a/core/src/fr/evolving/UI/TouchMaptiles.java +++ b/core/src/fr/evolving/UI/TouchMaptiles.java @@ -162,6 +162,15 @@ public class TouchMaptiles extends Actor implements GestureListener,InputProcess (int) y).setTile(null); } } + + public void tempclear(int[] layers) { + for (int layer: layers) + for (int x = 0; x < level.Grid.sizeX; x++) + for (int y = 0; y < level.Grid.sizeY; y++) { + ((TiledMapTileLayer) map.getLayers().get(layer)).getCell((int) x, + (int) y).setTile(null); + } + } //Calques : // 0 Grille ou Fibres @@ -177,12 +186,20 @@ public class TouchMaptiles extends Actor implements GestureListener,InputProcess for (int y = 0; y < level.Grid.sizeY; y++) { if (worlds.getState()==State.simulating) { if (level.Grid.GetXY(x,y).Fiber) - if (level.Grid.GetXY(x,y).Fiber_state==0) + if (level.Grid.GetXY(x,y).Fiber_state%1000==0) ((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(61)); else { - ((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(89 - +level.Grid.GetXY(x,y).Fiber_state)); + ((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(100-level.Grid.GetXY(x,y).Fiber_state%1000)); } + if (level.Grid.GetXY(x,y).Transmuter!=null) { + int active=Math.floorDiv(level.Grid.GetXY(x,y).Transmuter.getActivationLevel()*10, level.Grid.GetXY(x,y).Transmuter.getMaxActivationLevel()); + ((TiledMapTileLayer) map.getLayers().get(5)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(300+active)); + } + if (level.Grid.GetXY(x,y).Copper) + if (level.Grid.GetXY(x,y).Fiber_state>=1000) + ((TiledMapTileLayer) map.getLayers().get(6)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(level.Grid.GetXY(x,y).Fiber_state/1000)); + else + ((TiledMapTileLayer) map.getLayers().get(6)).getCell((int) x,(int) y).setTile(null); } else { diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index 407bf83..fbf74f2 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -191,32 +191,32 @@ public class AssetLoader { Gdx.app.debug("wirechem-AssetLoader", "Ajout des transmuters"); allTransmuter = new Array(); - allTransmuter.add(new Positiver(null)); - allTransmuter.add(new Positiver_I(null)); - allTransmuter.add(new Positiver_II(null)); - allTransmuter.add(new Positiver_III(null)); - allTransmuter.add(new Negativer(null)); - allTransmuter.add(new Negativer_I(null)); - allTransmuter.add(new Negativer_II(null)); - allTransmuter.add(new Negativer_III(null)); - allTransmuter.add(new Inverter_I(null)); - allTransmuter.add(new Inverter_II(null)); - allTransmuter.add(new Neutraliser_I(null)); - allTransmuter.add(new Neutraliser_II(null)); - allTransmuter.add(new Oneway(null)); - allTransmuter.add(new distributor(null)); - allTransmuter.add(new Insufler100(null)); - allTransmuter.add(new Insufler33(null)); - allTransmuter.add(new Insufler50(null)); - allTransmuter.add(new FilterPositive(null)); - allTransmuter.add(new FilterNegative(null)); - allTransmuter.add(new FilterBig(null)); - allTransmuter.add(new FilterActivable(null)); - allTransmuter.add(new Filter1(null)); - allTransmuter.add(new Filter2(null)); - allTransmuter.add(new Filter4(null)); - allTransmuter.add(new Filter4Activable(null)); - allTransmuter.add(new Filter8Activable(null)); + allTransmuter.add(new Positiver()); + allTransmuter.add(new Positiver_I()); + allTransmuter.add(new Positiver_II()); + allTransmuter.add(new Positiver_III()); + allTransmuter.add(new Negativer()); + allTransmuter.add(new Negativer_I()); + allTransmuter.add(new Negativer_II()); + allTransmuter.add(new Negativer_III()); + allTransmuter.add(new Inverter_I()); + allTransmuter.add(new Inverter_II()); + allTransmuter.add(new Neutraliser_I()); + allTransmuter.add(new Neutraliser_II()); + allTransmuter.add(new Oneway()); + allTransmuter.add(new distributor()); + allTransmuter.add(new Insufler100()); + allTransmuter.add(new Insufler33()); + allTransmuter.add(new Insufler50()); + allTransmuter.add(new FilterPositive()); + allTransmuter.add(new FilterNegative()); + allTransmuter.add(new FilterBig()); + allTransmuter.add(new FilterActivable()); + allTransmuter.add(new Filter1()); + allTransmuter.add(new Filter2()); + allTransmuter.add(new Filter4()); + allTransmuter.add(new Filter4Activable()); + allTransmuter.add(new Filter8Activable()); 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 fc9bf97..f249512 100644 --- a/core/src/fr/evolving/automata/Filter1.java +++ b/core/src/fr/evolving/automata/Filter1.java @@ -40,8 +40,8 @@ public class Filter1 extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Filter1(Level level) { - super(level); + public Filter1() { + super(); this.id="=1"; this.Name = AssetLoader.language.get("[filter1-name]"); this.Desc = AssetLoader.language.get("[filter1-desc]"); @@ -51,8 +51,8 @@ public class Filter1 extends Transmuter { this.Research = 0; this.Upgrade = null; this.Unlock = new Array(); - this.Unlock.add(new Filter2(level)); - this.Unlock.add(new Filter4(level)); + this.Unlock.add(new Filter2()); + this.Unlock.add(new Filter4()); this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = false; @@ -113,10 +113,10 @@ public class Filter1 extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -181,7 +181,7 @@ public class Filter1 extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Filter2.java b/core/src/fr/evolving/automata/Filter2.java index d705cbe..aa567e2 100644 --- a/core/src/fr/evolving/automata/Filter2.java +++ b/core/src/fr/evolving/automata/Filter2.java @@ -40,8 +40,8 @@ public class Filter2 extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Filter2(Level level) { - super(level); + public Filter2() { + super(); this.id="=2"; this.Name = AssetLoader.language.get("[filter2-name]"); this.Desc = AssetLoader.language.get("[filter2-desc]"); @@ -51,7 +51,7 @@ public class Filter2 extends Transmuter { this.Research = 150; this.Upgrade = null; this.Unlock = new Array(); - this.Unlock.add(new Filter4(level)); + this.Unlock.add(new Filter4()); this.showed = false; this.CanUpgradeTemp = true; this.CanUpgradeCycle = false; @@ -112,10 +112,10 @@ public class Filter2 extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -180,7 +180,7 @@ public class Filter2 extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Filter4.java b/core/src/fr/evolving/automata/Filter4.java index 1e35611..118956b 100644 --- a/core/src/fr/evolving/automata/Filter4.java +++ b/core/src/fr/evolving/automata/Filter4.java @@ -40,8 +40,8 @@ public class Filter4 extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Filter4(Level level) { - super(level); + public Filter4() { + super(); this.id="=4"; this.Name = AssetLoader.language.get("[filter4-name]"); this.Desc = AssetLoader.language.get("[filter4-desc]"); @@ -111,10 +111,10 @@ public class Filter4 extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -179,7 +179,7 @@ public class Filter4 extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Filter4Activable.java b/core/src/fr/evolving/automata/Filter4Activable.java index e244bf2..ee2fb43 100644 --- a/core/src/fr/evolving/automata/Filter4Activable.java +++ b/core/src/fr/evolving/automata/Filter4Activable.java @@ -40,8 +40,8 @@ public class Filter4Activable extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Filter4Activable(Level level) { - super(level); + public Filter4Activable() { + super(); this.id="=4a"; this.Name = AssetLoader.language.get("[filter4activable-name]"); this.Desc = AssetLoader.language.get("[filter4activable-desc]"); @@ -51,7 +51,7 @@ public class Filter4Activable extends Transmuter { this.Research = 0; this.Upgrade = null; this.Unlock = new Array(); - this.Unlock.add(new Filter8Activable(level)); + this.Unlock.add(new Filter8Activable()); this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = true; @@ -112,10 +112,10 @@ public class Filter4Activable extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -180,7 +180,7 @@ public class Filter4Activable extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Filter8Activable.java b/core/src/fr/evolving/automata/Filter8Activable.java index 0601817..5eff8ba 100644 --- a/core/src/fr/evolving/automata/Filter8Activable.java +++ b/core/src/fr/evolving/automata/Filter8Activable.java @@ -40,8 +40,8 @@ public class Filter8Activable extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Filter8Activable(Level level) { - super(level); + public Filter8Activable() { + super(); this.id="=8a"; this.Name = AssetLoader.language.get("[filter8activable-name]"); this.Desc = AssetLoader.language.get("[filter8activable-desc]"); @@ -111,10 +111,10 @@ public class Filter8Activable extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -179,7 +179,7 @@ public class Filter8Activable extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/FilterActivable.java b/core/src/fr/evolving/automata/FilterActivable.java index feb602d..51ee364 100644 --- a/core/src/fr/evolving/automata/FilterActivable.java +++ b/core/src/fr/evolving/automata/FilterActivable.java @@ -40,8 +40,8 @@ public class FilterActivable extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public FilterActivable(Level level) { - super(level); + public FilterActivable() { + super(); this.id="=!"; this.Name = AssetLoader.language.get("[filteractivable-name]"); this.Desc = AssetLoader.language.get("[filteractivable-desc]"); @@ -111,10 +111,10 @@ public class FilterActivable extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -179,7 +179,7 @@ public class FilterActivable extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/FilterBig.java b/core/src/fr/evolving/automata/FilterBig.java index 90f97ed..f14a699 100644 --- a/core/src/fr/evolving/automata/FilterBig.java +++ b/core/src/fr/evolving/automata/FilterBig.java @@ -40,8 +40,8 @@ public class FilterBig extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public FilterBig(Level level) { - super(level); + public FilterBig() { + super(); this.id="=E"; this.Name = AssetLoader.language.get("[filterbig-name]"); this.Desc = AssetLoader.language.get("[filterbig-desc]"); @@ -111,10 +111,10 @@ public class FilterBig extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -179,7 +179,7 @@ public class FilterBig extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/FilterNegative.java b/core/src/fr/evolving/automata/FilterNegative.java index face6ad..cc76622 100644 --- a/core/src/fr/evolving/automata/FilterNegative.java +++ b/core/src/fr/evolving/automata/FilterNegative.java @@ -40,8 +40,8 @@ public class FilterNegative extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public FilterNegative(Level level) { - super(level); + public FilterNegative() { + super(); this.id="=-"; this.Name = AssetLoader.language.get("[filternegative-name]"); this.Desc = AssetLoader.language.get("[filternegative-desc]"); @@ -111,10 +111,10 @@ public class FilterNegative extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -179,7 +179,7 @@ public class FilterNegative extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/FilterPositive.java b/core/src/fr/evolving/automata/FilterPositive.java index 9a355f2..437b186 100644 --- a/core/src/fr/evolving/automata/FilterPositive.java +++ b/core/src/fr/evolving/automata/FilterPositive.java @@ -39,8 +39,8 @@ public class FilterPositive extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public FilterPositive(Level level) { - super(level); + public FilterPositive() { + super(); this.id="=+"; this.Name = AssetLoader.language.get("[filterpositive-name]"); this.Desc = AssetLoader.language.get("[filterpositive-desc]"); @@ -110,10 +110,10 @@ public class FilterPositive extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -178,7 +178,7 @@ public class FilterPositive extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Grid.java b/core/src/fr/evolving/automata/Grid.java index d1084b4..1e1c508 100644 --- a/core/src/fr/evolving/automata/Grid.java +++ b/core/src/fr/evolving/automata/Grid.java @@ -12,7 +12,9 @@ import com.badlogic.gdx.utils.ObjectMap.Entries; import com.badlogic.gdx.utils.ObjectMap.Entry; import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Particle.Charge; import fr.evolving.automata.Particle.Orientation; +import fr.evolving.automata.Particle.Size; import fr.evolving.automata.Particle.Type; import fr.evolving.automata.Transmuter.CaseType; @@ -47,6 +49,9 @@ public class Grid implements Serializable,Cloneable { //Réalise un cycle de simulation dans la grille public void Cycle() { + for(Transmuter transmuter:transmuters) { + transmuter.ProcessCycle(); + } 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) { @@ -60,17 +65,28 @@ public class Grid implements Serializable,Cloneable { Vector2 position=transmuterscoords.get(i); if (GetXY(position.x+all.key.x,position.y+all.key.y).Fiber && position.x+all.key.x==particle.getCoordx() && position.y+all.key.y==particle.getCoordy()) if (thecase==CaseType.Fibre||thecase==CaseType.Tout||thecase==CaseType.Fibre_seul) { - Gdx.app.debug("wirechem-Grid", "Grid Cycle -> Activation Photon life:"+particle.getLife()+" coords:"+particle.getCoordx()+","+particle.getCoordy()+" Transmuter:"+transmuters.get(i).getName()+" activation:"+transmuters.get(i).getActivationLevel()); - particle.subLife(transmuters.get(i).getMaxActivationLevel()-transmuters.get(i).getActivationLevel()); - transmuters.get(i).Activate(); - Gdx.app.debug("wirechem-Grid", "Grid Cycle -> Activation Photon life:"+particle.getLife()+" coords:"+particle.getCoordx()+","+particle.getCoordy()+" Transmuter:"+transmuters.get(i).getName()+" activation:"+transmuters.get(i).getActivationLevel()); + int needed=transmuters.get(i).getMaxActivationLevel()-transmuters.get(i).getActivationLevel(); + Gdx.app.debug("wirechem-Grid", "Grid Cycle -> Activation ? Photon life:"+particle.getLife()+" coords:"+particle.getCoordx()+","+particle.getCoordy()+" Transmuter:"+transmuters.get(i).getName()+" activation:"+transmuters.get(i).getActivationLevel()+" necessaire:"+needed); + if (needed<=particle.getLife()) { + particle.subLife(needed); + transmuters.get(i).Activate(); + Gdx.app.debug("wirechem-Grid", "Grid Cycle -> Activation OUI Photon life:"+particle.getLife()+" coords:"+particle.getCoordx()+","+particle.getCoordy()+" Transmuter:"+transmuters.get(i).getName()+" activation:"+transmuters.get(i).getActivationLevel()); + } + else + Gdx.app.debug("wirechem-Grid", "Grid Cycle -> Activation NON Photon life:"+particle.getLife()+" coords:"+particle.getCoordx()+","+particle.getCoordy()+" Transmuter:"+transmuters.get(i).getName()+" activation:"+transmuters.get(i).getActivationLevel()); } } } - if (!particle.isAlive()) { - Gdx.app.debug("wirechem-Particle", "coords:"+particle.getCoordx()+","+particle.getCoordy()+" killed & removed"); - particles.removeValue(particle, true); - } + } + else if (particle.getType()==Type.Electron) { + particle.Next(); + Transmuter trans=GetXY(particle.getCoordx(),particle.getCoordy()).Transmuter; + if (trans!=null && trans.getActivation()) + trans.Run(particle); + } + if (!particle.isAlive()) { + Gdx.app.debug("wirechem-Particle", "coords:"+particle.getCoordx()+","+particle.getCoordy()+" killed & removed"); + particles.removeValue(particle, true); } } } @@ -79,18 +95,25 @@ public class Grid implements Serializable,Cloneable { public void tiling_particle() { for (int x = 0; x < this.sizeX; x++) for (int y = 0; y < this.sizeY; y++) - if (GetXY(x, y).Fiber) - GetXY(x, y).Fiber_state = 0; + GetXY(x, y).Fiber_state = 0; for(Particle particle: particles) { if (particle.getType()==Type.Photon) { GetXY(particle.getCoordx(), particle.getCoordy()).Fiber_state=1+Math.floorDiv(Particle.PHOTONLIFE-particle.getLife(),Math.floorDiv(Particle.PHOTONLIFE,10)); Gdx.app.debug("wirechem-Grid", "Grid Tiling -> Photon state :"+GetXY(particle.getCoordx(), particle.getCoordy()).Fiber_state+":"+particle.getCoordx()+","+particle.getCoordy()); } + else if (particle.getType()==Type.Electron) { + int value=16; + if (particle.getCharge()==Charge.Positif) value+=1; + if (particle.getCharge()==Charge.Neutre) value+=2; + if (particle.getSize()==Size.Petit) value+=3; + GetXY(particle.getCoordx(), particle.getCoordy()).Fiber_state+=1000*value; + Gdx.app.debug("wirechem-Grid", "Grid Tiling -> Electron state :"+GetXY(particle.getCoordx(), particle.getCoordy()).Fiber_state+":"+particle.getCoordx()+","+particle.getCoordy()); + } } } //Initialise la simulation pour permettre ensuite de faire des cycles - public void Initialize() { + public void Initialize(Level level) { particles.clear(); this.tiling_particle(); particles.add(new Particle(this)); @@ -100,6 +123,8 @@ public class Grid implements Serializable,Cloneable { 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); @@ -108,10 +133,13 @@ public class Grid implements Serializable,Cloneable { for (int x = 0; x < this.sizeX; x++) for (int y = 0; y < this.sizeY; y++) if (GetXY(x, y).Transmuter!=null) { - GetXY(x, y).Transmuter.Unactivate(); transmuters.add(GetXY(x, y).Transmuter); transmuterscoords.add(new Vector2(x,y)); } + for(Transmuter transmuter:transmuters) { + transmuter.Unactivate(); + } + if (transmuters.size>0) transmuters.first().AttachLevel(level); } //Genère des tiles qui correspondent aux transmuteurs sur la grille diff --git a/core/src/fr/evolving/automata/Insufler100.java b/core/src/fr/evolving/automata/Insufler100.java index 8053dc0..26f125a 100644 --- a/core/src/fr/evolving/automata/Insufler100.java +++ b/core/src/fr/evolving/automata/Insufler100.java @@ -40,8 +40,8 @@ public class Insufler100 extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Insufler100(Level level) { - super(level); + public Insufler100() { + super(); this.id=">100"; this.Name = AssetLoader.language.get("[insufler100-name]"); this.Desc = AssetLoader.language.get("[insufler100-desc]"); @@ -123,10 +123,10 @@ public class Insufler100 extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -191,7 +191,7 @@ public class Insufler100 extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Insufler33.java b/core/src/fr/evolving/automata/Insufler33.java index a561e32..832e659 100644 --- a/core/src/fr/evolving/automata/Insufler33.java +++ b/core/src/fr/evolving/automata/Insufler33.java @@ -39,8 +39,8 @@ public class Insufler33 extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Insufler33(Level level) { - super(level); + public Insufler33() { + super(); this.id=">33"; this.Name = AssetLoader.language.get("[insufler33-name]"); this.Desc = AssetLoader.language.get("[insufler33-desc]"); @@ -50,8 +50,8 @@ public class Insufler33 extends Transmuter { this.Research = 0; this.Upgrade = null; this.Unlock = new Array(); - this.Unlock.add(new Insufler100(null)); - this.Unlock.add(new Insufler50(null)); + this.Unlock.add(new Insufler100()); + this.Unlock.add(new Insufler50()); this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = false; @@ -124,10 +124,10 @@ public class Insufler33 extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -192,7 +192,7 @@ public class Insufler33 extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Insufler50.java b/core/src/fr/evolving/automata/Insufler50.java index 20d0f64..5d761ae 100644 --- a/core/src/fr/evolving/automata/Insufler50.java +++ b/core/src/fr/evolving/automata/Insufler50.java @@ -39,8 +39,8 @@ public class Insufler50 extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Insufler50(Level level) { - super(level); + public Insufler50() { + super(); this.id=">50"; this.Name = AssetLoader.language.get("[insufler50-name]"); this.Desc = AssetLoader.language.get("[insufler50-desc]"); @@ -50,7 +50,7 @@ public class Insufler50 extends Transmuter { this.Research = 120; this.Upgrade = null; this.Unlock = new Array(); - this.Unlock.add(new Insufler100(null)); + this.Unlock.add(new Insufler100()); this.showed = false; this.CanUpgradeTemp = true; this.CanUpgradeCycle = false; @@ -123,10 +123,10 @@ public class Insufler50 extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -191,7 +191,7 @@ public class Insufler50 extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Inverter_I.java b/core/src/fr/evolving/automata/Inverter_I.java index 5d9c112..54e05f4 100644 --- a/core/src/fr/evolving/automata/Inverter_I.java +++ b/core/src/fr/evolving/automata/Inverter_I.java @@ -39,8 +39,8 @@ public class Inverter_I extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Inverter_I(Level level) { - super(level); + public Inverter_I() { + super(); this.id="+-"; this.Name = AssetLoader.language.get("[inverteri-name]"); this.Desc = AssetLoader.language.get("[inverteri-desc]"); @@ -48,7 +48,7 @@ public class Inverter_I extends Transmuter { this.Price = 25; this.Technology = 1; this.Research = 0; - this.Upgrade = new Inverter_II(level); + this.Upgrade = new Inverter_II(); this.Unlock = null; this.showed = true; this.CanUpgradeTemp = true; @@ -106,10 +106,10 @@ public class Inverter_I extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -174,7 +174,7 @@ public class Inverter_I extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Inverter_II.java b/core/src/fr/evolving/automata/Inverter_II.java index 68389cf..c3210d7 100644 --- a/core/src/fr/evolving/automata/Inverter_II.java +++ b/core/src/fr/evolving/automata/Inverter_II.java @@ -39,8 +39,8 @@ public class Inverter_II extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Inverter_II(Level level) { - super(level); + public Inverter_II() { + super(); this.id="+-+-"; this.Name = AssetLoader.language.get("[inverterii-name]"); this.Desc = AssetLoader.language.get("[inverterii-desc]"); @@ -105,10 +105,10 @@ public class Inverter_II extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -173,7 +173,7 @@ public class Inverter_II extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Negativer.java b/core/src/fr/evolving/automata/Negativer.java index e91711b..1b390cd 100644 --- a/core/src/fr/evolving/automata/Negativer.java +++ b/core/src/fr/evolving/automata/Negativer.java @@ -39,8 +39,8 @@ public class Negativer extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Negativer(Level level) { - super(level); + public Negativer() { + super(); this.id="-/"; this.Name = AssetLoader.language.get("[negativer-name]"); this.Desc = AssetLoader.language.get("[negativer-desc]"); @@ -106,10 +106,10 @@ public class Negativer extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -174,7 +174,7 @@ public class Negativer extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Negativer_I.java b/core/src/fr/evolving/automata/Negativer_I.java index ec302f2..af72000 100644 --- a/core/src/fr/evolving/automata/Negativer_I.java +++ b/core/src/fr/evolving/automata/Negativer_I.java @@ -39,8 +39,8 @@ public class Negativer_I extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Negativer_I(Level level) { - super(level); + public Negativer_I() { + super(); this.id="-"; this.Name = AssetLoader.language.get("[negativeri-name]"); this.Desc = AssetLoader.language.get("[negativeri-desc]"); @@ -48,7 +48,7 @@ public class Negativer_I extends Transmuter { this.Price = 50; this.Technology = 4; this.Research = 0; - this.Upgrade = new Negativer_II(level); + this.Upgrade = new Negativer_II(); this.Unlock = null; this.showed = true; this.CanUpgradeTemp = true; @@ -108,10 +108,10 @@ public class Negativer_I extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -176,7 +176,7 @@ public class Negativer_I extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Negativer_II.java b/core/src/fr/evolving/automata/Negativer_II.java index 3ea6b02..713295e 100644 --- a/core/src/fr/evolving/automata/Negativer_II.java +++ b/core/src/fr/evolving/automata/Negativer_II.java @@ -39,8 +39,8 @@ public class Negativer_II extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Negativer_II(Level level) { - super(level); + public Negativer_II() { + super(); this.id="--"; this.Name = AssetLoader.language.get("[negativerii-name]"); this.Desc = AssetLoader.language.get("[negativerii-desc]"); @@ -48,7 +48,7 @@ public class Negativer_II extends Transmuter { this.Price = 100; this.Technology = 4; this.Research = 40; - this.Upgrade = new Negativer_III(level); + this.Upgrade = new Negativer_III(); this.Unlock = null; this.showed = false; this.CanUpgradeTemp = true; @@ -108,10 +108,10 @@ public class Negativer_II extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -176,7 +176,7 @@ public class Negativer_II extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Negativer_III.java b/core/src/fr/evolving/automata/Negativer_III.java index 04d44b7..d02d39b 100644 --- a/core/src/fr/evolving/automata/Negativer_III.java +++ b/core/src/fr/evolving/automata/Negativer_III.java @@ -39,8 +39,8 @@ public class Negativer_III extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Negativer_III(Level level) { - super(level); + public Negativer_III() { + super(); this.id="---"; this.Name = AssetLoader.language.get("[negativeriii-name]"); this.Desc = AssetLoader.language.get("[negativeriii-desc]"); @@ -106,10 +106,10 @@ public class Negativer_III extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -174,7 +174,7 @@ public class Negativer_III extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Neutraliser_I.java b/core/src/fr/evolving/automata/Neutraliser_I.java index 6b0a3ea..c5a346d 100644 --- a/core/src/fr/evolving/automata/Neutraliser_I.java +++ b/core/src/fr/evolving/automata/Neutraliser_I.java @@ -39,8 +39,8 @@ public class Neutraliser_I extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Neutraliser_I(Level level) { - super(level); + public Neutraliser_I() { + super(); this.id="0"; this.Name = AssetLoader.language.get("[neutraliseri-name]"); this.Desc = AssetLoader.language.get("[neutraliseri-desc]"); @@ -48,7 +48,7 @@ public class Neutraliser_I extends Transmuter { this.Price = 20; this.Technology = 4; this.Research = 0; - this.Upgrade = new Neutraliser_II(level);; + this.Upgrade = new Neutraliser_II();; this.Unlock = null; this.showed = true; this.CanUpgradeTemp = true; @@ -106,10 +106,10 @@ public class Neutraliser_I extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -174,7 +174,7 @@ public class Neutraliser_I extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Neutraliser_II.java b/core/src/fr/evolving/automata/Neutraliser_II.java index a6684fc..5a7dc89 100644 --- a/core/src/fr/evolving/automata/Neutraliser_II.java +++ b/core/src/fr/evolving/automata/Neutraliser_II.java @@ -39,8 +39,8 @@ public class Neutraliser_II extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Neutraliser_II(Level level) { - super(level); + public Neutraliser_II() { + super(); this.id="00"; this.Name = AssetLoader.language.get("[neutraliserii-name]"); this.Desc = AssetLoader.language.get("[neutraliserii-desc]"); @@ -106,10 +106,10 @@ public class Neutraliser_II extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -174,7 +174,7 @@ public class Neutraliser_II extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Oneway.java b/core/src/fr/evolving/automata/Oneway.java index 467a5c9..b560a7d 100644 --- a/core/src/fr/evolving/automata/Oneway.java +++ b/core/src/fr/evolving/automata/Oneway.java @@ -39,8 +39,8 @@ public class Oneway extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Oneway(Level level) { - super(level); + public Oneway() { + super(); this.id=">"; this.Name = AssetLoader.language.get("[oneway-name]"); this.Desc = AssetLoader.language.get("[oneway-desc]"); @@ -50,7 +50,7 @@ public class Oneway extends Transmuter { this.Research = 0; this.Upgrade = null; this.Unlock = new Array(); - this.Unlock.add(new distributor(level)); + this.Unlock.add(new distributor()); this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = false; @@ -107,10 +107,10 @@ public class Oneway extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -175,7 +175,7 @@ public class Oneway extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Particle.java b/core/src/fr/evolving/automata/Particle.java index 1a6c6b8..851333a 100644 --- a/core/src/fr/evolving/automata/Particle.java +++ b/core/src/fr/evolving/automata/Particle.java @@ -2,13 +2,14 @@ package fr.evolving.automata; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.Array; public class Particle { public enum Type { Electron, Photon, Proton, Neutron } public enum Orientation { - N, S, E, O, NE, SE, NO, SO + N, S, E, O, NE, SE, NO, SO, Fixed, Kill }; public enum Size { Gros, Petit @@ -17,7 +18,7 @@ public class Particle { Positif, Negatif, Neutre }; - public final static int PHOTONLIFE=200; + public final static int PHOTONLIFE=250; private Orientation oldorientation; private Orientation orientation; @@ -32,6 +33,7 @@ public class Particle { static private Grid grid; public Particle(Grid grid) { + this.life=PHOTONLIFE; this.Alive=true; this.type=Type.Electron; this.orientation=Orientation.E; @@ -141,87 +143,95 @@ public class Particle { this.charge=Charge.Negatif; } - private Vector2 testorientation(Orientation orientation) { + private Vector2 TestOrientation(Orientation orientation, Type type) { int movex=0,movey=0; + if (orientation==Orientation.Kill || orientation==Orientation.Fixed) return new Vector2(movex,movey); 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 (this.grid.GetXY(this.coordX+movex, this.coordY+movey)!=null && this.grid.GetXY(this.coordX+movex, this.coordY+movey).Fiber) - return new Vector2(movex,movey); + if (this.grid.GetXY(this.coordX+movex, this.coordY+movey)!=null) { + if (type==Type.Photon && !this.grid.GetXY(this.coordX+movex, this.coordY+movey).Fiber) + return null; + if (type==Type.Electron && (!this.grid.GetXY(this.coordX+movex, this.coordY+movey).Copper)) + return null; + } + else + return null; + return new Vector2(movex,movey); + } + + private Orientation[] getOrientations(Orientation orientation, Type type) { + if (type==Type.Photon) { + switch (orientation) { + case E: + return new Orientation[]{Orientation.E,Orientation.NE,Orientation.SE, Orientation.Kill}; + case NE: + return new Orientation[]{Orientation.NE,Orientation.N,Orientation.E, Orientation.Kill}; + case N: + return new Orientation[]{Orientation.N,Orientation.NE,Orientation.NO, Orientation.Kill}; + case NO: + return new Orientation[]{Orientation.NO,Orientation.N,Orientation.O, Orientation.Kill}; + case O: + return new Orientation[]{Orientation.O,Orientation.NO,Orientation.SO, Orientation.Kill}; + case SO: + return new Orientation[]{Orientation.SO,Orientation.S,Orientation.O, Orientation.Kill}; + case S: + return new Orientation[]{Orientation.S,Orientation.SE,Orientation.SO, Orientation.Kill}; + case SE: + default: + return new Orientation[]{Orientation.SE,Orientation.E,Orientation.S, Orientation.Kill}; + } + } + else if (type==Type.Electron) { + switch (orientation) { + case E: + return new Orientation[]{Orientation.E,Orientation.N,Orientation.S,Orientation.O,Orientation.Fixed}; + case N: + return new Orientation[]{Orientation.N,Orientation.O,Orientation.E,Orientation.S,Orientation.Fixed}; + case S: + return new Orientation[]{Orientation.S,Orientation.E,Orientation.O,Orientation.N,Orientation.Fixed}; + case O: + return new Orientation[]{Orientation.O,Orientation.N,Orientation.S,Orientation.E,Orientation.Fixed}; + case Fixed: + default: + return new Orientation[]{Orientation.N,Orientation.S,Orientation.E,Orientation.O,Orientation.Fixed}; + } + } else return null; } - private Orientation[] get_orientations(Orientation orientation) { - if (orientation==Orientation.E) - return new Orientation[]{Orientation.E,Orientation.NE,Orientation.SE}; - if (orientation==Orientation.NE) - return new Orientation[]{Orientation.NE,Orientation.N,Orientation.E}; - if (orientation==Orientation.N) - return new Orientation[]{Orientation.N,Orientation.NE,Orientation.NO}; - if (orientation==Orientation.NO) - return new Orientation[]{Orientation.NO,Orientation.N,Orientation.O}; - if (orientation==Orientation.O) - return new Orientation[]{Orientation.O,Orientation.NO,Orientation.SO}; - if (orientation==Orientation.SO) - return new Orientation[]{Orientation.SO,Orientation.S,Orientation.O}; - if (orientation==Orientation.S) - return new Orientation[]{Orientation.S,Orientation.SE,Orientation.SO}; - if (orientation==Orientation.SE) - return new Orientation[]{Orientation.SE,Orientation.E,Orientation.S}; - return new Orientation[]{Orientation.SE,Orientation.E,Orientation.S}; - } - public void Next() { - this.life++; + if (this.life>0) this.life--; + if (type==Type.Photon && life==0) this.kill(); Vector2 move=null; - Orientation neworientation=this.orientation; - if (type==Type.Photon) { - if (life>=PHOTONLIFE) this.kill(); - Orientation[] orientations=get_orientations(this.orientation); - Vector2 soluce0=testorientation(orientations[0]); - Vector2 soluce1=testorientation(orientations[1]); - Vector2 soluce2=testorientation(orientations[2]); - if (soluce0!=null) { - neworientation=orientations[0]; - move=soluce0; - } - else if (soluce1!=null && soluce2!=null) { - if (orientations[1]==oldorientation) { - neworientation=orientations[1]; - move=soluce1; + Orientation[] orientations=getOrientations(this.orientation, type); + Array orientations_good=new Array(); + 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; + else { + for(Orientation orientationtest2:orientations_good) { + if (orientationtest2==Orientation.Kill) { + Gdx.app.debug("wirechem-Particle", "coords:"+this.coordX+","+this.coordY+" killed no place to go"); + this.kill(); + return; } - else - { - neworientation=orientations[2]; - move=soluce2; + else { + orientation=orientationtest2; + break; } + } } - else if (soluce1!=null) { - neworientation=orientations[1]; - move=soluce1; - } - else if (soluce2!=null) { - neworientation=orientations[2]; - move=soluce2; - } - if (move==null) - { - Gdx.app.debug("wirechem-Particle", "coords:"+this.coordX+","+this.coordY+" killed no place to go"); - this.kill(); - } - else - { - Gdx.app.debug("wirechem-Particle", "coords:"+this.coordX+","+this.coordY+" move to "+orientation+":"+move.x+","+move.y+" life:"+this.life); - if (orientation!=neworientation) - oldorientation=orientation; - orientation=neworientation; - this.coordX+=move.x; - this.coordY+=move.y; - } + move=TestOrientation(orientation,type); + 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; } - } - } \ 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 6d3d596..72ea470 100644 --- a/core/src/fr/evolving/automata/Positiver.java +++ b/core/src/fr/evolving/automata/Positiver.java @@ -39,8 +39,8 @@ public class Positiver extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Positiver(Level level) { - super(level); + public Positiver() { + super(); this.id="+/"; this.Name = AssetLoader.language.get("[positiver-name]"); this.Desc = AssetLoader.language.get("[positiver-desc]"); @@ -106,10 +106,10 @@ public class Positiver extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -174,7 +174,7 @@ public class Positiver extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Positiver_I.java b/core/src/fr/evolving/automata/Positiver_I.java index 0e40098..aa37729 100644 --- a/core/src/fr/evolving/automata/Positiver_I.java +++ b/core/src/fr/evolving/automata/Positiver_I.java @@ -39,8 +39,8 @@ public class Positiver_I extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Positiver_I(Level level) { - super(level); + public Positiver_I() { + super(); this.id="+"; this.Name = AssetLoader.language.get("[positiveri-name]"); this.Desc = AssetLoader.language.get("[positiveri-desc]"); @@ -48,7 +48,7 @@ public class Positiver_I extends Transmuter { this.Price = 50; this.Technology = 2; this.Research = 0; - this.Upgrade = new Positiver_II(level); + this.Upgrade = new Positiver_II(); this.Unlock = null; this.showed = true; this.CanUpgradeTemp = true; @@ -108,13 +108,14 @@ public class Positiver_I extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; + particle.ChargePositive(); } public void Unactivate() { @@ -176,7 +177,7 @@ public class Positiver_I extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Positiver_II.java b/core/src/fr/evolving/automata/Positiver_II.java index a267643..9b93824 100644 --- a/core/src/fr/evolving/automata/Positiver_II.java +++ b/core/src/fr/evolving/automata/Positiver_II.java @@ -39,8 +39,8 @@ public class Positiver_II extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Positiver_II(Level level) { - super(level); + public Positiver_II() { + super(); this.id="++"; this.Name = AssetLoader.language.get("[positiverii-name]"); this.Desc = AssetLoader.language.get("[positiverii-desc]"); @@ -48,7 +48,7 @@ public class Positiver_II extends Transmuter { this.Price = 100; this.Technology = 2; this.Research = 40; - this.Upgrade = new Positiver_III(level); + this.Upgrade = new Positiver_III(); this.Unlock = null; this.showed = false; this.CanUpgradeTemp = true; @@ -108,10 +108,10 @@ public class Positiver_II extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -176,7 +176,7 @@ public class Positiver_II extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Positiver_III.java b/core/src/fr/evolving/automata/Positiver_III.java index bff4708..3d58158 100644 --- a/core/src/fr/evolving/automata/Positiver_III.java +++ b/core/src/fr/evolving/automata/Positiver_III.java @@ -38,8 +38,8 @@ public class Positiver_III extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public Positiver_III(Level level) { - super(level); + public Positiver_III() { + super(); this.id="+++"; this.Name = AssetLoader.language.get("[positiveriii-name]"); this.Desc = AssetLoader.language.get("[positiveriii-desc]"); @@ -105,10 +105,10 @@ public class Positiver_III extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -173,7 +173,7 @@ public class Positiver_III extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/automata/Transmuter.java b/core/src/fr/evolving/automata/Transmuter.java index c08f5b7..9d4b46b 100644 --- a/core/src/fr/evolving/automata/Transmuter.java +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -39,10 +39,13 @@ public abstract class Transmuter implements Cloneable, Serializable { public enum Angular { A00, A90, A180, A270 }; - - protected transient Level level; - protected Angular Rotation; + final static public int ACTIVATION_LIFE=50; + + protected static transient Level level; + + protected Cell cell; + protected Angular Rotation; protected boolean temp_showed; protected float temp_UpgradedNrj; protected float temp_UpgradedRayon; @@ -57,8 +60,19 @@ public abstract class Transmuter implements Cloneable, Serializable { this.temp_UpgradedNrj=temp_UpgradedNrj; } - public Transmuter(Level level) { - this.level = level; + public void AttachLevel(Level level) { + Transmuter.level=level; + } + + public void SetCell(Cell cell) { + this.cell=cell; + } + + public Cell getCell() { + return this.cell; + } + + public Transmuter() { this.Rotation = Angular.A00; } @@ -87,7 +101,7 @@ public abstract class Transmuter implements Cloneable, Serializable { public void ProcessCycle() { } - public void Run() { + public void Run(Particle particle) { } public void Activate() { @@ -174,6 +188,13 @@ public abstract class Transmuter implements Cloneable, Serializable { this.SetShowed(false); } + /** + * Verifie que le transmuteur est bien ameliorable + * + * @param value Point de recherche donnee pour verifier l'amélioration + * @return True si l'amelioration est possible + * @see Transmuter + */ public boolean isUpgradable(int value) { Transmuter transmuter=this.getUpgrade(); return transmuter!= null && !transmuter.isShowed() && (transmuter.getResearch()<=value || value==-1); diff --git a/core/src/fr/evolving/automata/distributor.java b/core/src/fr/evolving/automata/distributor.java index 0080d08..d5e904f 100644 --- a/core/src/fr/evolving/automata/distributor.java +++ b/core/src/fr/evolving/automata/distributor.java @@ -39,8 +39,8 @@ public class distributor extends Transmuter { private static OrderedMap Tilestype; private static OrderedMap Tilesid; - public distributor(Level level) { - super(level); + public distributor() { + super(); this.id="<>"; this.Name = AssetLoader.language.get("[distributer-name]"); this.Desc = AssetLoader.language.get("[distributer-desc]"); @@ -114,10 +114,10 @@ public class distributor extends Transmuter { this.level.Rayon += TurnRayon * UpgradedRayon; this.level.Nrj += TurnNrj * UpgradedNrj; if (this.Activable) - this.ActivationLevel -= 1; + if (this.ActivationLevel>0) this.ActivationLevel -= 1; } - public void Run() { + public void Run(Particle particle) { this.level.Temp += UsedTemp * UpgradedTemp; this.level.Rayon += UsedRayon * UpgradedRayon; this.level.Nrj += UsedNrj * UpgradedNrj; @@ -182,7 +182,7 @@ public class distributor extends Transmuter { } public int getMaxActivationLevel() { - return (int) (10 * this.UpgradedCycle); + return (int) (Transmuter.ACTIVATION_LIFE * this.UpgradedCycle); } public int getActivationLevel() { diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index 14f03de..2f8c275 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -862,18 +862,19 @@ public class GameScreen implements Screen { if (worlds.getState()==State.stop) { worlds.simulate(); Gdx.app.log("wirechem-GameScreen", "***** Mode run."); - worlds.getLevelData().Grid.Initialize(); + worlds.getLevelData().Grid.Initialize(worlds.getLevelData()); worlds.getLevelData().Grid.tiling_particle(); - RunTimer.start(); } + RunTimer.start(); } public void stop_mode() { Gdx.app.log("wirechem-GameScreen", "***** Mode stop."); worlds.stop(); - worlds.getLevelData().Grid.Initialize(); + worlds.getLevelData().Grid.Initialize(worlds.getLevelData()); worlds.getLevelData().Grid.tiling_particle(); RunTimer.stop(); + map.tempclear(new int[]{3,4,5}); } public void pause_mode() {