feat: suppression de la classe automata ajout du deuxième monde gestion du chargement des mondes selection des niveaux

This commit is contained in:
Nicolas Hordé 2015-06-20 00:33:20 +02:00
parent 77f1ff4659
commit a235c5241c
6 changed files with 387 additions and 103 deletions

View File

@ -88,6 +88,7 @@ public class AssetLoader {
Typecolors=new Color[]{new Color(0,0,1f,1),new Color(0,0.6f,0,1),new Color(0.196f,0.803f,0.196f,1),new Color(0.5f,0.5f,0.5f,1),new Color(0.8f,0.8f,0.8f,1),new Color(0.6f,0,0,1),new Color(1f,0,0,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0.294f,0.466f,0.615f,1),new Color(0.478f,0.192f,0.098f,1)};
Typenames=new String[13];
Typenames=new String[]{"E-","e-","Ph","e0","E0","e+","E+","K","L","M","N","n","p"};
intro = Gdx.audio.newSound(Gdx.files.internal("musics/intro.mp3"));
}
public static int setpref() {
@ -132,7 +133,6 @@ public class AssetLoader {
Gdx.app.debug("AssetLoader","Chargements des éléments minimalistes");
Texture_logo = new Texture(Gdx.files.internal("pictures/logo.png"));
Texture_logo.setFilter(TextureFilter.Linear,TextureFilter.Linear);
intro = Gdx.audio.newSound(Gdx.files.internal("musics/intro.mp3"));
}
public static void dispose() {

View File

@ -98,7 +98,7 @@ public class SaveObject {
public static Level[] initObject()
{
Level[] thelevels=new Level[9];
Level[] thelevels=new Level[35];
thelevels[0]=new Level(
0,
@ -327,6 +327,234 @@ public class SaveObject {
true,
new int[][]{{1, 0},{1, 2}});
thelevels[9]=new Level(
1,
0,
"Deutérium",
"Générer le Deutérium, un isostope de l'hydrogène, celui-ci comporte un neutron en plus du proton et de l'électron négatif sur la couche K.",
"D",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
30f,
700f,
4,
1100,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 1}});
thelevels[10]=new Level(
1,
1,
"Tritium",
"Générer le second isostope de l'hydrogène : cet atome plus lourd que le Deutérium comporte alors deux neutrons, un proton ainsi qu'un électron négatif sur la couche K.",
"T",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1},
420f,
750f,
4,
1000,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{}});
thelevels[11]=new Level(
1,
2,
"Hélium-4",
"L'isotope le plus courant de l'Hélium dans l'atmosphère terrestre est l'Hélium-4. Générer le en associant deux protons, deux neutrons et deux électrons négatifs sur la couche K.",
"He",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 2},
30f,
350f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
800,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 3},{1, 5}});
thelevels[12]=new Level(
1,
3,
"Hélium-3",
"Générer le seul autre isotope stable de l'hélium, ce dernier n'étant présent qu'à l'état de traces sur Terre. Cet isotope comporte deux protons,un neutron et deux électrons négatifs sur la couche K.",
"He",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 2},
180f,
230f,
4,
1300,
new Grid(20,20),
0,
0,
0,
0,
700,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 4}});
thelevels[13]=new Level(
1,
4,
"Hélium-8",
"l'Hélium-8 est le plus étudié des isotopes lourds de l'Hélium avec l'Hélium-6. Cet isostope comporte deux protons, six neutrons et deux électrons négatifs sur la couche K.",
"He",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 6, 2},
420f,
230f,
5,
1500,
new Grid(20,20),
0,
0,
0,
0,
1800,
99999,
99999,
99999,
"",
false,
new int[][]{{}});
thelevels[14]=new Level(
1,
5,
"Lithium",
"Générer un isostope de l'hydrogène qui comporte un proton et un neutron ainsi qu'un électron négatif sur la couche K.",
"Li",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
300f,
490f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 6}});
thelevels[15]=new Level(
1,
6,
"Carbone",
"Générer un isostope de l'hydrogène qui comporte un proton et un neutron ainsi qu'un électron négatif sur la couche K.",
"C",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
550f,
490f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 7}});
thelevels[16]=new Level(
1,
7,
"Oxygène",
"Générer un isostope de l'hydrogène qui comporte un proton et un neutron ainsi qu'un électron négatif sur la couche K.",
"O",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
800f,
570f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 8}});
thelevels[17]=new Level(
1,
8,
"Néon",
"Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.",
"Ne",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
1000f,
750f,
6,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
true,
new int[][]{{}});
return thelevels;
}

