feat: modification permettant de cloner réellement les cells et les grids.
This commit is contained in:
parent
9a537e2839
commit
7a9d8aeb01
|
@ -2,12 +2,13 @@ package fr.evolving.automata;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class Cell implements Serializable {
|
public class Cell implements Serializable,Cloneable {
|
||||||
public int Fiber;
|
public int Fiber;
|
||||||
public boolean Copper;
|
public boolean Copper;
|
||||||
|
public Transmuter Transmuter;
|
||||||
|
|
||||||
public transient int Copper_calc;
|
public transient int Copper_calc;
|
||||||
public transient int Fiber_old;
|
public transient int Fiber_old;
|
||||||
public Transmuter Transmuter;
|
|
||||||
public transient int Transmuter_calc;
|
public transient int Transmuter_calc;
|
||||||
public transient int Transmuter_movex;
|
public transient int Transmuter_movex;
|
||||||
public transient int Transmuter_movey;
|
public transient int Transmuter_movey;
|
||||||
|
@ -22,4 +23,12 @@ public class Cell implements Serializable {
|
||||||
this.Transmuter_movey = 0;
|
this.Transmuter_movey = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
Cell result = new Cell();
|
||||||
|
result.Copper=this.Copper;
|
||||||
|
result.Fiber=this.Fiber;
|
||||||
|
if (this.Transmuter!=null)
|
||||||
|
result.Transmuter=(Transmuter)this.Transmuter.clone();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.ObjectMap.Entry;
|
import com.badlogic.gdx.utils.ObjectMap.Entry;
|
||||||
|
|
||||||
public class Grid implements Serializable {
|
public class Grid implements Serializable,Cloneable {
|
||||||
public Cell[][] Cells;
|
public Cell[][] Cells;
|
||||||
public Integer sizeX, sizeY;
|
public Integer sizeX, sizeY;
|
||||||
|
|
||||||
|
@ -270,4 +270,12 @@ public class Grid implements Serializable {
|
||||||
return cell.Copper_calc;
|
return cell.Copper_calc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object clone() {
|
||||||
|
Grid result = new Grid(this.sizeX,this.sizeY);
|
||||||
|
for (int x = 0; x < this.sizeX; x++)
|
||||||
|
for (int y = 0; y < this.sizeY; y++)
|
||||||
|
result.Cells[x][y] = (Cell)this.Cells[x][y].clone();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,14 +166,14 @@ public class Worlds extends Actor {
|
||||||
ReadLastGrid();
|
ReadLastGrid();
|
||||||
if (usedlevel.Grid == null || force) {
|
if (usedlevel.Grid == null || force) {
|
||||||
Gdx.app.debug(getClass().getSimpleName(), "Copie monde original.");
|
Gdx.app.debug(getClass().getSimpleName(), "Copie monde original.");
|
||||||
usedlevel.Grid = usedlevel.Grid_orig;
|
usedlevel.Grid = (Grid)usedlevel.Grid_orig.clone();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Gdx.app.debug(getClass().getSimpleName(),
|
Gdx.app.debug(getClass().getSimpleName(),"Récupération de la dernière grille.");
|
||||||
"Récupération de la dernière grille.");
|
ReadLastGrid();
|
||||||
usedlevel.Grid.tiling_copper();
|
|
||||||
usedlevel.Grid.tiling_transmuter();
|
|
||||||
}
|
}
|
||||||
|
usedlevel.Grid.tiling_copper();
|
||||||
|
usedlevel.Grid.tiling_transmuter();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(int alevel) {
|
public void setLevel(int alevel) {
|
||||||
|
|
|
@ -201,7 +201,9 @@ public class LevelScreen implements Screen {
|
||||||
}
|
}
|
||||||
buttonLevels = null;
|
buttonLevels = null;
|
||||||
buttonLevels = new ButtonLevel[10];
|
buttonLevels = new ButtonLevel[10];
|
||||||
for (Level level : worlds.getLevels()) {
|
Array<Level> levels=worlds.getLevels();
|
||||||
|
if (levels!=null)
|
||||||
|
for (Level level : levels) {
|
||||||
if (level != null) {
|
if (level != null) {
|
||||||
if (level.Name.isEmpty())
|
if (level.Name.isEmpty())
|
||||||
level.Name=AssetLoader.language.get("[level"+(level.aWorld+1)+"/"+(level.aLevel+1)+"-name]");
|
level.Name=AssetLoader.language.get("[level"+(level.aWorld+1)+"/"+(level.aLevel+1)+"-name]");
|
||||||
|
@ -268,15 +270,17 @@ public class LevelScreen implements Screen {
|
||||||
}
|
}
|
||||||
if (worlds.getInformations()==null)
|
if (worlds.getInformations()==null)
|
||||||
selected=buttonLevels[0];
|
selected=buttonLevels[0];
|
||||||
selected.setChecked(true);
|
if (selected!=null) {
|
||||||
showlevel(selected);
|
selected.setChecked(true);
|
||||||
|
buttonPlay.setVisible(true);
|
||||||
|
TextDescriptive.setVisible(true);
|
||||||
|
showlevel(selected);
|
||||||
|
}
|
||||||
Previous.setVisible(!worlds.isFirstWorld());
|
Previous.setVisible(!worlds.isFirstWorld());
|
||||||
if (worlds.isDebug())
|
if (worlds.isDebug())
|
||||||
Next.setVisible(!worlds.isRealLastWorld());
|
Next.setVisible(!worlds.isRealLastWorld());
|
||||||
else
|
else
|
||||||
Next.setVisible(!worlds.isLastWorld());
|
Next.setVisible(!worlds.isLastWorld());
|
||||||
buttonPlay.setVisible(true);
|
|
||||||
TextDescriptive.setVisible(true);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Previous.setVisible(false);
|
Previous.setVisible(false);
|
||||||
|
@ -623,8 +627,9 @@ public class LevelScreen implements Screen {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showlevel(ButtonLevel button) {
|
public void showlevel(ButtonLevel button) {
|
||||||
Gdx.app.debug(getClass().getSimpleName(), "Reading button "
|
if (button==null)
|
||||||
+ button.level.Name);
|
return;
|
||||||
|
Gdx.app.debug(getClass().getSimpleName(), "Reading button " + button.level.Name);
|
||||||
TextDescriptive.setText(button.level.Description);
|
TextDescriptive.setText(button.level.Description);
|
||||||
if (button.level.Maxcycle < 99999 && button.level.Maxcycle > 0) {
|
if (button.level.Maxcycle < 99999 && button.level.Maxcycle > 0) {
|
||||||
cycle.setText(String.valueOf(button.level.Maxcycle));
|
cycle.setText(String.valueOf(button.level.Maxcycle));
|
||||||
|
|
Loading…
Reference in New Issue