diff --git a/core/src/fr/evolving/automata/Level.java b/core/src/fr/evolving/automata/Level.java index 9cd13a1..4fecdb4 100644 --- a/core/src/fr/evolving/automata/Level.java +++ b/core/src/fr/evolving/automata/Level.java @@ -6,20 +6,12 @@ public class Level implements Serializable { public String Name; public String Description; public String Element; - public transient int[] Current; - public int[] Victory; public int aWorld; public int aLevel; public int id; public float X; public float Y; public int Tech; - public int Cout; - public Grid Grid_orig; - public int Cycle_orig; - public int Temp_orig; - public int Rayon_orig; - public int Nrj_orig; public int Maxcycle; public int Maxtemp; public int Maxrayon; @@ -29,13 +21,23 @@ public class Level implements Serializable { public String Tuto; public int[][] Link; + public int[] Victory_orig; + public int Cout_orig; + public Grid Grid_orig; + public int Cycle_orig; + public int Temp_orig; + public int Rayon_orig; + public int Nrj_orig; + + public transient int[] Victory; + 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 boolean Locked; - public transient boolean Locked_old; public Level(int aWorld, int aLevel, int id, String Name, String Description, String Element, int[] Current, int[] Victory, @@ -48,12 +50,12 @@ public class Level implements Serializable { this.Name = Name; this.Description = Description; this.Element = Element; - this.Current = Current; - this.Victory = Victory; + this.Victory = Current; + this.Victory_orig = Victory; this.X = X; this.Y = Y; this.Tech = Tech; - this.Cout = Cout; + this.Cout_orig = Cout; this.Grid = World; this.Grid_orig = World; this.Cycle = Cycle; diff --git a/core/src/fr/evolving/automata/Worlds.java b/core/src/fr/evolving/automata/Worlds.java index 9ed088b..07d370e 100644 --- a/core/src/fr/evolving/automata/Worlds.java +++ b/core/src/fr/evolving/automata/Worlds.java @@ -144,6 +144,7 @@ public class Worlds extends Actor { } public void updateUnlockLevels() { + if (levels!=null) for(Level level:levels) if (level!=null) level.Locked=AssetLoader.Datahandler.user().getLevellock(0, level.id); @@ -153,6 +154,28 @@ public class Worlds extends Actor { return state; } + public void prepareLevel(boolean force) { + Gdx.app.debug(getClass().getSimpleName(),"Récupération des conditions initiales."); + usedlevel.Cout=usedlevel.Cout_orig; + usedlevel.Cycle=usedlevel.Cycle_orig; + usedlevel.Temp=usedlevel.Temp_orig; + usedlevel.Rayon=usedlevel.Rayon_orig; + usedlevel.Nrj=usedlevel.Nrj_orig; + usedlevel.Victory=usedlevel.Victory_orig.clone(); + Gdx.app.debug(getClass().getSimpleName(),"Récupération des derniers niveaux."); + ReadLastGrid(); + if (usedlevel.Grid == null || force) { + Gdx.app.debug(getClass().getSimpleName(), "Copie monde original."); + usedlevel.Grid = usedlevel.Grid_orig; + + } else { + Gdx.app.debug(getClass().getSimpleName(), + "Récupération de la dernière grille."); + usedlevel.Grid.tiling_copper(); + usedlevel.Grid.tiling_transmuter(); + } + } + public void setLevel(int alevel) { if (state!=State.notloaded) if (usedworld>=0) { @@ -171,7 +194,10 @@ public class Worlds extends Actor { } public int getLevel() { - return usedlevel.aLevel; + if (usedlevel!=null) + return usedlevel.aLevel; + else + return 0; } public void delLevel() { diff --git a/core/src/fr/evolving/renderers/LevelRenderer.java b/core/src/fr/evolving/renderers/LevelRenderer.java index 795779f..57cd461 100644 --- a/core/src/fr/evolving/renderers/LevelRenderer.java +++ b/core/src/fr/evolving/renderers/LevelRenderer.java @@ -91,7 +91,7 @@ public class LevelRenderer { if (LevelScreen.selected.level.Tech > 0) font.draw(batcher2, this.reward, 1215, AssetLoader.height - 15); - if (LevelScreen.selected.level.Cout > 0) { + if (LevelScreen.selected.level.Cout_orig > 0) { font.draw(batcher2, this.ressource, 1215, 145); font.draw(batcher2, this.goal, 1215, 295); } @@ -108,7 +108,7 @@ public class LevelRenderer { shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f); if (LevelScreen.selected != null) { shapeRenderer.rect(10, 10, 1190, 165); - if (LevelScreen.selected.level.Cout > 0) { + if (LevelScreen.selected.level.Cout_orig > 0) { shapeRenderer.rect(1210, 10, 250, 140); shapeRenderer.rect(1210, 160, 250, 140); } diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index e27a8a2..86ab07d 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -203,6 +203,7 @@ public class GameScreen implements Screen { public GameScreen(Worlds aworlds) { Gdx.app.debug(getClass().getSimpleName(),"Préparation du screen"); this.worlds = aworlds; + this.worlds.prepareLevel(false); this.level=worlds.getInformations(); if (level.Tech<1) tocreate = new String[] { "run", "stop", "speed", "separator", "move#", "zoomp#","zoomm#", "separator", "levels", "exits", "separator", "screen", "sound", "settings" }; @@ -210,18 +211,6 @@ public class GameScreen implements Screen { tocreate = new String[] { "run", "stop", "speed", "separator", "move#", "zoomp#","zoomm#", "infos#", "separator", "raz", "save", "levels", "exits", "separator", "screen", "sound", "grid", "settings" }; else tocreate = new String[] { "run", "stop", "speed", "separator", "move#", "zoomp#","zoomm#", "infos#", "separator", "raz", "save", "levels", "tree", "exits", "separator", "screen", "sound", "tuto", "grid", "settings", "separator", "stat" }; - Gdx.app.debug(getClass().getSimpleName(),"Récupération des derniers niveaux."); - worlds.ReadLastGrid(); - if (this.level.Grid == null) { - Gdx.app.debug(getClass().getSimpleName(), "Copie monde original."); - this.level.Grid = this.level.Grid_orig; - - } else { - Gdx.app.debug(getClass().getSimpleName(), - "Récupération de la dernière grille."); - this.level.Grid.tiling_copper(); - this.level.Grid.tiling_transmuter(); - } Gdx.app.debug(getClass().getSimpleName(),"Création des Barres verticales & horizontales."); horizbar=new HorizBarre(tocreate,"preparebarre"); horizbar.addListener(new ChangeListener() { @@ -275,9 +264,7 @@ public class GameScreen implements Screen { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.debug(getClass().getSimpleName(),"Remise à zéro du monde"); - GameScreen.this.level.Grid = GameScreen.this.level.Grid_orig; - level.Grid.tiling_copper(); - level.Grid.tiling_transmuter(); + worlds.prepareLevel(true); map.redraw(); buttonlevel.setChecked(false); } diff --git a/core/src/fr/evolving/screens/LevelScreen.java b/core/src/fr/evolving/screens/LevelScreen.java index de4c186..7fb1640 100644 --- a/core/src/fr/evolving/screens/LevelScreen.java +++ b/core/src/fr/evolving/screens/LevelScreen.java @@ -646,8 +646,8 @@ public class LevelScreen implements Screen { rayon.setVisible(true); } else rayon.setVisible(false); - if (button.level.Cout > 0) { - cout.setText(String.valueOf(button.level.Cout)); + if (button.level.Cout_orig > 0) { + cout.setText(String.valueOf(button.level.Cout_orig)); cout.setVisible(true); } else cout.setVisible(false); @@ -656,8 +656,8 @@ public class LevelScreen implements Screen { tech.setVisible(true); } else tech.setVisible(false); - Victory.setVisible(button.level.Cout > 0); - Victory.setVictory(button.level.Victory); + Victory.setVisible(button.level.Cout_orig > 0); + Victory.setVictory(button.level.Victory_orig); if (selected != null) selected.setChecked(false); selected = button;