View File

@ -1,28 +0,0 @@
package fr.evolving.automata;
import java.io.Serializable;
public class Automata implements Serializable{
private int X;
private int Y;
private Grid MyGrid;
private Cell Current;
private transient Cell Old;
public Automata(int X,int Y,Grid MyGrid) {
this.X=X;
this.Y=Y;
this.MyGrid=MyGrid;
this.Current=new Cell();
this.Old=new Cell();
}
public Automata GetRelative(int X,int Y) {
int goX=this.X+X;
int goY=this.Y+Y;
if (goX<0 || goY<0 || goX>=this.MyGrid.automatas.length || goY>=this.MyGrid.automatas[0].length) {
return null;
}
return this.MyGrid.automatas[goX][goY];
}
}

View File

@ -14,6 +14,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextArea;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.viewport.FillViewport;
@ -24,6 +25,7 @@ import com.badlogic.gdx.utils.viewport.StretchViewport;
import fr.evolving.worlds.LevelRenderer;
import fr.evolving.UI.ButtonLevel;
import fr.evolving.UI.Objectives;
import fr.evolving.game.main;
import fr.evolving.inputs.InputHandler;
import java.util.Timer;
import java.util.TimerTask;
@ -46,71 +48,68 @@ public class LevelScreen implements Screen {
private TextButton buttonPlay,buttonExit;
private Level[] thelevels;
private TextArea TextDescriptive;
public int World;
Objectives Victory;
public int world;
private Objectives Victory;
public ButtonLevel selected;
public int getMaxWorld() {
int max=0;
for (Level level :thelevels)
if (level!=null && level.aWorld>max)
max=level.aWorld;
return max;
}
public void loadWorld(int aworld) {
int i=0;
if (buttonLevels!=null)
for (int j=0;j<10;j++) {
if (buttonLevels[j]!=null) {
buttonLevels[j].remove();
}
}
buttonLevels = null;
buttonLevels = new ButtonLevel[10];
for (Level level :thelevels) {
if (level!=null && level.aWorld==aworld) {
buttonLevels[i]=new ButtonLevel(level,true);
Gdx.app.debug(getClass().getSimpleName(),"Ajout du niveau :"+level.Name+""+String.valueOf(level.aLevel));
buttonLevels[i++].addListener(new ClickListener(){
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ButtonLevel button = (ButtonLevel)event.getListenerActor();
Gdx.app.debug(getClass().getSimpleName(), "Enter button "+button.level.Name);
if (!button.isChecked())
showlevel(button);
}
public void exit(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ButtonLevel button = (ButtonLevel)event.getListenerActor();
Gdx.app.debug(getClass().getSimpleName(), "Enter button "+button.level.Name);
if (!button.isChecked())
showlevel(button);
}
});
}
}
for (int j=0;j<10;j++) {
if (buttonLevels[j]!=null) {
stage.addActor(buttonLevels[j]);
}
}
Gdx.app.debug(getClass().getSimpleName(),"Mise en place du level 0.");
world=world;
buttonLevels[0].setChecked(true);
showlevel(buttonLevels[0]);
}
public LevelScreen() {
this.World=0;
Gdx.app.debug(getClass().getSimpleName(),"Création des boutons.");
this.world=0;
Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table)");
stage = new Stage(AssetLoader.viewport);
table = new Table();
Renderer=new LevelRenderer(this);
buttonLevels = new ButtonLevel[10];
thelevels= SaveObject.initObject();
for (int i = 0;i<thelevels.length;i++) {
if (thelevels[i] != null)
buttonLevels[i]=new ButtonLevel(thelevels[i],true);
buttonLevels[i].addListener(new ClickListener(){
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ButtonLevel button = (ButtonLevel)event.getListenerActor();
System.out.println(button.getBackground());
TextDescriptive.setText(button.level.Description);
if (button.level.Maxcycle<99999 && button.level.Maxcycle>0) {
cycle.setText(String.valueOf(button.level.Maxcycle));
cycle.setVisible(true);
}
else
cycle.setVisible(false);
if (button.level.Maxtemp<99999 && button.level.Maxtemp>0) {
temp.setText(String.valueOf(button.level.Maxtemp));
temp.setVisible(true);
}
else
temp.setVisible(false);
if (button.level.Maxnrj<99999 && button.level.Maxnrj>0) {
nrj.setText(String.valueOf(button.level.Maxnrj));
nrj.setVisible(true);
}
else
nrj.setVisible(false);
if (button.level.Maxrayon<99999 && button.level.Maxrayon>0) {
rayon.setText(String.valueOf(button.level.Maxrayon));
rayon.setVisible(true);
}
else
rayon.setVisible(false);
if (button.level.Cout>0) {
cout.setText(String.valueOf(button.level.Cout));
cout.setVisible(true);
}
else
cout.setVisible(false);
if (button.level.Tech>=0) {
tech.setText(String.valueOf(button.level.Tech));
tech.setVisible(true);
}
else
tech.setVisible(false);
Victory.setVictory(button.level.Victory);
}
public void leave(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ButtonLevel button = (ButtonLevel)event.getListenerActor();
button.setBackground("leveler"+String.valueOf(World)+"_over");
}
});
}
Gdx.app.debug(getClass().getSimpleName(),"Mise en place du timer.");
ScrollTimer=new Timer();
ScrollTask = new TimerTask()
{
@ -121,6 +120,7 @@ public class LevelScreen implements Screen {
}
};
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
Gdx.app.debug(getClass().getSimpleName(),"Création des boutons.");
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,"Descriptif");
TextDescriptive.setBounds(15, 15, 1185, 100);
buttonPlay = new TextButton("Connexions", AssetLoader.Skin_level,"Bouton");
@ -137,8 +137,28 @@ public class LevelScreen implements Screen {
});
Next=new ImageButton(AssetLoader.Skin_level,"Next");
Next.setPosition(1030, 170);
Next.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if (world<getMaxWorld()) {
world++;
loadWorld(world);
}
Gdx.app.debug(getClass().getSimpleName(),"World:"+String.valueOf(world)+" Maxworld:"+String.valueOf(getMaxWorld()));
}
});
Previous=new ImageButton(AssetLoader.Skin_level,"Previous");
Previous.setPosition(1110, 170);
Previous.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if (world>0) {
world--;
loadWorld(world);
}
Gdx.app.debug(getClass().getSimpleName(),"World:"+String.valueOf(world)+" Maxworld:"+String.valueOf(getMaxWorld()));
}
});
cout=new ImageTextButton("5",AssetLoader.Skin_level,"cout");
cout.setPosition(1250, 48);
tech=new ImageTextButton("10",AssetLoader.Skin_level,"tech");
@ -151,9 +171,13 @@ public class LevelScreen implements Screen {
nrj.setPosition(1365, 490);
rayon=new ImageTextButton("10",AssetLoader.Skin_level,"rayon");
rayon.setPosition(1250, 490);
Gdx.app.debug(getClass().getSimpleName(),"Conditions de victoire.");
Victory=new Objectives();
Victory.setVictory(new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
Victory.setPosition(1216, 185);
Gdx.app.debug(getClass().getSimpleName(),"Création des boutons de niveau.");
thelevels= SaveObject.initObject();
loadWorld(0);
}
@Override
@ -192,6 +216,9 @@ public class LevelScreen implements Screen {
stage.addActor(rayon);
stage.addActor(Victory);
Gdx.input.setInputProcessor(stage);
Gdx.app.debug("AssetLoader","Début dans la bande son \'intro\'");
AssetLoader.intro.setLooping(0, true);
AssetLoader.intro.play();
}
@Override
@ -210,5 +237,55 @@ public class LevelScreen implements Screen {
public void dispose() {
stage.dispose();
}
public void showlevel(ButtonLevel button) {
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));
cycle.setVisible(true);
}
else
cycle.setVisible(false);
if (button.level.Maxtemp<99999 && button.level.Maxtemp>0) {
temp.setText(String.valueOf(button.level.Maxtemp));
temp.setVisible(true);
}
else
temp.setVisible(false);
if (button.level.Maxnrj<99999 && button.level.Maxnrj>0) {
nrj.setText(String.valueOf(button.level.Maxnrj));
nrj.setVisible(true);
}
else
nrj.setVisible(false);
if (button.level.Maxrayon<99999 && button.level.Maxrayon>0) {
rayon.setText(String.valueOf(button.level.Maxrayon));
rayon.setVisible(true);
}
else
rayon.setVisible(false);
if (button.level.Cout>0) {
cout.setText(String.valueOf(button.level.Cout));
cout.setVisible(true);
}
else
cout.setVisible(false);
if (button.level.Tech>=1) {
tech.setText(String.valueOf(button.level.Tech));
tech.setVisible(true);
}
else
tech.setVisible(false);
Victory.setVisible(button.level.Cout>0);
Victory.setVictory(button.level.Victory);
//for (int i = 0;i<thelevels.length;i++) {
// if (thelevels[i] != null && buttonLevels[i]!=button)
// buttonLevels[i].setChecked(false);
if (selected!=null)
selected.setChecked(false);
selected=button;
button.setChecked(true);
}
}

