feat: rajout de la gestion des niveaux. création du niveau 1.
This commit is contained in:
parent
bd1e014171
commit
0609d13f92
|
@ -13,56 +13,45 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.Align;
|
import com.badlogic.gdx.scenes.scene2d.utils.Align;
|
||||||
|
|
||||||
import fr.evolving.assets.AssetLoader;
|
import fr.evolving.assets.AssetLoader;
|
||||||
|
import fr.evolving.automata.Level;
|
||||||
|
|
||||||
public class ButtonLevel extends ImageTextButton {
|
public class ButtonLevel extends ImageTextButton {
|
||||||
public int level;
|
public Level level;
|
||||||
public int world;
|
|
||||||
public boolean Final;
|
|
||||||
public int[][] Link;
|
|
||||||
public boolean Activated;
|
public boolean Activated;
|
||||||
TextureRegion Finalled,Locked;
|
TextureRegion Finalled,Locked;
|
||||||
public String id,shortid;
|
|
||||||
public int xx,yy;
|
|
||||||
private Color[] Levelcolors={AssetLoader.Skin_level.getColor("world1"),AssetLoader.Skin_level.getColor("world2"),AssetLoader.Skin_level.getColor("world3"),AssetLoader.Skin_level.getColor("world4"),AssetLoader.Skin_level.getColor("world5")};
|
private Color[] Levelcolors={AssetLoader.Skin_level.getColor("world1"),AssetLoader.Skin_level.getColor("world2"),AssetLoader.Skin_level.getColor("world3"),AssetLoader.Skin_level.getColor("world4"),AssetLoader.Skin_level.getColor("world5")};
|
||||||
Label Thelabel;
|
Label Thelabel;
|
||||||
|
|
||||||
public ButtonLevel(String shortid,String id,int world, int level, boolean Final, int[][] Link, boolean Activated,int x, int y) {
|
public ButtonLevel(Level level, boolean Activated) {
|
||||||
super(id, AssetLoader.Skin_level, "world"+String.valueOf(world));
|
super(level.Name, AssetLoader.Skin_level, "world"+String.valueOf(level.aWorld));
|
||||||
this.xx=x;
|
|
||||||
this.yy=y;
|
|
||||||
this.id=id;
|
|
||||||
this.shortid=shortid;
|
|
||||||
this.level=level;
|
this.level=level;
|
||||||
this.world=world;
|
|
||||||
this.Final=Final;
|
|
||||||
this.Link=Link;
|
|
||||||
this.Activated=Activated;
|
this.Activated=Activated;
|
||||||
if (Final==true) {
|
if (level.Special==true) {
|
||||||
Finalled=AssetLoader.Skin_level.getAtlas().findRegion("boss");
|
Finalled=AssetLoader.Skin_level.getAtlas().findRegion("boss");
|
||||||
}
|
}
|
||||||
if (Activated==false) {
|
if (Activated==false) {
|
||||||
this.setDisabled(true);
|
this.setDisabled(true);
|
||||||
Locked=AssetLoader.Skin_level.getAtlas().findRegion("locked");
|
Locked=AssetLoader.Skin_level.getAtlas().findRegion("locked");
|
||||||
}
|
}
|
||||||
this.setColor(1f, 0.47f+(float)x/Gdx.graphics.getWidth()*0.529f,0.607f+(float)x/Gdx.graphics.getWidth()*0.392f, 1f);
|
this.setColor(1f, 0.47f+(float)level.X/Gdx.graphics.getWidth()*0.529f,0.607f+(float)level.X/Gdx.graphics.getWidth()*0.392f, 1f);
|
||||||
this.setBounds(x/1024.0f*Gdx.graphics.getWidth(), y/768.0f*Gdx.graphics.getHeight(), 111, 125);
|
this.setBounds(level.X, level.Y/768.0f*Gdx.graphics.getHeight(), 111, 125);
|
||||||
Thelabel=new Label(this.shortid, AssetLoader.Skin_level,"Levelshort");
|
Thelabel=new Label(level.Element, AssetLoader.Skin_level,"Levelshort");
|
||||||
Thelabel.setColor(xx/1024f,xx/1024f,xx/1024f,1f);
|
Thelabel.setColor(level.X/1024f,level.X/1024f,level.X/1024f,1f);
|
||||||
Thelabel.setPosition(xx/1024.0f*Gdx.graphics.getWidth()+54, yy/768.0f*Gdx.graphics.getHeight()+20, Align.bottom | Align.center);
|
Thelabel.setPosition(level.X+54, level.Y/768.0f*Gdx.graphics.getHeight()+20, Align.bottom | Align.center);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getLevelcolor() {
|
public Color getLevelcolor() {
|
||||||
return Levelcolors[world];
|
return Levelcolors[level.aWorld];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Batch batch, float parentAlpha) {
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
super.draw(batch, parentAlpha);
|
super.draw(batch, parentAlpha);
|
||||||
if (Final) {
|
if (level.Special) {
|
||||||
batch.draw(Finalled,xx/1024.0f*Gdx.graphics.getWidth(),yy/768.0f*Gdx.graphics.getHeight());
|
batch.draw(Finalled,level.X,level.Y/768.0f*Gdx.graphics.getHeight());
|
||||||
}
|
}
|
||||||
if (!Activated) {
|
if (!Activated) {
|
||||||
batch.draw(Locked,xx/1024.0f*Gdx.graphics.getWidth()+this.getWidth()-Locked.getRegionWidth(),yy/768.0f*Gdx.graphics.getHeight()+this.getHeight()-Locked.getRegionWidth());
|
batch.draw(Locked,level.X+this.getWidth()-Locked.getRegionWidth(),level.Y/768.0f*Gdx.graphics.getHeight()+this.getHeight()-Locked.getRegionWidth());
|
||||||
}
|
}
|
||||||
Thelabel.draw(batch, 1f);
|
Thelabel.draw(batch, 1f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,15 +96,18 @@ public class SaveObject {
|
||||||
return dbConnection;
|
return dbConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Level[] initObject()
|
public static Level[] initObject()
|
||||||
{
|
{
|
||||||
Level[] thelevels=new Level[9];
|
Level[] thelevels=new Level[9];
|
||||||
|
|
||||||
thelevels[0]=new Level("Introduction",
|
thelevels[0]=new Level(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
"Introduction",
|
||||||
"Prise en main de l'interface de WireChem{#169} et amener l'électron neutre sur le senseur.",
|
"Prise en main de l'interface de WireChem{#169} et amener l'électron neutre sur le senseur.",
|
||||||
"e0",
|
"e0",
|
||||||
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
38f,
|
38f,
|
||||||
450f,
|
450f,
|
||||||
-1,
|
-1,
|
||||||
|
@ -121,7 +124,211 @@ public class SaveObject {
|
||||||
"",
|
"",
|
||||||
false,
|
false,
|
||||||
new int[][]{{0, 1}, {0, 8}});
|
new int[][]{{0, 1}, {0, 8}});
|
||||||
|
|
||||||
|
thelevels[1]=new Level(
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
"Trajectoires",
|
||||||
|
"Comprendre les trajectoires empruntées par les électrons afin de mieux appréhender la conception de systèmes.",
|
||||||
|
"e0",
|
||||||
|
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
38f,
|
||||||
|
200,
|
||||||
|
-1,
|
||||||
|
0,
|
||||||
|
new Grid(20,20),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
new int[][]{{0, 2}});
|
||||||
|
|
||||||
|
thelevels[2]=new Level(
|
||||||
|
0,
|
||||||
|
2,
|
||||||
|
"Pistes",
|
||||||
|
"Utiliser des pistes afin de réaliser un circuit qui permet l'arrivée d'un électron neutre sur le senseur.",
|
||||||
|
"e0",
|
||||||
|
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
180f,
|
||||||
|
300f,
|
||||||
|
-1,
|
||||||
|
15,
|
||||||
|
new Grid(20,20),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
new int[][]{{0, 3}});
|
||||||
|
|
||||||
|
|
||||||
|
thelevels[3]=new Level(
|
||||||
|
0,
|
||||||
|
3,
|
||||||
|
"Positiveur",
|
||||||
|
"Comprendre le fonctionnement de l'élément positiveur et générer 8 électrons positifs sur le senseur.",
|
||||||
|
"e+",
|
||||||
|
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
new int[]{0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
330f,
|
||||||
|
350f,
|
||||||
|
0,
|
||||||
|
16,
|
||||||
|
new Grid(20,20),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
new int[][]{{0, 4}});
|
||||||
|
|
||||||
|
thelevels[4]=new Level(
|
||||||
|
0,
|
||||||
|
4,
|
||||||
|
"Super-électrons",
|
||||||
|
"Générer 2 super-électrons negatifs par colision et les amener sur le senseur.",
|
||||||
|
"E-",
|
||||||
|
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
new int[]{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
490f,
|
||||||
|
380f,
|
||||||
|
0,
|
||||||
|
16,
|
||||||
|
new Grid(20,20),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
new int[][]{{0, 5}});
|
||||||
|
|
||||||
|
thelevels[5]=new Level(
|
||||||
|
0,
|
||||||
|
5,
|
||||||
|
"Activation",
|
||||||
|
"L'objectif est de générer 6 électrons neutres et de découvrir les liaisons de fibres par lesquelles transitent les photons. Certains modifieurs nécessitent désormais l'activation par des photons.",
|
||||||
|
"e0",
|
||||||
|
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
new int[]{0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
490f,
|
||||||
|
200f,
|
||||||
|
1,
|
||||||
|
136,
|
||||||
|
new Grid(20,20),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
new int[][]{{0, 6}});
|
||||||
|
|
||||||
|
thelevels[6]=new Level(
|
||||||
|
0,
|
||||||
|
6,
|
||||||
|
"Fibres",
|
||||||
|
"A vous de dessiner votre infrastructure à base de fibres et de pistes mais aussi de modifieur activable afin de faire parvenir des éléctrons positifs et neutres sur les senseurs.",
|
||||||
|
"eX",
|
||||||
|
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
new int[]{0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
640f,
|
||||||
|
200f,
|
||||||
|
2,
|
||||||
|
230,
|
||||||
|
new Grid(20,20),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
new int[][]{{0, 7}});
|
||||||
|
|
||||||
|
|
||||||
|
thelevels[7]=new Level(
|
||||||
|
0,
|
||||||
|
7,
|
||||||
|
"Protons",
|
||||||
|
"Générer deux protons sur le senseur en utilisant un réacteur et un super-positron. Le réacteur est un élément qui nécessite l'activation.",
|
||||||
|
"p",
|
||||||
|
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
|
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
|
||||||
|
800f,
|
||||||
|
290f,
|
||||||
|
2,
|
||||||
|
370,
|
||||||
|
new Grid(20,20),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
new int[][]{{0, 8}});
|
||||||
|
|
||||||
|
thelevels[8]=new Level(
|
||||||
|
0,
|
||||||
|
8,
|
||||||
|
"Hydrogène",
|
||||||
|
"Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.",
|
||||||
|
"H",
|
||||||
|
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, 0, 1},
|
||||||
|
900f,
|
||||||
|
450f,
|
||||||
|
3,
|
||||||
|
750,
|
||||||
|
new Grid(20,20),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
99999,
|
||||||
|
"",
|
||||||
|
true,
|
||||||
|
new int[][]{{1, 0},{1, 2}});
|
||||||
|
|
||||||
return thelevels;
|
return thelevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,29 +3,33 @@ package fr.evolving.automata;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class Level implements Serializable{
|
public class Level implements Serializable{
|
||||||
String Name;
|
public String Name;
|
||||||
String Description;
|
public String Description;
|
||||||
String Element;
|
public String Element;
|
||||||
int[] Current;
|
public int[] Current;
|
||||||
int[] Victory;
|
public int[] Victory;
|
||||||
float X;
|
public int aWorld;
|
||||||
float Y;
|
public int aLevel;
|
||||||
int Tech;
|
public float X;
|
||||||
int Cout;
|
public float Y;
|
||||||
Grid Grid;
|
public int Tech;
|
||||||
int Cycle;
|
public int Cout;
|
||||||
int Temp;
|
public Grid Grid;
|
||||||
int Rayon;
|
public int Cycle;
|
||||||
int Nrj;
|
public int Temp;
|
||||||
int Maxcycle;
|
public int Rayon;
|
||||||
int Maxtemp;
|
public int Nrj;
|
||||||
int Maxrayon;
|
public int Maxcycle;
|
||||||
int Maxnrj;
|
public int Maxtemp;
|
||||||
boolean Special;
|
public int Maxrayon;
|
||||||
String Tuto;
|
public int Maxnrj;
|
||||||
int[][] Link;
|
public boolean Special;
|
||||||
|
public String Tuto;
|
||||||
|
public int[][] Link;
|
||||||
|
|
||||||
public Level(String Name,String Description,String Element,int[] Current,int[] Victory,float X,float Y,int Tech,int Cout,Grid World,int Cycle,int Temp,int Rayon,int Nrj,int Maxcycle,int Maxtemp,int Maxrayon,int Maxnrj,String Tuto,boolean Special, int[][] Link){
|
public Level(int aWorld, int aLevel,String Name,String Description,String Element,int[] Current,int[] Victory,float X,float Y,int Tech,int Cout,Grid World,int Cycle,int Temp,int Rayon,int Nrj,int Maxcycle,int Maxtemp,int Maxrayon,int Maxnrj,String Tuto,boolean Special, int[][] Link){
|
||||||
|
this.aWorld=aWorld;
|
||||||
|
this.aLevel=aLevel;
|
||||||
this.Name=Name;
|
this.Name=Name;
|
||||||
this.Description=Description;
|
this.Description=Description;
|
||||||
this.Element=Element;
|
this.Element=Element;
|
||||||
|
|
|
@ -29,9 +29,7 @@ public class Laser {
|
||||||
overlay=AssetLoader.Skin_level.getAtlas().findRegion("overlay");
|
overlay=AssetLoader.Skin_level.getAtlas().findRegion("overlay");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) {
|
public void draw(float x1,float yy1,float x2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) {
|
||||||
float x1=xx1/1024.0f*Gdx.graphics.getWidth();
|
|
||||||
float x2=xx2/1024.0f*Gdx.graphics.getWidth();
|
|
||||||
float y1=yy1/768.0f*Gdx.graphics.getHeight();
|
float y1=yy1/768.0f*Gdx.graphics.getHeight();
|
||||||
float y2=yy2/768.0f*Gdx.graphics.getHeight();
|
float y2=yy2/768.0f*Gdx.graphics.getHeight();
|
||||||
Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1));
|
Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1));
|
||||||
|
@ -50,9 +48,7 @@ public class Laser {
|
||||||
Laser.dispose();
|
Laser.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawnotsoold(float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) {
|
public void drawnotsoold(float x1,float yy1,float x2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) {
|
||||||
float x1=xx1/1024.0f*Gdx.graphics.getWidth();
|
|
||||||
float x2=xx2/1024.0f*Gdx.graphics.getWidth();
|
|
||||||
float y1=yy1/768.0f*Gdx.graphics.getHeight();
|
float y1=yy1/768.0f*Gdx.graphics.getHeight();
|
||||||
float y2=yy2/768.0f*Gdx.graphics.getHeight();
|
float y2=yy2/768.0f*Gdx.graphics.getHeight();
|
||||||
ShapeRenderer Laser=new ShapeRenderer();
|
ShapeRenderer Laser=new ShapeRenderer();
|
||||||
|
@ -91,9 +87,7 @@ public class Laser {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void drawold(float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) {
|
public static void drawold(float x1,float yy1,float x2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) {
|
||||||
float x1=xx1/1024.0f*Gdx.graphics.getWidth();
|
|
||||||
float x2=xx2/1024.0f*Gdx.graphics.getWidth();
|
|
||||||
float y1=yy1/768.0f*Gdx.graphics.getHeight();
|
float y1=yy1/768.0f*Gdx.graphics.getHeight();
|
||||||
float y2=yy2/768.0f*Gdx.graphics.getHeight();
|
float y2=yy2/768.0f*Gdx.graphics.getHeight();
|
||||||
ShapeRenderer Laser=new ShapeRenderer();
|
ShapeRenderer Laser=new ShapeRenderer();
|
||||||
|
|
|
@ -9,9 +9,12 @@ import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextArea;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
|
||||||
import fr.evolving.worlds.LevelRenderer;
|
import fr.evolving.worlds.LevelRenderer;
|
||||||
import fr.evolving.UI.ButtonLevel;
|
import fr.evolving.UI.ButtonLevel;
|
||||||
|
@ -19,10 +22,13 @@ import fr.evolving.inputs.InputHandler;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import fr.evolving.assets.AssetLoader;
|
import fr.evolving.assets.AssetLoader;
|
||||||
|
import fr.evolving.assets.SaveObject;
|
||||||
|
import fr.evolving.automata.Level;
|
||||||
import fr.evolving.effects.Laser;
|
import fr.evolving.effects.Laser;
|
||||||
|
|
||||||
|
|
||||||
public class LevelScreen implements Screen {
|
public class LevelScreen implements Screen {
|
||||||
|
protected static final Class<? extends Actor> ButtonLevel = null;
|
||||||
public ButtonLevel[] buttonLevels;
|
public ButtonLevel[] buttonLevels;
|
||||||
private LevelRenderer Renderer;
|
private LevelRenderer Renderer;
|
||||||
private float runTime;
|
private float runTime;
|
||||||
|
@ -32,6 +38,9 @@ public class LevelScreen implements Screen {
|
||||||
private Table table = new Table();
|
private Table table = new Table();
|
||||||
private ImageButton Previous,Next,Exit;
|
private ImageButton Previous,Next,Exit;
|
||||||
private TextButton buttonPlay,buttonExit;
|
private TextButton buttonPlay,buttonExit;
|
||||||
|
private Level[] thelevels=new Level[9];
|
||||||
|
private float spaces,sizes;
|
||||||
|
private TextArea TextDescriptive;
|
||||||
|
|
||||||
// This is the constructor, not the class declaration
|
// This is the constructor, not the class declaration
|
||||||
public LevelScreen() {
|
public LevelScreen() {
|
||||||
|
@ -39,14 +48,17 @@ public class LevelScreen implements Screen {
|
||||||
float screenHeight = Gdx.graphics.getHeight();
|
float screenHeight = Gdx.graphics.getHeight();
|
||||||
Renderer=new LevelRenderer((int)screenWidth,(int)screenHeight,this);
|
Renderer=new LevelRenderer((int)screenWidth,(int)screenHeight,this);
|
||||||
buttonLevels = new ButtonLevel[10];
|
buttonLevels = new ButtonLevel[10];
|
||||||
int[][] integer=new int[][] {{0,2},{0,3},{0,1}};
|
thelevels= SaveObject.initObject();
|
||||||
buttonLevels[0]= new ButtonLevel("H","Hydrogene en test",0,0,true, integer, true,120,120);
|
for (int i = 0;i<thelevels.length;i++) {
|
||||||
buttonLevels[1]= new ButtonLevel("Li","Lithium a voir",0,1,false, new int[0][0], false,820,520);
|
if (thelevels[i] != null)
|
||||||
buttonLevels[2]= new ButtonLevel("Ne","Neon",0,2,true, new int[0][0], true,420,420);
|
buttonLevels[i]=new ButtonLevel(thelevels[i],true);
|
||||||
buttonLevels[3]= new ButtonLevel("Mg","Magnesium 23",0,3,false, new int[0][0], false,420,220);
|
buttonLevels[i].addListener(new ClickListener(){
|
||||||
buttonLevels[4]= new ButtonLevel("Pr","prout 21",1,3,true, integer, true,520,520);
|
@Override
|
||||||
int[][] integer2=new int[][] {{0,1},{1,3},{0,2}};
|
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
|
||||||
buttonLevels[5]= new ButtonLevel("Pr","prout",4,5,true, integer2, true,900,40);
|
TextDescriptive.setText(((ButtonLevel)event.getListenerActor()).level.Description);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
ScrollTimer=new Timer();
|
ScrollTimer=new Timer();
|
||||||
ScrollTask = new TimerTask()
|
ScrollTask = new TimerTask()
|
||||||
{
|
{
|
||||||
|
@ -57,8 +69,10 @@ public class LevelScreen implements Screen {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
|
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
|
||||||
buttonPlay = new TextButton("Play", AssetLoader.Skin_level);
|
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,"Descriptif");
|
||||||
buttonExit = new TextButton("Exit", AssetLoader.Skin_level);
|
TextDescriptive.setBounds(15, 15, 1009, 130);
|
||||||
|
buttonPlay = new TextButton("Jouer", AssetLoader.Skin_level,"Bouton");
|
||||||
|
buttonExit = new TextButton("Quitter", AssetLoader.Skin_level,"Bouton");
|
||||||
Exit=new ImageButton(AssetLoader.Skin_level,"Exit");
|
Exit=new ImageButton(AssetLoader.Skin_level,"Exit");
|
||||||
Exit.setPosition(900, Gdx.graphics.getHeight()-Exit.getHeight());
|
Exit.setPosition(900, Gdx.graphics.getHeight()-Exit.getHeight());
|
||||||
Exit.addListener(new ClickListener(){
|
Exit.addListener(new ClickListener(){
|
||||||
|
@ -68,9 +82,14 @@ public class LevelScreen implements Screen {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Next=new ImageButton(AssetLoader.Skin_level,"Next");
|
Next=new ImageButton(AssetLoader.Skin_level,"Next");
|
||||||
Next.setPosition(800, 100);
|
Next.setPosition(840, 170);
|
||||||
Previous=new ImageButton(AssetLoader.Skin_level,"Previous");
|
Previous=new ImageButton(AssetLoader.Skin_level,"Previous");
|
||||||
Previous.setPosition(900, 100);
|
Previous.setPosition(920, 170);
|
||||||
|
table.right().top().padTop(100);
|
||||||
|
sizes=(screenWidth-1024.0f)*0.7f;
|
||||||
|
if (sizes>250.0f)
|
||||||
|
sizes=250.0f;
|
||||||
|
spaces=(screenWidth-1024.0f-sizes)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,14 +107,15 @@ public class LevelScreen implements Screen {
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
Gdx.app.log("Affichage du LevelScreen","ok");
|
Gdx.app.log("Affichage du LevelScreen","ok");
|
||||||
table.add(buttonPlay).size(150,60).padBottom(20).row();
|
table.add(buttonPlay).size(sizes,60).padRight(spaces).padBottom(20).row();
|
||||||
table.add(buttonExit).size(150,60).padBottom(20).row();
|
table.add(buttonExit).size(sizes,60).padRight(spaces).padBottom(20).row();
|
||||||
for (int i=0;i<10;i++) {
|
for (int i=0;i<10;i++) {
|
||||||
if (buttonLevels[i]!=null) {
|
if (buttonLevels[i]!=null) {
|
||||||
stage.addActor(buttonLevels[i]);
|
stage.addActor(buttonLevels[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table.setFillParent(true);
|
table.setFillParent(true);
|
||||||
|
stage.addActor(TextDescriptive);
|
||||||
stage.addActor(table);
|
stage.addActor(table);
|
||||||
stage.addActor(Exit);
|
stage.addActor(Exit);
|
||||||
stage.addActor(Next);
|
stage.addActor(Next);
|
||||||
|
|
|
@ -78,23 +78,27 @@ public class LevelRenderer {
|
||||||
Texture_logosmall=AssetLoader.Skin_level.getRegion("logo2");
|
Texture_logosmall=AssetLoader.Skin_level.getRegion("logo2");
|
||||||
batcher.draw(Texture_logosmall,20, this.gameHeight-Texture_logobig.getRegionHeight()+Texture_logosmall.getRegionHeight()/2);
|
batcher.draw(Texture_logosmall,20, this.gameHeight-Texture_logobig.getRegionHeight()+Texture_logosmall.getRegionHeight()/2);
|
||||||
batcher.draw(Texture_logobig,120, this.gameHeight-Texture_logobig.getRegionHeight());
|
batcher.draw(Texture_logobig,120, this.gameHeight-Texture_logobig.getRegionHeight());
|
||||||
|
|
||||||
batcher.end();
|
batcher.end();
|
||||||
|
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||||
|
shapeRenderer.begin(ShapeType.Filled);
|
||||||
|
shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f);
|
||||||
|
shapeRenderer.rect(10, 10, 1014, 140);
|
||||||
|
shapeRenderer.end();
|
||||||
for (int i=0;i<LevelScreen.buttonLevels.length;i++) {
|
for (int i=0;i<LevelScreen.buttonLevels.length;i++) {
|
||||||
if (LevelScreen.buttonLevels[i]!=null) {
|
if (LevelScreen.buttonLevels[i]!=null) {
|
||||||
for (int[] item : LevelScreen.buttonLevels[i].Link)
|
for (int[] item : LevelScreen.buttonLevels[i].level.Link)
|
||||||
{
|
{
|
||||||
int found=-1;
|
int found=-1;
|
||||||
for (int j=0;j<LevelScreen.buttonLevels.length;j++)
|
for (int j=0;j<LevelScreen.buttonLevels.length;j++)
|
||||||
{
|
{
|
||||||
if ((LevelScreen.buttonLevels[j]!=null) && (LevelScreen.buttonLevels[j].world==item[0]) && (LevelScreen.buttonLevels[j].level==item[1])) {
|
if ((LevelScreen.buttonLevels[j]!=null) && (LevelScreen.buttonLevels[j].level.aWorld==item[0]) && (LevelScreen.buttonLevels[j].level.aLevel==item[1])) {
|
||||||
found=j;
|
found=j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found!=-1)
|
if (found!=-1)
|
||||||
{
|
{
|
||||||
Laser.draw(LevelScreen.buttonLevels[i].xx+20,LevelScreen.buttonLevels[i].yy+20,LevelScreen.buttonLevels[found].xx+20,LevelScreen.buttonLevels[found].yy+20,10,0.5f,LevelScreen.buttonLevels[found].Activated,LevelScreen.buttonLevels[i].getLevelcolor(),LevelScreen.buttonLevels[found].getLevelcolor());
|
Laser.draw(LevelScreen.buttonLevels[i].level.X+20,LevelScreen.buttonLevels[i].level.Y+20,LevelScreen.buttonLevels[found].level.X+20,LevelScreen.buttonLevels[found].level.Y+20,10,0.5f,LevelScreen.buttonLevels[found].Activated,LevelScreen.buttonLevels[i].getLevelcolor(),LevelScreen.buttonLevels[found].getLevelcolor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue