feat: préparation de la gestion de l'argent

This commit is contained in:
Nicolas Hordé 2016-02-02 23:53:02 +01:00
parent fd74d60194
commit 487bf7d021
5 changed files with 49 additions and 34 deletions

View File

@ -6,20 +6,12 @@ public class Level implements Serializable {
public String Name; public String Name;
public String Description; public String Description;
public String Element; public String Element;
public transient int[] Current;
public int[] Victory;
public int aWorld; public int aWorld;
public int aLevel; public int aLevel;
public int id; public int id;
public float X; public float X;
public float Y; public float Y;
public int Tech; 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 Maxcycle;
public int Maxtemp; public int Maxtemp;
public int Maxrayon; public int Maxrayon;
@ -29,13 +21,23 @@ public class Level implements Serializable {
public String Tuto; public String Tuto;
public int[][] Link; 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 Grid Grid;
public transient int Cycle; public transient int Cycle;
public transient int Temp; public transient int Temp;
public transient int Rayon; public transient int Rayon;
public transient int Nrj; public transient int Nrj;
public transient boolean Locked; public transient boolean Locked;
public transient boolean Locked_old;
public Level(int aWorld, int aLevel, int id, String Name, public Level(int aWorld, int aLevel, int id, String Name,
String Description, String Element, int[] Current, int[] Victory, String Description, String Element, int[] Current, int[] Victory,
@ -48,12 +50,12 @@ public class Level implements Serializable {
this.Name = Name; this.Name = Name;
this.Description = Description; this.Description = Description;
this.Element = Element; this.Element = Element;
this.Current = Current; this.Victory = Current;
this.Victory = Victory; this.Victory_orig = Victory;
this.X = X; this.X = X;
this.Y = Y; this.Y = Y;
this.Tech = Tech; this.Tech = Tech;
this.Cout = Cout; this.Cout_orig = Cout;
this.Grid = World; this.Grid = World;
this.Grid_orig = World; this.Grid_orig = World;
this.Cycle = Cycle; this.Cycle = Cycle;

View File

@ -144,6 +144,7 @@ public class Worlds extends Actor {
} }
public void updateUnlockLevels() { public void updateUnlockLevels() {
if (levels!=null)
for(Level level:levels) for(Level level:levels)
if (level!=null) if (level!=null)
level.Locked=AssetLoader.Datahandler.user().getLevellock(0, level.id); level.Locked=AssetLoader.Datahandler.user().getLevellock(0, level.id);
@ -153,6 +154,28 @@ public class Worlds extends Actor {
return state; 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) { public void setLevel(int alevel) {
if (state!=State.notloaded) if (state!=State.notloaded)
if (usedworld>=0) { if (usedworld>=0) {
@ -171,7 +194,10 @@ public class Worlds extends Actor {
} }
public int getLevel() { public int getLevel() {
return usedlevel.aLevel; if (usedlevel!=null)
return usedlevel.aLevel;
else
return 0;
} }
public void delLevel() { public void delLevel() {

View File

@ -91,7 +91,7 @@ public class LevelRenderer {
if (LevelScreen.selected.level.Tech > 0) if (LevelScreen.selected.level.Tech > 0)
font.draw(batcher2, this.reward, 1215, font.draw(batcher2, this.reward, 1215,
AssetLoader.height - 15); 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.ressource, 1215, 145);
font.draw(batcher2, this.goal, 1215, 295); font.draw(batcher2, this.goal, 1215, 295);
} }
@ -108,7 +108,7 @@ public class LevelRenderer {
shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f); shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f);
if (LevelScreen.selected != null) { if (LevelScreen.selected != null) {
shapeRenderer.rect(10, 10, 1190, 165); 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, 10, 250, 140);
shapeRenderer.rect(1210, 160, 250, 140); shapeRenderer.rect(1210, 160, 250, 140);
} }

View File

@ -203,6 +203,7 @@ public class GameScreen implements Screen {
public GameScreen(Worlds aworlds) { public GameScreen(Worlds aworlds) {
Gdx.app.debug(getClass().getSimpleName(),"Préparation du screen"); Gdx.app.debug(getClass().getSimpleName(),"Préparation du screen");
this.worlds = aworlds; this.worlds = aworlds;
this.worlds.prepareLevel(false);
this.level=worlds.getInformations(); this.level=worlds.getInformations();
if (level.Tech<1) if (level.Tech<1)
tocreate = new String[] { "run", "stop", "speed", "separator", "move#", "zoomp#","zoomm#", "separator", "levels", "exits", "separator", "screen", "sound", "settings" }; 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" }; tocreate = new String[] { "run", "stop", "speed", "separator", "move#", "zoomp#","zoomm#", "infos#", "separator", "raz", "save", "levels", "exits", "separator", "screen", "sound", "grid", "settings" };
else 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" }; 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."); Gdx.app.debug(getClass().getSimpleName(),"Création des Barres verticales & horizontales.");
horizbar=new HorizBarre(tocreate,"preparebarre"); horizbar=new HorizBarre(tocreate,"preparebarre");
horizbar.addListener(new ChangeListener() { horizbar.addListener(new ChangeListener() {
@ -275,9 +264,7 @@ public class GameScreen implements Screen {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug(getClass().getSimpleName(),"Remise à zéro du monde"); Gdx.app.debug(getClass().getSimpleName(),"Remise à zéro du monde");
GameScreen.this.level.Grid = GameScreen.this.level.Grid_orig; worlds.prepareLevel(true);
level.Grid.tiling_copper();
level.Grid.tiling_transmuter();
map.redraw(); map.redraw();
buttonlevel.setChecked(false); buttonlevel.setChecked(false);
} }

View File

@ -646,8 +646,8 @@ public class LevelScreen implements Screen {
rayon.setVisible(true); rayon.setVisible(true);
} else } else
rayon.setVisible(false); rayon.setVisible(false);
if (button.level.Cout > 0) { if (button.level.Cout_orig > 0) {
cout.setText(String.valueOf(button.level.Cout)); cout.setText(String.valueOf(button.level.Cout_orig));
cout.setVisible(true); cout.setVisible(true);
} else } else
cout.setVisible(false); cout.setVisible(false);
@ -656,8 +656,8 @@ public class LevelScreen implements Screen {
tech.setVisible(true); tech.setVisible(true);
} else } else
tech.setVisible(false); tech.setVisible(false);
Victory.setVisible(button.level.Cout > 0); Victory.setVisible(button.level.Cout_orig > 0);
Victory.setVictory(button.level.Victory); Victory.setVictory(button.level.Victory_orig);
if (selected != null) if (selected != null)
selected.setChecked(false); selected.setChecked(false);
selected = button; selected = button;