feat: ajout de la gestion des verrouillages des niveaux (incomplet)

This commit is contained in:
Nicolas Hordé 2016-01-30 01:27:27 +01:00
parent 1f3fe69f61
commit 7efec490f4
8 changed files with 62 additions and 50 deletions

View File

@ -13,7 +13,6 @@ import fr.evolving.automata.Level;
public class ButtonLevel extends ImageTextButton {
public Level level;
public boolean Activated;
private TextureRegion Finalled, Locked;
private Label Thelabel;
private float scale;
@ -22,17 +21,16 @@ public class ButtonLevel extends ImageTextButton {
private LabelStyle stylelabel;
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"
+ String.valueOf(level.aWorld));
this.modifyxy=modifyxy;
this.level = level;
this.ratio = ratio;
this.Activated = Activated;
if (level.Special == true) {
Finalled = AssetLoader.Skin_level.getAtlas().findRegion("boss");
}
if (Activated == false) {
if (level.Locked == false) {
this.setDisabled(true);
Locked = AssetLoader.Skin_level.getAtlas().findRegion("locked");
}
@ -90,7 +88,7 @@ public class ButtonLevel extends ImageTextButton {
Finalled.getRegionWidth() * scale,
Finalled.getRegionHeight() * scale);
}
if (!Activated) {
if (!level.Locked) {
batch.draw(
Locked,
getX() + this.getWidth() - Locked.getRegionWidth(),

View File

@ -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[17].setChecked(Preference.prefs.getBoolean("Tutorial"));
Barre[18].setChecked(Preference.prefs.getBoolean("Grid"));
Barre[18].setChecked(Preference.prefs.getBoolean("Grid"));*/
table = new HorizontalGroup();
table.bottom().padLeft(5f).padBottom(8f).space(10f);
this.setTouchable(Touchable.enabled);

View File

@ -16,11 +16,10 @@ public class Level implements Serializable {
public int Tech;
public int Cout;
public Grid Grid_orig;
public transient Grid Grid;
public int Cycle;
public int Temp;
public int Rayon;
public int Nrj;
public int Cycle_orig;
public int Temp_orig;
public int Rayon_orig;
public int Nrj_orig;
public int Maxcycle;
public int Maxtemp;
public int Maxrayon;
@ -29,6 +28,13 @@ public class Level implements Serializable {
public boolean Special;
public String Tuto;
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,
String Description, String Element, int[] Current, int[] Victory,

View File

@ -41,7 +41,7 @@ public class Worlds extends Actor {
state=State.notloaded;
this.load(name);
this.ReadTransmuters();
//if (state==State.notloaded)
if (state==State.notloaded)
create(name);
onchanged();
}
@ -58,7 +58,6 @@ public class Worlds extends Actor {
}
public void SaveResearch() {
this.research=research;
AssetLoader.Datahandler.user().setResearchpoint(0,research);
}
@ -133,7 +132,13 @@ public class Worlds extends Actor {
{
for(Level level:levels)
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);
}
return tempworld;
}
else

View File

@ -15,22 +15,25 @@ public class Laser {
public float i = 0;
TextureRegion overlaymiddle, middle, overlay;
ShapeRenderer shaperenderer;
public Laser() {
i = 0;
overlaymiddle = AssetLoader.Skin_level.getAtlas().findRegion(
"overlay-middle");
overlaymiddle = AssetLoader.Skin_level.getAtlas().findRegion("overlay-middle");
middle = AssetLoader.Skin_level.getAtlas().findRegion("middle");
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,
float maxwidth, float power, boolean active, Color colorsrc,
Color colordst) {
float x1 = xx1 + 26;
float y1 = yy1 + 20;
float x2 = xx2 + 26;
float y2 = yy2 + 20;
if (active) {
float x1 = xx1 + 26;
float x2 = xx2 + 26;
Vector2 vector1 = new Vector2(x1, y1);
Vector2 vector2 = new Vector2(x2, y2);
Vector2 vectorall = vector2.sub(vector1);
@ -40,19 +43,23 @@ public class Laser {
Laser.begin();
Laser.setColor(colorsrc);
Laser.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
Laser.draw(overlaymiddle, 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.draw(overlaymiddle, 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));
for (int j = 0; j < (vectorall.len() - vectoradd.cpy()
.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);
for (int j = 0; j < (vectorall.len() - vectoradd.cpy().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, y1, 32, 0, 64, i * inc, 1f, 1f,
vectorall.angle() + 270);
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,
@ -64,7 +71,7 @@ public class Laser {
float y2 = yy2 + 20;
Laser.begin(ShapeType.Filled);
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));
float length = vectorall.len();
float size = 20;
@ -74,13 +81,10 @@ public class Laser {
float width = (float) (maxwidth - Math.random() * 2);
while (width >= 0) {
adding = (width * power / maxwidth);
Color Acolor = colorsrc.cpy().lerp(colordst.cpy(),
(i / (length / size)));
Color Acolor = colorsrc.cpy().lerp(colordst.cpy(),(i / (length / size)));
Laser.setColor(Acolor.add(adding, adding, adding, 0.5f));
if (Math.random() > 0.4)
Laser.rectLine(x1 + i * vectoradd.x, y1 + i
* vectoradd.y, x1 + (i + 1) * vectoradd.x, y1
+ (i + 1) * vectoradd.y, width);
Laser.rectLine(x1 + i * vectoradd.x, y1 + i * vectoradd.y, x1 + (i + 1) * vectoradd.x, y1+ (i + 1) * vectoradd.y, width);
width = width - 1;
}
}
@ -115,14 +119,10 @@ public class Laser {
vec2.clamp(length - i, length - i);
while (width >= 0) {
adding = (width * power / maxwidth);
Color Acolor = colordst.cpy()
.lerp(colorsrc.cpy(), (i / length));
Color Acolor = colordst.cpy().lerp(colorsrc.cpy(), (i / length));
Laser.setColor(Acolor.add(adding, adding, adding, 1f));
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
/ 2, 0);
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/ 2, 0);
}
width = width - 1;
}

View File

@ -146,7 +146,7 @@ public class LevelRenderer {
* AssetLoader.ratio,
10,
0.5f,
LevelScreen.buttonLevels[found].Activated,
LevelScreen.buttonLevels[i].level.Locked,
LevelScreen.buttonLevels[i]
.getLevelcolor(),
LevelScreen.buttonLevels[found]
@ -162,7 +162,7 @@ public class LevelRenderer {
* AssetLoader.ratio,
10,
0.5f,
LevelScreen.buttonLevels[found].Activated,
LevelScreen.buttonLevels[i].level.Locked,
LevelScreen.buttonLevels[i]
.getLevelcolor(),
LevelScreen.buttonLevels[found]

View File

@ -92,10 +92,7 @@ public class GameScreen implements Screen {
info_up_cycleval, nextpage, previouspage;
private ImageTextButton cycle, temp, nrj, rayon, cout, tech, research,
info_cout, info_tech, info_research, info_activation;
String[] tocreate = { "run", "stop", "speed", "separator", "move#", "zoomp#",
"zoomm#", "infos#", "separator", "raz", "save", "levels", "tree",
"exits", "separator", "screen", "sound", "tuto", "grid", "settings",
"separator", "stat" };
String[] tocreate;
private ButtonLevel buttonlevel;
private Objectives objectives;
public TouchMaptiles map;
@ -201,9 +198,15 @@ public class GameScreen implements Screen {
// This is the constructor, not the class declaration
public GameScreen(Worlds aworlds) {
Gdx.app.log("game", "Ok");
Gdx.app.debug(getClass().getSimpleName(),"Préparation du screen");
this.worlds = aworlds;
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.");
worlds.ReadLastGrid();
if (this.level.Grid == null) {
@ -270,7 +273,7 @@ public class GameScreen implements Screen {
objectives.setVictory(level.Victory);
objectives.setPosition(890, AssetLoader.height - 95);
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.addListener(new ClickListener() {
@Override

View File

@ -207,7 +207,7 @@ public class LevelScreen implements Screen {
level.Name=AssetLoader.language.get("[level"+(level.aWorld+1)+"/"+(level.aLevel+1)+"-name]");
if (level.Description.isEmpty())
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 :"
+ level.Name + "" + String.valueOf(level.aLevel));
buttonLevels[i++].addListener(new ClickListener() {