View File

@ -48,9 +48,6 @@ public class SplashScreen implements Screen {
((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen());
}
})));
Gdx.app.debug("AssetLoader","Début dans la bande son \'intro\'");
AssetLoader.intro.setLooping(0, true);
AssetLoader.intro.play();
}
@Override

View File

@ -46,7 +46,7 @@ public class LevelRenderer {
Laser=new Laser();
AssetLoader.viewport.apply();
font=AssetLoader.Skin_level.getFont("OpenDyslexicAlta-22");
font.setColor(AssetLoader.Levelcolors[LevelScreen.World]);
font.setColor(AssetLoader.Levelcolors[LevelScreen.world]);
}
public void evolve() {
@ -87,11 +87,16 @@ public class LevelRenderer {
Texture_logosmall=AssetLoader.Skin_level.getRegion("logo2");
batcher2.draw(Texture_logosmall,20, AssetLoader.height-Texture_logobig.getRegionHeight()+Texture_logosmall.getRegionHeight()/2);
batcher2.draw(Texture_logobig,120, AssetLoader.height-Texture_logobig.getRegionHeight());
font.draw(batcher2, "Ressources", 1215, 145);
font.draw(batcher2, "Descriptif", 15, 145);
font.draw(batcher2, LevelScreen.selected.level.Name, 15, 145);
if (LevelScreen.selected!=null && LevelScreen.selected.level.Tech>0)
font.draw(batcher2, "Récompenses", 1215, AssetLoader.height-15);
font.draw(batcher2, "Objectifs", 1215, 295);
font.draw(batcher2, "Handicaps", 1215, 605);
if (LevelScreen.selected!=null && LevelScreen.selected.level.Cout>0) {
font.draw(batcher2, "Ressources", 1215, 145);
font.draw(batcher2, "Objectifs", 1215, 295);
}
if (LevelScreen.selected!=null && LevelScreen.selected.level.aWorld>0)
font.draw(batcher2, "Handicaps", 1215, 605);
font.draw(batcher2, "", 1215, 145);
batcher2.end();
@ -100,21 +105,26 @@ public class LevelRenderer {
shapeRenderer.setProjectionMatrix(AssetLoader.Camera.combined);
shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f);
shapeRenderer.rect(10, 10, 1190, 140);
shapeRenderer.rect(1210, 10, 250, 140);
shapeRenderer.rect(1210, 160,250, 140);
shapeRenderer.rect(1210, 310,250, 300);
shapeRenderer.rect(1210, 620,250, AssetLoader.height-630);
if (LevelScreen.selected!=null && LevelScreen.selected.level.Cout>0) {
shapeRenderer.rect(1210, 10, 250, 140);
shapeRenderer.rect(1210, 160,250, 140);
}
if (LevelScreen.selected!=null && LevelScreen.selected.level.aWorld>0)
shapeRenderer.rect(1210, 310,250, 300);
if (LevelScreen.selected!=null && LevelScreen.selected.level.Tech>0)
shapeRenderer.rect(1210, 620,250, AssetLoader.height-630);
shapeRenderer.rect(1470, 10, 440, AssetLoader.height-20);
shapeRenderer.end();
for (int i=0;i<LevelScreen.buttonLevels.length;i++) {
if (LevelScreen.buttonLevels[i]!=null) {
for (int[] item : LevelScreen.buttonLevels[i].level.Link)
{
int found=-1;
for (int j=0;j<LevelScreen.buttonLevels.length;j++)
{
if ((LevelScreen.buttonLevels[j]!=null) && (LevelScreen.buttonLevels[j].level.aWorld==item[0]) && (LevelScreen.buttonLevels[j].level.aLevel==item[1])) {
if ((item.length==2) && (LevelScreen.buttonLevels[j]!=null) && (LevelScreen.buttonLevels[j].level.aWorld==item[0]) && (LevelScreen.buttonLevels[j].level.aLevel==item[1])) {
found=j;
break;
}