feat: ajout de la gestion des verrouillages des niveaux (incomplet)
This commit is contained in:
parent
1f3fe69f61
commit
7efec490f4
|
@ -13,7 +13,6 @@ import fr.evolving.automata.Level;
|
||||||
|
|
||||||
public class ButtonLevel extends ImageTextButton {
|
public class ButtonLevel extends ImageTextButton {
|
||||||
public Level level;
|
public Level level;
|
||||||
public boolean Activated;
|
|
||||||
private TextureRegion Finalled, Locked;
|
private TextureRegion Finalled, Locked;
|
||||||
private Label Thelabel;
|
private Label Thelabel;
|
||||||
private float scale;
|
private float scale;
|
||||||
|
@ -22,17 +21,16 @@ public class ButtonLevel extends ImageTextButton {
|
||||||
private LabelStyle stylelabel;
|
private LabelStyle stylelabel;
|
||||||
private boolean modifyxy;
|
private boolean modifyxy;
|
||||||
|
|
||||||
public ButtonLevel(Level level, boolean Activated, float ratio, boolean modifyxy) {
|
public ButtonLevel(Level level, float ratio, boolean modifyxy) {
|
||||||
super(level.Name, AssetLoader.Skin_level, "world"
|
super(level.Name, AssetLoader.Skin_level, "world"
|
||||||
+ String.valueOf(level.aWorld));
|
+ String.valueOf(level.aWorld));
|
||||||
this.modifyxy=modifyxy;
|
this.modifyxy=modifyxy;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.ratio = ratio;
|
this.ratio = ratio;
|
||||||
this.Activated = Activated;
|
|
||||||
if (level.Special == true) {
|
if (level.Special == true) {
|
||||||
Finalled = AssetLoader.Skin_level.getAtlas().findRegion("boss");
|
Finalled = AssetLoader.Skin_level.getAtlas().findRegion("boss");
|
||||||
}
|
}
|
||||||
if (Activated == false) {
|
if (level.Locked == false) {
|
||||||
this.setDisabled(true);
|
this.setDisabled(true);
|
||||||
Locked = AssetLoader.Skin_level.getAtlas().findRegion("locked");
|
Locked = AssetLoader.Skin_level.getAtlas().findRegion("locked");
|
||||||
}
|
}
|
||||||
|
@ -90,7 +88,7 @@ public class ButtonLevel extends ImageTextButton {
|
||||||
Finalled.getRegionWidth() * scale,
|
Finalled.getRegionWidth() * scale,
|
||||||
Finalled.getRegionHeight() * scale);
|
Finalled.getRegionHeight() * scale);
|
||||||
}
|
}
|
||||||
if (!Activated) {
|
if (!level.Locked) {
|
||||||
batch.draw(
|
batch.draw(
|
||||||
Locked,
|
Locked,
|
||||||
getX() + this.getWidth() - Locked.getRegionWidth(),
|
getX() + this.getWidth() - Locked.getRegionWidth(),
|
||||||
|
|
|
@ -107,10 +107,10 @@ public class HorizBarre extends Actor {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Barre[15].setChecked(Preference.prefs.getBoolean("Fullscreen"));
|
/*Barre[15].setChecked(Preference.prefs.getBoolean("Fullscreen"));
|
||||||
Barre[16].setChecked(Preference.prefs.getBoolean("Sound"));
|
Barre[16].setChecked(Preference.prefs.getBoolean("Sound"));
|
||||||
Barre[17].setChecked(Preference.prefs.getBoolean("Tutorial"));
|
Barre[17].setChecked(Preference.prefs.getBoolean("Tutorial"));
|
||||||
Barre[18].setChecked(Preference.prefs.getBoolean("Grid"));
|
Barre[18].setChecked(Preference.prefs.getBoolean("Grid"));*/
|
||||||
table = new HorizontalGroup();
|
table = new HorizontalGroup();
|
||||||
table.bottom().padLeft(5f).padBottom(8f).space(10f);
|
table.bottom().padLeft(5f).padBottom(8f).space(10f);
|
||||||
this.setTouchable(Touchable.enabled);
|
this.setTouchable(Touchable.enabled);
|
||||||
|
|
|
@ -16,11 +16,10 @@ public class Level implements Serializable {
|
||||||
public int Tech;
|
public int Tech;
|
||||||
public int Cout;
|
public int Cout;
|
||||||
public Grid Grid_orig;
|
public Grid Grid_orig;
|
||||||
public transient Grid Grid;
|
public int Cycle_orig;
|
||||||
public int Cycle;
|
public int Temp_orig;
|
||||||
public int Temp;
|
public int Rayon_orig;
|
||||||
public int Rayon;
|
public int Nrj_orig;
|
||||||
public int Nrj;
|
|
||||||
public int Maxcycle;
|
public int Maxcycle;
|
||||||
public int Maxtemp;
|
public int Maxtemp;
|
||||||
public int Maxrayon;
|
public int Maxrayon;
|
||||||
|
@ -30,6 +29,13 @@ public class Level implements Serializable {
|
||||||
public String Tuto;
|
public String Tuto;
|
||||||
public int[][] Link;
|
public int[][] Link;
|
||||||
|
|
||||||
|
public transient Grid Grid;
|
||||||
|
public transient int Cycle;
|
||||||
|
public transient int Temp;
|
||||||
|
public transient int Rayon;
|
||||||
|
public transient int Nrj;
|
||||||
|
public transient boolean Locked;
|
||||||
|
|
||||||
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,
|
||||||
float X, float Y, int Tech, int Cout, Grid World, int Cycle,
|
float X, float Y, int Tech, int Cout, Grid World, int Cycle,
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class Worlds extends Actor {
|
||||||
state=State.notloaded;
|
state=State.notloaded;
|
||||||
this.load(name);
|
this.load(name);
|
||||||
this.ReadTransmuters();
|
this.ReadTransmuters();
|
||||||
//if (state==State.notloaded)
|
if (state==State.notloaded)
|
||||||
create(name);
|
create(name);
|
||||||
onchanged();
|
onchanged();
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,6 @@ public class Worlds extends Actor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveResearch() {
|
public void SaveResearch() {
|
||||||
this.research=research;
|
|
||||||
AssetLoader.Datahandler.user().setResearchpoint(0,research);
|
AssetLoader.Datahandler.user().setResearchpoint(0,research);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +132,13 @@ public class Worlds extends Actor {
|
||||||
{
|
{
|
||||||
for(Level level:levels)
|
for(Level level:levels)
|
||||||
if (level!=null && level.aWorld==usedworld)
|
if (level!=null && level.aWorld==usedworld)
|
||||||
|
{
|
||||||
|
if (level.aLevel==0)
|
||||||
|
level.Locked=true;
|
||||||
|
else
|
||||||
|
level.Locked=AssetLoader.Datahandler.user().getLevellock(0, level.aLevel);
|
||||||
tempworld.add(level);
|
tempworld.add(level);
|
||||||
|
}
|
||||||
return tempworld;
|
return tempworld;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -15,22 +15,25 @@ public class Laser {
|
||||||
|
|
||||||
public float i = 0;
|
public float i = 0;
|
||||||
TextureRegion overlaymiddle, middle, overlay;
|
TextureRegion overlaymiddle, middle, overlay;
|
||||||
|
ShapeRenderer shaperenderer;
|
||||||
|
|
||||||
public Laser() {
|
public Laser() {
|
||||||
i = 0;
|
i = 0;
|
||||||
overlaymiddle = AssetLoader.Skin_level.getAtlas().findRegion(
|
overlaymiddle = AssetLoader.Skin_level.getAtlas().findRegion("overlay-middle");
|
||||||
"overlay-middle");
|
|
||||||
middle = AssetLoader.Skin_level.getAtlas().findRegion("middle");
|
middle = AssetLoader.Skin_level.getAtlas().findRegion("middle");
|
||||||
overlay = AssetLoader.Skin_level.getAtlas().findRegion("overlay");
|
overlay = AssetLoader.Skin_level.getAtlas().findRegion("overlay");
|
||||||
|
shaperenderer=new ShapeRenderer();
|
||||||
|
shaperenderer.setProjectionMatrix(AssetLoader.Camera.combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Batch Laser, float xx1, float yy1, float xx2, float yy2,
|
public void draw(Batch Laser, float xx1, float yy1, float xx2, float yy2,
|
||||||
float maxwidth, float power, boolean active, Color colorsrc,
|
float maxwidth, float power, boolean active, Color colorsrc,
|
||||||
Color colordst) {
|
Color colordst) {
|
||||||
float x1 = xx1 + 26;
|
|
||||||
float y1 = yy1 + 20;
|
float y1 = yy1 + 20;
|
||||||
float x2 = xx2 + 26;
|
|
||||||
float y2 = yy2 + 20;
|
float y2 = yy2 + 20;
|
||||||
|
if (active) {
|
||||||
|
float x1 = xx1 + 26;
|
||||||
|
float x2 = xx2 + 26;
|
||||||
Vector2 vector1 = new Vector2(x1, y1);
|
Vector2 vector1 = new Vector2(x1, y1);
|
||||||
Vector2 vector2 = new Vector2(x2, y2);
|
Vector2 vector2 = new Vector2(x2, y2);
|
||||||
Vector2 vectorall = vector2.sub(vector1);
|
Vector2 vectorall = vector2.sub(vector1);
|
||||||
|
@ -40,19 +43,23 @@ public class Laser {
|
||||||
Laser.begin();
|
Laser.begin();
|
||||||
Laser.setColor(colorsrc);
|
Laser.setColor(colorsrc);
|
||||||
Laser.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
|
Laser.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
|
||||||
Laser.draw(overlaymiddle, x1, y1, 32, 0, 64, vectorall.len(), 1f, 1f,
|
Laser.draw(overlaymiddle, x1, y1, 32, 0, 64, vectorall.len(), 1f, 1f,vectorall.angle() + 270);
|
||||||
vectorall.angle() + 270);
|
Laser.draw(middle, x1, y1, 32, 0, 64, vectorall.len(), 1f, 1f,vectorall.angle() + 270);
|
||||||
Laser.draw(middle, x1, y1, 32, 0, 64, vectorall.len(), 1f, 1f,
|
|
||||||
vectorall.angle() + 270);
|
|
||||||
Laser.setColor(new Color(1f, 1f, 1f, 1f));
|
Laser.setColor(new Color(1f, 1f, 1f, 1f));
|
||||||
for (int j = 0; j < (vectorall.len() - vectoradd.cpy()
|
for (int j = 0; j < (vectorall.len() - vectoradd.cpy().setLength(i * inc).len()) / 64 - 1; j++)
|
||||||
.setLength(i * inc).len()) / 64 - 1; j++)
|
Laser.draw(overlay, x1 + i * vectoradd.x + j * vectoraddit.x, y1+ i * vectoradd.y + j * vectoraddit.y, 32, 0, 64, 64, 1f,1f, vectorall.angle() + 270);
|
||||||
Laser.draw(overlay, x1 + i * vectoradd.x + j * vectoraddit.x, y1
|
|
||||||
+ i * vectoradd.y + j * vectoraddit.y, 32, 0, 64, 64, 1f,
|
|
||||||
1f, vectorall.angle() + 270);
|
|
||||||
Laser.draw(overlay, x1, y1, 32, 0, 64, i * inc, 1f, 1f,
|
Laser.draw(overlay, x1, y1, 32, 0, 64, i * inc, 1f, 1f,
|
||||||
vectorall.angle() + 270);
|
vectorall.angle() + 270);
|
||||||
Laser.end();
|
Laser.end();
|
||||||
|
} else {
|
||||||
|
float x1 = xx1 + 56;
|
||||||
|
float x2 = xx2 + 56;
|
||||||
|
shaperenderer.begin(ShapeType.Filled);
|
||||||
|
Color Acolor = new Color(0.5f, 0.5f, 0.5f, 1f);
|
||||||
|
shaperenderer.setColor(Acolor);
|
||||||
|
shaperenderer.rectLine(x1, y1, x2, y2, 2);
|
||||||
|
shaperenderer.end();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawnotsoold(ShapeRenderer Laser, float xx1, float yy1,
|
public void drawnotsoold(ShapeRenderer Laser, float xx1, float yy1,
|
||||||
|
@ -64,7 +71,7 @@ public class Laser {
|
||||||
float y2 = yy2 + 20;
|
float y2 = yy2 + 20;
|
||||||
Laser.begin(ShapeType.Filled);
|
Laser.begin(ShapeType.Filled);
|
||||||
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
|
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
if (active) {
|
if (true) {
|
||||||
Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1));
|
Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1));
|
||||||
float length = vectorall.len();
|
float length = vectorall.len();
|
||||||
float size = 20;
|
float size = 20;
|
||||||
|
@ -74,13 +81,10 @@ public class Laser {
|
||||||
float width = (float) (maxwidth - Math.random() * 2);
|
float width = (float) (maxwidth - Math.random() * 2);
|
||||||
while (width >= 0) {
|
while (width >= 0) {
|
||||||
adding = (width * power / maxwidth);
|
adding = (width * power / maxwidth);
|
||||||
Color Acolor = colorsrc.cpy().lerp(colordst.cpy(),
|
Color Acolor = colorsrc.cpy().lerp(colordst.cpy(),(i / (length / size)));
|
||||||
(i / (length / size)));
|
|
||||||
Laser.setColor(Acolor.add(adding, adding, adding, 0.5f));
|
Laser.setColor(Acolor.add(adding, adding, adding, 0.5f));
|
||||||
if (Math.random() > 0.4)
|
if (Math.random() > 0.4)
|
||||||
Laser.rectLine(x1 + i * vectoradd.x, y1 + i
|
Laser.rectLine(x1 + i * vectoradd.x, y1 + i * vectoradd.y, x1 + (i + 1) * vectoradd.x, y1+ (i + 1) * vectoradd.y, width);
|
||||||
* vectoradd.y, x1 + (i + 1) * vectoradd.x, y1
|
|
||||||
+ (i + 1) * vectoradd.y, width);
|
|
||||||
width = width - 1;
|
width = width - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,14 +119,10 @@ public class Laser {
|
||||||
vec2.clamp(length - i, length - i);
|
vec2.clamp(length - i, length - i);
|
||||||
while (width >= 0) {
|
while (width >= 0) {
|
||||||
adding = (width * power / maxwidth);
|
adding = (width * power / maxwidth);
|
||||||
Color Acolor = colordst.cpy()
|
Color Acolor = colordst.cpy().lerp(colorsrc.cpy(), (i / length));
|
||||||
.lerp(colorsrc.cpy(), (i / length));
|
|
||||||
Laser.setColor(Acolor.add(adding, adding, adding, 1f));
|
Laser.setColor(Acolor.add(adding, adding, adding, 1f));
|
||||||
if (size > 0.4f) {
|
if (size > 0.4f) {Laser.point(x1 + vec2.x - width / 2, y1 + vec2.y + width/ 2, 0);
|
||||||
Laser.point(x1 + vec2.x - width / 2, y1 + vec2.y + width
|
Laser.point(x1 + vec2.x + width / 2, y1 + vec2.y - width/ 2, 0);
|
||||||
/ 2, 0);
|
|
||||||
Laser.point(x1 + vec2.x + width / 2, y1 + vec2.y - width
|
|
||||||
/ 2, 0);
|
|
||||||
}
|
}
|
||||||
width = width - 1;
|
width = width - 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class LevelRenderer {
|
||||||
* AssetLoader.ratio,
|
* AssetLoader.ratio,
|
||||||
10,
|
10,
|
||||||
0.5f,
|
0.5f,
|
||||||
LevelScreen.buttonLevels[found].Activated,
|
LevelScreen.buttonLevels[i].level.Locked,
|
||||||
LevelScreen.buttonLevels[i]
|
LevelScreen.buttonLevels[i]
|
||||||
.getLevelcolor(),
|
.getLevelcolor(),
|
||||||
LevelScreen.buttonLevels[found]
|
LevelScreen.buttonLevels[found]
|
||||||
|
@ -162,7 +162,7 @@ public class LevelRenderer {
|
||||||
* AssetLoader.ratio,
|
* AssetLoader.ratio,
|
||||||
10,
|
10,
|
||||||
0.5f,
|
0.5f,
|
||||||
LevelScreen.buttonLevels[found].Activated,
|
LevelScreen.buttonLevels[i].level.Locked,
|
||||||
LevelScreen.buttonLevels[i]
|
LevelScreen.buttonLevels[i]
|
||||||
.getLevelcolor(),
|
.getLevelcolor(),
|
||||||
LevelScreen.buttonLevels[found]
|
LevelScreen.buttonLevels[found]
|
||||||
|
|
|
@ -92,10 +92,7 @@ public class GameScreen implements Screen {
|
||||||
info_up_cycleval, nextpage, previouspage;
|
info_up_cycleval, nextpage, previouspage;
|
||||||
private ImageTextButton cycle, temp, nrj, rayon, cout, tech, research,
|
private ImageTextButton cycle, temp, nrj, rayon, cout, tech, research,
|
||||||
info_cout, info_tech, info_research, info_activation;
|
info_cout, info_tech, info_research, info_activation;
|
||||||
String[] tocreate = { "run", "stop", "speed", "separator", "move#", "zoomp#",
|
String[] tocreate;
|
||||||
"zoomm#", "infos#", "separator", "raz", "save", "levels", "tree",
|
|
||||||
"exits", "separator", "screen", "sound", "tuto", "grid", "settings",
|
|
||||||
"separator", "stat" };
|
|
||||||
private ButtonLevel buttonlevel;
|
private ButtonLevel buttonlevel;
|
||||||
private Objectives objectives;
|
private Objectives objectives;
|
||||||
public TouchMaptiles map;
|
public TouchMaptiles map;
|
||||||
|
@ -201,9 +198,15 @@ public class GameScreen implements Screen {
|
||||||
|
|
||||||
// This is the constructor, not the class declaration
|
// This is the constructor, not the class declaration
|
||||||
public GameScreen(Worlds aworlds) {
|
public GameScreen(Worlds aworlds) {
|
||||||
Gdx.app.log("game", "Ok");
|
Gdx.app.debug(getClass().getSimpleName(),"Préparation du screen");
|
||||||
this.worlds = aworlds;
|
this.worlds = aworlds;
|
||||||
this.level=worlds.getInformations();
|
this.level=worlds.getInformations();
|
||||||
|
if (level.Tech<1)
|
||||||
|
tocreate = new String[] { "run", "stop", "speed", "separator", "move#", "zoomp#","zoomm#", "separator", "levels", "exits", "separator", "screen", "sound", "settings" };
|
||||||
|
else if (level.aWorld<1)
|
||||||
|
tocreate = new String[] { "run", "stop", "speed", "separator", "move#", "zoomp#","zoomm#", "infos#", "separator", "raz", "save", "levels", "exits", "separator", "screen", "sound", "grid", "settings" };
|
||||||
|
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" };
|
||||||
Gdx.app.debug(getClass().getSimpleName(),"Récupération des derniers niveaux.");
|
Gdx.app.debug(getClass().getSimpleName(),"Récupération des derniers niveaux.");
|
||||||
worlds.ReadLastGrid();
|
worlds.ReadLastGrid();
|
||||||
if (this.level.Grid == null) {
|
if (this.level.Grid == null) {
|
||||||
|
@ -270,7 +273,7 @@ public class GameScreen implements Screen {
|
||||||
objectives.setVictory(level.Victory);
|
objectives.setVictory(level.Victory);
|
||||||
objectives.setPosition(890, AssetLoader.height - 95);
|
objectives.setPosition(890, AssetLoader.height - 95);
|
||||||
objectives.setVisible(level.Cout>0);
|
objectives.setVisible(level.Cout>0);
|
||||||
buttonlevel = new ButtonLevel(level, true, 1.0f, false);
|
buttonlevel = new ButtonLevel(level, 1.0f, false);
|
||||||
buttonlevel.setPosition(1760, AssetLoader.height - 125);
|
buttonlevel.setPosition(1760, AssetLoader.height - 125);
|
||||||
buttonlevel.addListener(new ClickListener() {
|
buttonlevel.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class LevelScreen implements Screen {
|
||||||
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]");
|
||||||
if (level.Description.isEmpty())
|
if (level.Description.isEmpty())
|
||||||
level.Description=AssetLoader.language.get("[level"+(level.aWorld+1)+"/"+(level.aLevel+1)+"-desc]");
|
level.Description=AssetLoader.language.get("[level"+(level.aWorld+1)+"/"+(level.aLevel+1)+"-desc]");
|
||||||
buttonLevels[i] = new ButtonLevel(level, true, AssetLoader.ratio, true);
|
buttonLevels[i] = new ButtonLevel(level, AssetLoader.ratio, true);
|
||||||
Gdx.app.debug(getClass().getSimpleName(), "Ajout du niveau :"
|
Gdx.app.debug(getClass().getSimpleName(), "Ajout du niveau :"
|
||||||
+ level.Name + " N°" + String.valueOf(level.aLevel));
|
+ level.Name + " N°" + String.valueOf(level.aLevel));
|
||||||
buttonLevels[i++].addListener(new ClickListener() {
|
buttonLevels[i++].addListener(new ClickListener() {
|
||||||
|
|
Loading…
Reference in New Issue