diff --git a/core/src/fr/evolving/assets/InitWorlds.java b/core/src/fr/evolving/assets/InitWorlds.java index 22c6d85..b192ca2 100644 --- a/core/src/fr/evolving/assets/InitWorlds.java +++ b/core/src/fr/evolving/assets/InitWorlds.java @@ -12,7 +12,6 @@ public class InitWorlds { thelevels[0] = new Level( 0, 0, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "e0", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -23,7 +22,6 @@ public class InitWorlds { thelevels[1] = new Level( 0, 1, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "e0", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -34,7 +32,6 @@ public class InitWorlds { thelevels[2] = new Level( 0, 2, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "e0", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -45,7 +42,6 @@ public class InitWorlds { thelevels[3] = new Level( 0, 3, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "e+", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -56,7 +52,6 @@ public class InitWorlds { thelevels[4] = new Level( 0, 4, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "E-", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -67,7 +62,6 @@ public class InitWorlds { thelevels[5] = new Level( 0, 5, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "e0", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -78,7 +72,6 @@ public class InitWorlds { thelevels[6] = new Level( 0, 6, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "eX", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -89,7 +82,6 @@ public class InitWorlds { thelevels[7] = new Level( 0, 7, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "p", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -100,7 +92,6 @@ public class InitWorlds { thelevels[8] = new Level( 0, 8, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "H", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -111,7 +102,6 @@ public class InitWorlds { thelevels[9] = new Level( 1, 0, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "D", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -122,7 +112,6 @@ public class InitWorlds { thelevels[10] = new Level( 1, 1, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "T", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -133,7 +122,6 @@ public class InitWorlds { thelevels[11] = new Level( 1, 2, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "He", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -144,7 +132,6 @@ public class InitWorlds { thelevels[12] = new Level( 1, 3, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "He", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -155,7 +142,6 @@ public class InitWorlds { thelevels[13] = new Level( 1, 4, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "He", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -166,7 +152,6 @@ public class InitWorlds { thelevels[14] = new Level( 1, 5, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Li", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -177,7 +162,6 @@ public class InitWorlds { thelevels[15] = new Level( 1, 6, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Be", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -188,7 +172,6 @@ public class InitWorlds { thelevels[16] = new Level( 1, 7, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "B", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -199,7 +182,6 @@ public class InitWorlds { thelevels[17] = new Level( 1, 8, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "C", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -212,7 +194,6 @@ public class InitWorlds { thelevels[18] = new Level( 2, 0, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "N", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -223,7 +204,6 @@ public class InitWorlds { thelevels[19] = new Level( 2, 1, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "N", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -234,7 +214,6 @@ public class InitWorlds { thelevels[20] = new Level( 2, 2, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "O", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -245,7 +224,6 @@ public class InitWorlds { thelevels[21] = new Level( 2, 3, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "O", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -256,7 +234,6 @@ public class InitWorlds { thelevels[22] = new Level( 2, 4, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "F", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -267,7 +244,6 @@ public class InitWorlds { thelevels[23] = new Level( 2, 5, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Ne", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -278,7 +254,6 @@ public class InitWorlds { thelevels[24] = new Level( 2, 6, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Ne", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -289,7 +264,6 @@ public class InitWorlds { thelevels[25] = new Level( 2, 7, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Ne", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -300,7 +274,6 @@ public class InitWorlds { thelevels[26] = new Level( 2, 8, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Na", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -313,7 +286,6 @@ public class InitWorlds { thelevels[27] = new Level( 3, 0, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Mg", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -323,7 +295,6 @@ public class InitWorlds { thelevels[28] = new Level( 3, 1, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Mg", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -333,7 +304,6 @@ public class InitWorlds { thelevels[29] = new Level( 3, 2, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Mg", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -343,7 +313,6 @@ public class InitWorlds { thelevels[30] = new Level( 3, 3, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Al", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -353,7 +322,6 @@ public class InitWorlds { thelevels[31] = new Level( 3, 4, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Si", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -363,7 +331,6 @@ public class InitWorlds { thelevels[32] = new Level( 3, 5, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Si", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -373,7 +340,6 @@ public class InitWorlds { thelevels[33] = new Level( 3, 6, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Si", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -383,7 +349,6 @@ public class InitWorlds { thelevels[34] = new Level( 3, 7, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Si", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -393,7 +358,6 @@ public class InitWorlds { thelevels[35] = new Level( 3, 8, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "O", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -405,7 +369,6 @@ public class InitWorlds { thelevels[36] = new Level( 4, 0, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "P", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -415,7 +378,6 @@ public class InitWorlds { thelevels[37] = new Level( 4, 1, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "S", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -425,7 +387,6 @@ public class InitWorlds { thelevels[38] = new Level( 4, 2, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "S", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -435,7 +396,6 @@ public class InitWorlds { thelevels[39] = new Level( 4, 3, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "S", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -445,7 +405,6 @@ public class InitWorlds { thelevels[40] = new Level( 4, 4, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "S", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -455,7 +414,6 @@ public class InitWorlds { thelevels[41] = new Level( 4, 5, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Cl", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -465,7 +423,6 @@ public class InitWorlds { thelevels[42] = new Level( 4, 6, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Cl", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -475,7 +432,6 @@ public class InitWorlds { thelevels[43] = new Level( 4, 7, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Ar", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -485,7 +441,6 @@ public class InitWorlds { thelevels[44] = new Level( 4, 8, - (int) (Math.random() * Integer.MAX_VALUE), "", "", "Ar", new int[] { 0, 0, 0, 0, 0, 0 }, diff --git a/core/src/fr/evolving/automata/Level.java b/core/src/fr/evolving/automata/Level.java index 0335e64..607b52c 100644 --- a/core/src/fr/evolving/automata/Level.java +++ b/core/src/fr/evolving/automata/Level.java @@ -2,7 +2,7 @@ package fr.evolving.automata; import java.io.Serializable; -public class Level implements Serializable { +public class Level implements Serializable,Cloneable { public String Name; public String Description; public String Element; @@ -42,14 +42,14 @@ public class Level implements Serializable { public transient boolean Locked; - public Level(int aWorld, int aLevel, int id, String Name, + 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.id = id; + this.id = (int) (Math.random() * Integer.MAX_VALUE); this.Name = Name; this.Description = Description; this.Element = Element; @@ -73,4 +73,10 @@ public class Level implements Serializable { this.Tuto = Tuto; this.Link = Link; } + + public Object clone() { + Level result = new Level(this.aWorld, this.aLevel, this.Name+" BIS", this.Description, this.Element, this.rewards.clone(), this.Victory_orig.clone(), this.X+100f, this.Y+100f, this.Tech, this.Cout_orig, (Grid)this.Grid_orig.clone(), this.Cycle_orig, this.Temp_orig, this.Rayon_orig, this.Nrj_orig, this.Maxcycle, this.Maxtemp, this.Maxrayon, this.Maxnrj, this.Tuto, this.Special, this.Link); + return result; + } + } diff --git a/core/src/fr/evolving/automata/Worlds.java b/core/src/fr/evolving/automata/Worlds.java index 2714024..b603a02 100644 --- a/core/src/fr/evolving/automata/Worlds.java +++ b/core/src/fr/evolving/automata/Worlds.java @@ -233,7 +233,18 @@ public class Worlds extends Actor { if (this.usedlevel!=null && this.usedlevel.aLevel==levelid) this.usedlevel=null; onchanged(level); - this.showlevels(); + } + } + + public void dupLevel() { + dupLevel(usedlevel.aLevel); + } + + public void dupLevel(int levelid) { + Level level=(Level) findLevel(levelid).clone(); + if (level!=null) { + level.aLevel=getFreeLevel(); + addLevel(level); } } @@ -243,7 +254,6 @@ public class Worlds extends Actor { public void addLevel(Level level) { levels.add(level); - this.showlevels(); onchanged(level); } @@ -308,10 +318,13 @@ public class Worlds extends Actor { public void unLockLevel() { AssetLoader.Datahandler.user().setLevelunlock(0, usedlevel.id); + usedlevel.Locked=false; } public void unLockLevel(int levelid) { - AssetLoader.Datahandler.user().setLevelunlock(0, levelid); + Level level=findLevel(levelid); + AssetLoader.Datahandler.user().setLevelunlock(0, level.id); + findLevel(levelid).Locked=false; } public void set(String campaign) { diff --git a/core/src/fr/evolving/screens/LevelScreen.java b/core/src/fr/evolving/screens/LevelScreen.java index bf71355..dc850cf 100644 --- a/core/src/fr/evolving/screens/LevelScreen.java +++ b/core/src/fr/evolving/screens/LevelScreen.java @@ -21,9 +21,11 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label; 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.VerticalGroup; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent; +import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Array; import fr.evolving.UI.ButtonLevel; @@ -31,6 +33,7 @@ import fr.evolving.UI.Objectives; import fr.evolving.UI.ServerList; import fr.evolving.UI.Transhower; import fr.evolving.UI.Translist; +import fr.evolving.UI.VertiBarre; import fr.evolving.UI.Worldlist; import fr.evolving.assets.AssetLoader; import fr.evolving.assets.InitWorlds; @@ -53,7 +56,7 @@ public class LevelScreen implements Screen { private Stage stage; private Table table; private WarningDialog dialog; - private ImageButton Previous, Next, Exit, logosmall, databaseSave, adder, signer, finisher, deletelinker, deletebutton, addbutton; + private ImageButton Previous, Next, Exit, logosmall, databaseSave, adder, signer, finisher, deletelinker, deletebutton, addbutton, unlocked, duplicate; public Image MenuSolo, MenuMulti, MenuScenario; private ImageTextButton cout, tech, cycle, temp, rayon, nrj, up_cycle, up_temp, up_rayon, up_nrj, research, up; private TextButton buttonConnect, buttonPlay, buttonStat, buttonSave, buttonApply, buttonPlaythis; @@ -63,6 +66,7 @@ public class LevelScreen implements Screen { private TextArea TextDescriptive; public Worlds worlds; private Objectives Victory; + private VerticalGroup vertibar; public ButtonLevel selected; public int addervalue; public ButtonGroup chooser; @@ -151,26 +155,21 @@ public class LevelScreen implements Screen { public ClickListener buttonLevelslistener() { return new ClickListener() { @Override - public void enter(InputEvent event, float x, float y, - int pointer, Actor fromActor) { - ButtonLevel abutton = (ButtonLevel) event - .getListenerActor(); + public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { + ButtonLevel abutton = (ButtonLevel) event.getListenerActor(); Gdx.app.debug("wirechem-LevelScreen","Enter button "); if (!abutton.isChecked() && (!abutton.level.Locked || worlds.isDebug())) showlevel(abutton); } - public void exit(InputEvent event, float x, float y, - int pointer, Actor fromActor) { - ButtonLevel abutton = (ButtonLevel) event - .getListenerActor(); + public void exit(InputEvent event, float x, float y,int pointer, Actor fromActor) { + ButtonLevel abutton = (ButtonLevel) event.getListenerActor(); Gdx.app.debug("wirechem-LevelScreen","Enter button "); if (!abutton.isChecked() && (!abutton.level.Locked || worlds.isDebug())) showlevel(abutton); } - public void touchDragged(InputEvent event, float x, - float y, int pointer) { + public void touchDragged(InputEvent event, float x, float y, int pointer) { ButtonLevel abutton = (ButtonLevel) event.getListenerActor(); if (worlds.isDebug()) { abutton.setPosition(event.getStageX() - 56, event.getStageY() - 20); @@ -222,6 +221,7 @@ public class LevelScreen implements Screen { buttonLevels.add(button); stage.addActor(button); button.addListener(buttonLevelslistener()); + showlevel(button); return; } LevelScreen.this.loadWorld(); @@ -791,7 +791,23 @@ public class LevelScreen implements Screen { //Group Debug //********************************************************** Gdx.app.debug("wirechem-LevelScreen", "Création du groupe Debug."); - deletebutton = new ImageButton(AssetLoader.Skin_level, "boss"); + unlocked = new ImageButton(AssetLoader.Skin_level, "unlocked"); + unlocked.setPosition(1460, 140); + unlocked.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + worlds.unLockLevel(selected.level.aLevel); + } + }); + duplicate = new ImageButton(AssetLoader.Skin_level, "duplicate"); + duplicate.setPosition(1460, 140); + duplicate.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + worlds.dupLevel(selected.level.aLevel); + } + }); + deletebutton = new ImageButton(AssetLoader.Skin_level, "eraser"); deletebutton.setPosition(1460, 140); deletebutton.addListener(new ClickListener() { @Override @@ -817,13 +833,12 @@ public class LevelScreen implements Screen { button.level.Link=links.toArray(); } Gdx.app.debug("wirechem-LevelScreen", "Destruction du bouton :"+selected.level.aLevel); - //buttonLevels.removeValue(selected, true); worlds.delLevel(selected.level.aLevel); - //selected.remove(); + selectone(); } } }); - deletelinker = new ImageButton(AssetLoader.Skin_level, "boss"); + deletelinker = new ImageButton(AssetLoader.Skin_level, "cut"); deletelinker.setPosition(1560, 140); deletelinker.addListener(new ClickListener() { @Override @@ -842,7 +857,7 @@ public class LevelScreen implements Screen { } } }); - addbutton = new ImageButton(AssetLoader.Skin_level, "boss"); + addbutton = new ImageButton(AssetLoader.Skin_level, "level"); addbutton.setPosition(1760, 540); addbutton.addListener(new ClickListener() { @Override @@ -850,7 +865,6 @@ public class LevelScreen implements Screen { Level level=new Level( worlds.getWorld(), worlds.getFreeLevel(), - (int) (Math.random() * Integer.MAX_VALUE), "Unknown", "Unknown", "Uk", new int[] { 0, 0, 0, 0, 0, 0 }, @@ -858,13 +872,9 @@ public class LevelScreen implements Screen { (float)Math.random() * 750f, 0, 0, new Grid(3, 3), 0, 0, 0, 0, 99999, 99999, 99999, 99999, "", false, new int[][] {{}}); worlds.addLevel(level); - //ButtonLevel button=new ButtonLevel(level, AssetLoader.ratio, true); - //buttonLevels.add(button); - //stage.addActor(button); - //button.addListener(buttonLevelslistener()); } }); - finisher = new ImageButton(AssetLoader.Skin_level, "boss"); + finisher = new ImageButton(AssetLoader.Skin_level, "finish"); finisher.setSize(64, 64); finisher.setPosition(1560, 40); finisher.addListener(new ClickListener() { @@ -880,7 +890,7 @@ public class LevelScreen implements Screen { } }); signer = new ImageButton(AssetLoader.Skin_level, "add"); - signer.setPosition(1660, 40); + signer.setPosition(1280, AssetLoader.height-650); signer.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { @@ -899,7 +909,7 @@ public class LevelScreen implements Screen { } }); adder = new ImageButton(AssetLoader.Skin_level, "add1"); - adder.setPosition(1720, 40); + adder.setPosition(1340, AssetLoader.height-650); adder.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { @@ -926,15 +936,22 @@ public class LevelScreen implements Screen { worlds.save(worlds.getName()); } }); - + vertibar=new VerticalGroup(); + vertibar.setPosition(1600, AssetLoader.height-500); + vertibar.center(); + vertibar.addActor(databaseSave); + vertibar.space(20f); + vertibar.addActor(deletebutton); + vertibar.addActor(addbutton); + vertibar.addActor(duplicate); + vertibar.addActor(deletelinker); + vertibar.addActor(unlocked); + vertibar.addActor(finisher); + vertibar.addActor(databaseSave); group_debug=new Group(); - group_debug.addActor(databaseSave); group_debug.addActor(adder); group_debug.addActor(signer); - group_debug.addActor(finisher); - group_debug.addActor(deletelinker); - group_debug.addActor(deletebutton); - group_debug.addActor(addbutton); + group_debug.addActor(vertibar); //********************************************************** Gdx.app.debug("wirechem-LevelScreen", "Affichage du menu."); @@ -991,6 +1008,16 @@ public class LevelScreen implements Screen { public void dispose() { stage.dispose(); } + + public void selectone() { + for(ButtonLevel button: buttonLevels) + if (button!=null) { + selected=button; + selected.setChecked(true); + return; + } + return; + } public void showlevel(ButtonLevel button) { if (button==null) diff --git a/core/src/fr/evolving/screens/SplashScreen.java b/core/src/fr/evolving/screens/SplashScreen.java index f71311d..eb89b4b 100644 --- a/core/src/fr/evolving/screens/SplashScreen.java +++ b/core/src/fr/evolving/screens/SplashScreen.java @@ -64,10 +64,8 @@ public class SplashScreen implements Screen { if (AssetLoader.manager != null) { batcher.begin(); batcher.setProjectionMatrix(AssetLoader.Camera.combined); - AssetLoader.empty.draw(batcher, (AssetLoader.width / 2) - 400f, - 150f, 800f, 50f); - AssetLoader.full.draw(batcher, (AssetLoader.width / 2) - 400f, - 150f, AssetLoader.manager.getProgress() * 800f, 50f); + AssetLoader.empty.draw(batcher, (AssetLoader.width / 2) - 400f, 150f, 800f, 50f); + AssetLoader.full.draw(batcher, (AssetLoader.width / 2) - 400f, 150f, AssetLoader.manager.getProgress() * 800f, 50f); AssetLoader.manager.update(); batcher.end(); }