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;
|
||||
|
||||
public class Cell implements Serializable {
|
||||
public class Cell implements Serializable,Cloneable {
|
||||
public int Fiber;
|
||||
public boolean Copper;
|
||||
public Transmuter Transmuter;
|
||||
|
||||
public transient int Copper_calc;
|
||||
public transient int Fiber_old;
|
||||
public Transmuter Transmuter;
|
||||
public transient int Transmuter_calc;
|
||||
public transient int Transmuter_movex;
|
||||
public transient int Transmuter_movey;
|
||||
|
@ -22,4 +23,12 @@ public class Cell implements Serializable {
|
|||
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.utils.ObjectMap.Entry;
|
||||
|
||||
public class Grid implements Serializable {
|
||||
public class Grid implements Serializable,Cloneable {
|
||||
public Cell[][] Cells;
|
||||
public Integer sizeX, sizeY;
|
||||
|
||||
|
@ -270,4 +270,12 @@ public class Grid implements Serializable {
|
|||
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,15 +166,15 @@ public class Worlds extends Actor {
|
|||
ReadLastGrid();
|
||||
if (usedlevel.Grid == null || force) {
|
||||
Gdx.app.debug(getClass().getSimpleName(), "Copie monde original.");
|
||||
usedlevel.Grid = usedlevel.Grid_orig;
|
||||
usedlevel.Grid = (Grid)usedlevel.Grid_orig.clone();
|
||||
|
||||
} else {
|
||||
Gdx.app.debug(getClass().getSimpleName(),
|
||||
"Récupération de la dernière grille.");
|
||||
Gdx.app.debug(getClass().getSimpleName(),"Récupération de la dernière grille.");
|
||||
ReadLastGrid();
|
||||
}
|
||||
usedlevel.Grid.tiling_copper();
|
||||
usedlevel.Grid.tiling_transmuter();
|
||||
}
|
||||
}
|
||||
|
||||
public void setLevel(int alevel) {
|
||||
if (state!=State.notloaded)
|
||||
|
|
|
@ -201,7 +201,9 @@ public class LevelScreen implements Screen {
|
|||
}
|
||||
buttonLevels = null;
|
||||
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.Name.isEmpty())
|
||||
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)
|
||||
selected=buttonLevels[0];
|
||||
if (selected!=null) {
|
||||
selected.setChecked(true);
|
||||
buttonPlay.setVisible(true);
|
||||
TextDescriptive.setVisible(true);
|
||||
showlevel(selected);
|
||||
}
|
||||
Previous.setVisible(!worlds.isFirstWorld());
|
||||
if (worlds.isDebug())
|
||||
Next.setVisible(!worlds.isRealLastWorld());
|
||||
else
|
||||
Next.setVisible(!worlds.isLastWorld());
|
||||
buttonPlay.setVisible(true);
|
||||
TextDescriptive.setVisible(true);
|
||||
}
|
||||
else {
|
||||
Previous.setVisible(false);
|
||||
|
@ -623,8 +627,9 @@ public class LevelScreen implements Screen {
|
|||
}
|
||||
|
||||
public void showlevel(ButtonLevel button) {
|
||||
Gdx.app.debug(getClass().getSimpleName(), "Reading button "
|
||||
+ button.level.Name);
|
||||
if (button==null)
|
||||
return;
|
||||
Gdx.app.debug(getClass().getSimpleName(), "Reading button " + button.level.Name);
|
||||
TextDescriptive.setText(button.level.Description);
|
||||
if (button.level.Maxcycle < 99999 && button.level.Maxcycle > 0) {
|
||||
cycle.setText(String.valueOf(button.level.Maxcycle));
|
||||
|
|
Loading…
Reference in New Issue