From c99a91629791250e3dd8678c206759ed70f828a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Fri, 29 Jan 2016 00:11:01 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20centralisation=20dans=20l'objet=20worlds?= =?UTF-8?q?=20des=20informations=20relatives=20=C3=A0=20la=20gestion=20du?= =?UTF-8?q?=20monde=20sauvegarde/restauration=20des=20transmuteurs=20gesti?= =?UTF-8?q?on=20des=20points=20de=20recherche=20sauvegarde/restauration=20?= =?UTF-8?q?de=20la=20grille=20par=20l'object=20worlds=20evolution=20des=20?= =?UTF-8?q?transmuteurs=20avec=20debit=20des=20points=20de=20recherche=20a?= =?UTF-8?q?jout=20d'un=20mode=20"debogue"=20qui=20permet=20l'=C3=A9dition?= =?UTF-8?q?=20et=20l'affichage=20de=20tout=20les=20transmuteurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/fr/evolving/UI/Menu.java | 188 ++++++++++-------- core/src/fr/evolving/UI/VertiBarre.java | 52 ++--- .../src/fr/evolving/automata/Insufler100.java | 19 +- core/src/fr/evolving/automata/Insufler33.java | 21 +- core/src/fr/evolving/automata/Insufler50.java | 19 +- core/src/fr/evolving/automata/Inverter_I.java | 21 +- .../src/fr/evolving/automata/Inverter_II.java | 18 +- core/src/fr/evolving/automata/Negativer.java | 19 +- .../src/fr/evolving/automata/Negativer_I.java | 21 +- .../fr/evolving/automata/Negativer_II.java | 19 +- .../fr/evolving/automata/Negativer_III.java | 19 +- .../fr/evolving/automata/Neutraliser_I.java | 23 ++- .../fr/evolving/automata/Neutraliser_II.java | 19 +- core/src/fr/evolving/automata/Oneway.java | 21 +- core/src/fr/evolving/automata/Positiver.java | 19 +- .../src/fr/evolving/automata/Positiver_I.java | 21 +- .../fr/evolving/automata/Positiver_II.java | 19 +- .../fr/evolving/automata/Positiver_III.java | 19 +- core/src/fr/evolving/automata/Transmuter.java | 39 +++- core/src/fr/evolving/automata/Worlds.java | 82 +++++++- .../src/fr/evolving/automata/distributor.java | 17 +- core/src/fr/evolving/database/LocalBase.java | 13 +- .../fr/evolving/renderers/LevelRenderer.java | 2 +- core/src/fr/evolving/screens/GameScreen.java | 36 ++-- core/src/fr/evolving/screens/LevelScreen.java | 16 +- 25 files changed, 545 insertions(+), 217 deletions(-) diff --git a/core/src/fr/evolving/UI/Menu.java b/core/src/fr/evolving/UI/Menu.java index 7af36ba..007e975 100644 --- a/core/src/fr/evolving/UI/Menu.java +++ b/core/src/fr/evolving/UI/Menu.java @@ -27,6 +27,7 @@ import fr.evolving.assets.AssetLoader; import fr.evolving.automata.Level; import fr.evolving.automata.Transmuter; import fr.evolving.automata.Transmuter.Angular; +import fr.evolving.automata.Worlds; public class Menu extends Actor { @@ -41,7 +42,6 @@ public class Menu extends Actor { private float decx; private float decy; private int size = 32; - private Level level; private Actor selected; private Transmuter selected_transmuter; private TextureRegion oneselection; @@ -49,20 +49,21 @@ public class Menu extends Actor { private TimerTask RotateTask; private float rotation; ChangeEvent event; + Worlds worlds; - public Menu(Level level) { + public Menu(Worlds worlds) { + this.worlds=worlds; this.tilesizex = 4; this.tilesizey = 8; this.nbpages=3; this.selpage=0; this.seltype=0; - this.level=level; - + Gdx.app.debug(getClass().getSimpleName(), "Création du Tiledmap et Maprenderer"); map = new TiledMap[3][Transmuter.Class.values().length]; - clear(); + initialize(); MapRenderer = new OrthogonalTiledMapRenderer(map[selpage][seltype], 1 / (float) size); - + Gdx.app.debug(getClass().getSimpleName(), "Caméra pour tilemap:"+ (tilesizex * size) + "x" + (tilesizey * size)); camera = new OrthographicCamera(); camera.setToOrtho(false, tilesizex * 32, tilesizex * 32 * AssetLoader.height / AssetLoader.width); @@ -72,10 +73,10 @@ public class Menu extends Actor { Gdx.app.debug(getClass().getSimpleName(), "Décalage:" + decx + "x"+ decy); camera.translate(decx, decy); - + Gdx.app.debug(getClass().getSimpleName(), "Ajout des éléments de menu"); - init(); - + update(); + Gdx.app.debug(getClass().getSimpleName(), "Mise en place du timer de rotation."); oneselection = AssetLoader.Atlas_level.findRegion("circle"); selected = new Actor(); @@ -88,7 +89,7 @@ public class Menu extends Actor { } }; RotateTimer.scheduleAtFixedRate(RotateTask, 0, 30); - + Gdx.app.debug(getClass().getSimpleName(), "Ajout de l'évènements clicked"); this.addListener(new ClickListener() { @Override @@ -118,33 +119,33 @@ public class Menu extends Actor { Vector2 coords2 = worldtoscreen((int) coords.x, (int) coords.y); Gdx.app.debug("menu","Coordonnées:" + x + "x" + y + " Menu:" + coords.x - + "," + coords.y + " Ecran :" + coords2.x - + "x" + coords2.y + " type:" - + tile.get("type")); + + "," + coords.y + " Ecran :" + coords2.x + + "x" + coords2.y + " type:" + + tile.get("type")); selected.setBounds(coords2.x, coords2.y, 60, 60); onchanged(); } } }); } - + public void unSelect() { - selected=null; - selected_transmuter=null; - EraseSurtile(); + selected=null; + selected_transmuter=null; + EraseSurtile(); } - + public String getSelection() { if (selected!=null) return selected.getName(); else return null; } - + public Transmuter getTransmuter() { - return selected_transmuter; + return selected_transmuter; } - + public void onchanged() { ChangeEvent event=new ChangeEvent(); event.setTarget(this); @@ -153,7 +154,7 @@ public class Menu extends Actor { if (event.getStage()!=null) this.fire(event); } - + public void setPage(int page) { selected=null; this.selpage=page; @@ -161,7 +162,7 @@ public class Menu extends Actor { EraseSurtile(); onchanged(); } - + public void setPageType(int page,int type) { selected=null; this.selpage=page; @@ -170,20 +171,20 @@ public class Menu extends Actor { EraseSurtile(); onchanged(); } - + public boolean isNextEmpty() { if (this.selpage>=this.nbpages-2) return true; TiledMapTileLayer layer=(TiledMapTileLayer)map[selpage+1][seltype].getLayers().get(0); boolean test=layer.getProperties().containsKey("noempty"); return (!layer.getProperties().containsKey("noempty")); } - + public boolean isPreviousEmpty() { if (this.selpage<1) return true; TiledMapTileLayer layer=(TiledMapTileLayer)map[selpage-1][seltype].getLayers().get(0); return (!layer.getProperties().containsKey("noempty")); } - + public void NextPage() { if (this.selpage0) { selected=null; @@ -203,65 +204,85 @@ public class Menu extends Actor { onchanged(); } } - + public int getPage() { return this.selpage; } - + public int getMaxPage() { return this.nbpages; } - + public void setType(int type) { this.seltype=type; selected=null; this.MapRenderer.setMap(map[selpage][seltype]); onchanged(); } - + public int getType() { return this.seltype; } - - private void init() { - this.setMenuTile(0, 7, 71, "copper_pen",0); - this.setMenuTile(1, 7, 72, "copper_brush",0); - this.setMenuTile(2, 7, 73, "copper_eraser",0); - this.setMenuTile(1, 5, 70, "blank",0); - this.setMenuTile(0, 6, 74, "fiber_pen",0); - this.setMenuTile(1, 6, 75, "fiber_brush",0); - this.setMenuTile(2, 6, 76, "fiber_eraser",0); - this.setMenuTile(0, 5, 77, "transmuter_eraser",0); - this.setMenuTile(2, 5, 78, "all_eraser",0); - this.setMenuTile(3, 3, 79, "cleaner",0); - this.setMenuTransmuter(0, 7, "+", Angular.A00,0); - this.setMenuTransmuter(2, 7, "-", Angular.A00,0); - this.setMenuTransmuter(0, 6, "++", Angular.A00,0); - this.setMenuTransmuter(2, 6, "--", Angular.A00,0); - this.setMenuTransmuter(0, 5, "+++", Angular.A00,0); - this.setMenuTransmuter(1, 5, "---", Angular.A00,0); - this.setMenuTransmuter(0, 4, "+-", Angular.A00,0); - this.setMenuTransmuter(1, 4, "+-+-", Angular.A00,0); - this.setMenuTransmuter(0, 3, "0", Angular.A00,0); - this.setMenuTransmuter(1, 3, "00", Angular.A00,0); - this.setMenuTransmuter(0, 7, ">", Angular.A00,0); - this.setMenuTransmuter(1, 6, "<>", Angular.A00,1); - this.setMenuTransmuter(1, 4, ">33", Angular.A00,0); - this.setMenuTransmuter(1, 1, ">50", Angular.A00,0); - this.setMenuTransmuter(1, 2, ">100", Angular.A00,1); - this.setMenuTransmuter(0, 7, "+/",Angular.A00,0); - this.setMenuTransmuter(1, 7, "-/",Angular.A00,0); + + public void upate() { + } - public void clear() { + public void update() { + clearall(); + this.setMenuTile(0, 7, 71, "copper_pen",0); + this.setMenuTile(1, 7, 72, "copper_brush",0); + this.setMenuTile(2, 7, 73, "copper_eraser",0); + this.setMenuTile(1, 5, 70, "blank",0); + this.setMenuTile(0, 6, 74, "fiber_pen",0); + this.setMenuTile(1, 6, 75, "fiber_brush",0); + this.setMenuTile(2, 6, 76, "fiber_eraser",0); + this.setMenuTile(0, 5, 77, "transmuter_eraser",0); + this.setMenuTile(2, 5, 78, "all_eraser",0); + this.setMenuTile(3, 3, 79, "cleaner",0); + this.setMenuTransmuter(0, 7, "+", Angular.A00,0); + this.setMenuTransmuter(2, 7, "-", Angular.A00,0); + this.setMenuTransmuter(0, 6, "++", Angular.A00,0); + this.setMenuTransmuter(2, 6, "--", Angular.A00,0); + this.setMenuTransmuter(0, 5, "+++", Angular.A00,0); + this.setMenuTransmuter(2, 5, "---", Angular.A00,0); + this.setMenuTransmuter(2, 4, "+-", Angular.A00,0); + this.setMenuTransmuter(3, 4, "+-+-", Angular.A00,0); + this.setMenuTransmuter(0, 4, "0", Angular.A00,0); + this.setMenuTransmuter(1, 4, "00", Angular.A00,0); + this.setMenuTransmuter(0, 7, ">", Angular.A00,0); + this.setMenuTransmuter(1, 6, "<>", Angular.A00,1); + this.setMenuTransmuter(1, 4, ">33", Angular.A00,0); + this.setMenuTransmuter(1, 1, ">50", Angular.A00,0); + this.setMenuTransmuter(1, 2, ">100", Angular.A00,1); + this.setMenuTransmuter(0, 7, "+/",Angular.A00,0); + this.setMenuTransmuter(1, 7, "-/",Angular.A00,0); + this.unSelect(); + } + + private void clearall() { + for (int k=0;k iterator = tiles.iterator(); while (iterator.hasNext()) { Entry all = iterator.next(); - Cell subcell = ((TiledMapTileLayer) map[selpage][seltype].getLayers().get(1)) - .getCell((int) (x + all.key.x), (int) (y + all.key.y)); - subcell.setTile(AssetLoader.tileSet.getTile(transmuter - .getTilestype( - tiles.keys().toArray().indexOf(all.key, false)) - .ordinal() + 80)); + Cell subcell = ((TiledMapTileLayer) map[selpage][seltype].getLayers().get(1)).getCell((int) (x + all.key.x), (int) (y + all.key.y)); + subcell.setTile(AssetLoader.tileSet.getTile(transmuter.getTilestype(tiles.keys().toArray().indexOf(all.key, false)) .ordinal() + 80)); } } } @@ -323,32 +341,34 @@ public class Menu extends Actor { private void setMenuTransmuter(int x, int y, String Name, Transmuter.Angular Angle,int page) { Transmuter transmuter = AssetLoader.getTransmuter(Name); + TiledMapTileLayer layer; if (transmuter != null) { int type=transmuter.getaClass().ordinal(); - TiledMapTileLayer layer = ((TiledMapTileLayer) map[page][type].getLayers().get(0)); - Cell cell = layer.getCell(x, y); - if (cell != null) { - Gdx.app.debug(getClass().getSimpleName(), "Transmuter find:" - + transmuter.getName() + " Angle:" + Angle + " coords" - + x + "," + y+" page:"+page+" type:"+type); - if (transmuter.getTechnology()<=level.Tech) { - Gdx.app.debug(getClass().getSimpleName(), "Autorisé par le niveau"); + Gdx.app.debug(getClass().getSimpleName(), "Transmuter find:" + + transmuter.getName() + " Angle:" + Angle + " coords" + + x + "," + y+" page:"+page+" type:"+type); + if (transmuter.getTechnology()<=worlds.getInformations().Tech || worlds.isDebug()) { + Gdx.app.debug(getClass().getSimpleName(), "Autorisé par le niveau"); + if (!transmuter.isShowed() && transmuter.isUpgraded() && !worlds.isDebug()) + layer = ((TiledMapTileLayer) map[page][type].getLayers().get(2)); + else if (transmuter.isShowed() || worlds.isDebug()) + layer = ((TiledMapTileLayer) map[page][type].getLayers().get(0)); + else + return; + Cell cell = layer.getCell(x, y); + if (cell != null) { layer.getProperties().put("noempty", false); transmuter.setRotation(Angle); - Iterator> keySetIterator = transmuter - .getTilesidrotated().iterator(); + Iterator> keySetIterator = transmuter.getTilesidrotated().iterator(); while (keySetIterator.hasNext()) { Entry all = keySetIterator.next(); Cell subcell = layer.getCell((int) (x + all.key.x), (int) (y + all.key.y)); subcell.setTile(AssetLoader.tileSet.getTile(all.value)); subcell.setRotation(Angle.ordinal()); - subcell.getTile().getProperties() - .put("movetox", (int) -all.key.x); - subcell.getTile().getProperties() - .put("movetoy", (int) -all.key.y); + subcell.getTile().getProperties().put("movetox", (int) -all.key.x); + subcell.getTile().getProperties().put("movetoy", (int) -all.key.y); } } - } } } diff --git a/core/src/fr/evolving/UI/VertiBarre.java b/core/src/fr/evolving/UI/VertiBarre.java index ea552e4..68d930d 100644 --- a/core/src/fr/evolving/UI/VertiBarre.java +++ b/core/src/fr/evolving/UI/VertiBarre.java @@ -14,6 +14,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import fr.evolving.assets.AssetLoader; import fr.evolving.automata.Transmuter; +import fr.evolving.automata.Worlds; import fr.evolving.screens.GameScreen.calling; @@ -21,8 +22,10 @@ public class VertiBarre extends Actor { private VerticalGroup table; private ImageTextButton[] Barre; private ButtonGroup buttonGroup; + Worlds worlds; - public VertiBarre() { + public VertiBarre(Worlds worlds) { + this.worlds=worlds; table = new VerticalGroup(); table.setPosition(AssetLoader.width, AssetLoader.height - 375); table.right(); @@ -32,38 +35,41 @@ public class VertiBarre extends Actor { Gdx.app.debug(getClass().getSimpleName(), "Menu:" + Barre.length+ " elements"); for (int i = 0; i < Barre.length; i++) { - Barre[i] = new ImageTextButton(Transmuter.Class.values()[i].toString(), AssetLoader.Skin_level); - table.addActor(Barre[i]); - buttonGroup.add(Barre[i]); - Barre[i].setName(String.valueOf(i)); - Barre[i].addListener(new ClickListener() { - @Override - public void clicked(InputEvent event, float x, float y) { - int caller = Integer.parseInt(event.getListenerActor().getName()); - Gdx.app.debug("Barre2", "Selection dans la Barre droite:"+ caller); - Method method; - try { - Class base = Class.forName("fr.evolving.screens.GameScreen"); - Class[] params = { int.class }; - method = base.getDeclaredMethod("preparemenu", params); - method.invoke(((Game) Gdx.app.getApplicationListener()).getScreen(), caller); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (Transmuter.Class.values()[i]!=Transmuter.Class.Scenario || worlds.isDebug()) + { + Barre[i] = new ImageTextButton(Transmuter.Class.values()[i].toString(), AssetLoader.Skin_level); + table.addActor(Barre[i]); + buttonGroup.add(Barre[i]); + Barre[i].setName(String.valueOf(i)); + Barre[i].addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + int caller = Integer.parseInt(event.getListenerActor().getName()); + Gdx.app.debug("Barre2", "Selection dans la Barre droite:"+ caller); + Method method; + try { + Class base = Class.forName("fr.evolving.screens.GameScreen"); + Class[] params = { int.class }; + method = base.getDeclaredMethod("preparemenu", params); + method.invoke(((Game) Gdx.app.getApplicationListener()).getScreen(), caller); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } - } - }); + }); + } } buttonGroup.setMaxCheckCount(1); buttonGroup.setMinCheckCount(0); buttonGroup.setUncheckLast(true); this.setBounds(table.getX(),table.getY(),table.getWidth(),table.getHeight()); } - + public Actor hit(float x, float y, boolean touchable) { return table.hit(x, y, touchable); } - + @Override public void draw(Batch batch, float parentAlpha) { table.draw(batch, parentAlpha); diff --git a/core/src/fr/evolving/automata/Insufler100.java b/core/src/fr/evolving/automata/Insufler100.java index 3ca6015..89631d9 100644 --- a/core/src/fr/evolving/automata/Insufler100.java +++ b/core/src/fr/evolving/automata/Insufler100.java @@ -34,9 +34,8 @@ public class Insufler100 extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -105,7 +104,19 @@ public class Insufler100 extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Insufler33.java b/core/src/fr/evolving/automata/Insufler33.java index 92a227d..3c73509 100644 --- a/core/src/fr/evolving/automata/Insufler33.java +++ b/core/src/fr/evolving/automata/Insufler33.java @@ -34,9 +34,8 @@ public class Insufler33 extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -52,7 +51,7 @@ public class Insufler33 extends Transmuter { this.Upgrade = null; this.Unlock = new Array(); this.Unlock.add(new Insufler50(null)); - this.showed = false; + this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = false; this.CanUpgradeRayon = false; @@ -106,7 +105,19 @@ public class Insufler33 extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Insufler50.java b/core/src/fr/evolving/automata/Insufler50.java index 0d32854..1d63fef 100644 --- a/core/src/fr/evolving/automata/Insufler50.java +++ b/core/src/fr/evolving/automata/Insufler50.java @@ -34,9 +34,8 @@ public class Insufler50 extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -106,7 +105,19 @@ public class Insufler50 extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Inverter_I.java b/core/src/fr/evolving/automata/Inverter_I.java index 7583ee3..a7c2f91 100644 --- a/core/src/fr/evolving/automata/Inverter_I.java +++ b/core/src/fr/evolving/automata/Inverter_I.java @@ -34,9 +34,8 @@ public class Inverter_I extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -51,7 +50,7 @@ public class Inverter_I extends Transmuter { this.Research = 0; this.Upgrade = new Inverter_II(level); this.Unlock = null; - this.showed = false; + this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = false; this.CanUpgradeRayon = false; @@ -89,7 +88,19 @@ public class Inverter_I extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Inverter_II.java b/core/src/fr/evolving/automata/Inverter_II.java index 8659dd6..86a9602 100644 --- a/core/src/fr/evolving/automata/Inverter_II.java +++ b/core/src/fr/evolving/automata/Inverter_II.java @@ -34,9 +34,8 @@ public class Inverter_II extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -89,7 +88,18 @@ public class Inverter_II extends Transmuter { public Class getaClass() { return this.theClass; } - + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Negativer.java b/core/src/fr/evolving/automata/Negativer.java index 4a7e252..313a540 100644 --- a/core/src/fr/evolving/automata/Negativer.java +++ b/core/src/fr/evolving/automata/Negativer.java @@ -34,9 +34,8 @@ public class Negativer extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -89,7 +88,19 @@ public class Negativer extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Negativer_I.java b/core/src/fr/evolving/automata/Negativer_I.java index ef7bb3f..0030184 100644 --- a/core/src/fr/evolving/automata/Negativer_I.java +++ b/core/src/fr/evolving/automata/Negativer_I.java @@ -34,9 +34,8 @@ public class Negativer_I extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -51,7 +50,7 @@ public class Negativer_I extends Transmuter { this.Research = 0; this.Upgrade = new Negativer_II(level); this.Unlock = null; - this.showed = false; + this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = true; this.CanUpgradeRayon = false; @@ -91,7 +90,19 @@ public class Negativer_I extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Negativer_II.java b/core/src/fr/evolving/automata/Negativer_II.java index b988bd1..7f2db9e 100644 --- a/core/src/fr/evolving/automata/Negativer_II.java +++ b/core/src/fr/evolving/automata/Negativer_II.java @@ -34,9 +34,8 @@ public class Negativer_II extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -91,7 +90,19 @@ public class Negativer_II extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Negativer_III.java b/core/src/fr/evolving/automata/Negativer_III.java index 244ac17..4defb17 100644 --- a/core/src/fr/evolving/automata/Negativer_III.java +++ b/core/src/fr/evolving/automata/Negativer_III.java @@ -34,9 +34,8 @@ public class Negativer_III extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -89,7 +88,19 @@ public class Negativer_III extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Neutraliser_I.java b/core/src/fr/evolving/automata/Neutraliser_I.java index 3594f7c..7c71b5b 100644 --- a/core/src/fr/evolving/automata/Neutraliser_I.java +++ b/core/src/fr/evolving/automata/Neutraliser_I.java @@ -34,9 +34,8 @@ public class Neutraliser_I extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -49,9 +48,9 @@ public class Neutraliser_I extends Transmuter { this.Price = 20; this.Technology = 4; this.Research = 0; - this.Upgrade = null; + this.Upgrade = new Neutraliser_II(level);; this.Unlock = null; - this.showed = false; + this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = false; this.CanUpgradeRayon = false; @@ -89,7 +88,19 @@ public class Neutraliser_I extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Neutraliser_II.java b/core/src/fr/evolving/automata/Neutraliser_II.java index b7697ae..11045f8 100644 --- a/core/src/fr/evolving/automata/Neutraliser_II.java +++ b/core/src/fr/evolving/automata/Neutraliser_II.java @@ -34,9 +34,8 @@ public class Neutraliser_II extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -89,7 +88,19 @@ public class Neutraliser_II extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Oneway.java b/core/src/fr/evolving/automata/Oneway.java index f56f085..f7824d4 100644 --- a/core/src/fr/evolving/automata/Oneway.java +++ b/core/src/fr/evolving/automata/Oneway.java @@ -34,9 +34,8 @@ public class Oneway extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -52,7 +51,7 @@ public class Oneway extends Transmuter { this.Upgrade = null; this.Unlock = new Array(); this.Unlock.add(new distributor(level)); - this.showed = false; + this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = false; this.CanUpgradeRayon = false; @@ -90,7 +89,19 @@ public class Oneway extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Positiver.java b/core/src/fr/evolving/automata/Positiver.java index e5912e9..2a55b9d 100644 --- a/core/src/fr/evolving/automata/Positiver.java +++ b/core/src/fr/evolving/automata/Positiver.java @@ -34,9 +34,8 @@ public class Positiver extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -89,7 +88,19 @@ public class Positiver extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Positiver_I.java b/core/src/fr/evolving/automata/Positiver_I.java index 1591c73..b224f23 100644 --- a/core/src/fr/evolving/automata/Positiver_I.java +++ b/core/src/fr/evolving/automata/Positiver_I.java @@ -34,9 +34,8 @@ public class Positiver_I extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -51,7 +50,7 @@ public class Positiver_I extends Transmuter { this.Research = 0; this.Upgrade = new Positiver_II(level); this.Unlock = null; - this.showed = false; + this.showed = true; this.CanUpgradeTemp = true; this.CanUpgradeCycle = true; this.CanUpgradeRayon = false; @@ -91,7 +90,19 @@ public class Positiver_I extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Positiver_II.java b/core/src/fr/evolving/automata/Positiver_II.java index 9eb1c1e..a7e6842 100644 --- a/core/src/fr/evolving/automata/Positiver_II.java +++ b/core/src/fr/evolving/automata/Positiver_II.java @@ -34,9 +34,8 @@ public class Positiver_II extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -91,7 +90,19 @@ public class Positiver_II extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Positiver_III.java b/core/src/fr/evolving/automata/Positiver_III.java index 633fd16..e5e2dbc 100644 --- a/core/src/fr/evolving/automata/Positiver_III.java +++ b/core/src/fr/evolving/automata/Positiver_III.java @@ -33,9 +33,8 @@ public class Positiver_III extends Transmuter { private static float TurnRayon; private static float TurnNrj; private static boolean Activable; - private int ActivationLevel; - private int Rotation; - private String id; + private transient int ActivationLevel; + private static String id; private static OrderedMap Tilestype; private static OrderedMap Tilesid; @@ -88,7 +87,19 @@ public class Positiver_III extends Transmuter { public Class getaClass() { return this.theClass; } - + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } + public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; this.level.Rayon += TurnRayon * UpgradedRayon; diff --git a/core/src/fr/evolving/automata/Transmuter.java b/core/src/fr/evolving/automata/Transmuter.java index 5876373..cecaffe 100644 --- a/core/src/fr/evolving/automata/Transmuter.java +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -41,8 +41,22 @@ public abstract class Transmuter implements Cloneable, Serializable { }; protected transient Level level; - protected transient Angular Rotation; - + protected Angular Rotation; + + protected boolean temp_showed; + protected float temp_UpgradedNrj; + protected float temp_UpgradedRayon; + protected float temp_UpgradedCycle; + protected float temp_UpgradedTemp; + + public void SetTemp(boolean temp_showed,float temp_UpgradedCycle,float temp_UpgradedTemp,float temp_UpgradedRayon,float temp_UpgradedNrj) { + this.temp_showed=temp_showed; + this.temp_UpgradedCycle=temp_UpgradedCycle; + this.temp_UpgradedTemp=temp_UpgradedTemp; + this.temp_UpgradedRayon=temp_UpgradedRayon; + this.temp_UpgradedNrj=temp_UpgradedNrj; + } + public Transmuter(Level level) { this.level = level; this.Rotation = Angular.A00; @@ -63,7 +77,13 @@ public abstract class Transmuter implements Cloneable, Serializable { public Class getaClass() { return null; } - + + public void savestatic() { + } + + public void restorestatic() { + } + public void ProcessCycle() { } @@ -153,19 +173,28 @@ public abstract class Transmuter implements Cloneable, Serializable { public boolean isUpgradable(int value) { Transmuter transmuter=this.getUpgrade(); - return transmuter!= null && !transmuter.isShowed() && transmuter.getResearch()>=value; + return transmuter!= null && !transmuter.isShowed() && (transmuter.getResearch()<=value || value==-1); } public boolean isUnlockable(int value) { Array transmuters=this.getUnlock(); if (transmuters != null) { for(Transmuter transmuter:transmuters) { - if (!transmuter.isShowed() && transmuter.getResearch()>=value) + if (!transmuter.isShowed() && (transmuter.getResearch()<=value || value==-1)) return true; } } return false; } + + public boolean isUpgraded () { + Transmuter transmuter=this; + while(transmuter!=null) { + transmuter=transmuter.getUpgrade(); + if (transmuter!=null && transmuter.isShowed()) return true; + } + return false; + } public boolean isShowed() { return false; diff --git a/core/src/fr/evolving/automata/Worlds.java b/core/src/fr/evolving/automata/Worlds.java index 6a1f409..544a0b9 100644 --- a/core/src/fr/evolving/automata/Worlds.java +++ b/core/src/fr/evolving/automata/Worlds.java @@ -17,17 +17,21 @@ public class Worlds extends Actor { private Level usedlevel; private Array Transmuters; private State state; + private boolean Debug; + private int research; public enum State {pause,simulating,notloaded,databasefailed}; public Worlds(String campaign) { name=campaign; - init(); + initialize(); } - public void init() { + public void initialize() { + Debug=false; levels=null; usedworld=-1; + research=-2; usedlevel=null; if (!AssetLoader.Datahandler.verifyall()) { Gdx.app.debug(getClass().getSimpleName(),"Pilotes de bases de donnée défaillant."); @@ -36,16 +40,75 @@ public class Worlds extends Actor { else state=State.notloaded; this.load(name); + this.ReadTransmuters(); if (state==State.notloaded) - this.init(name); + create(name); onchanged(); - } + } + + public void ModResearch(int addsub) { + research+=addsub; + SaveResearch(); + } + + public int ReadResearch() { + if (research==-2) + research=AssetLoader.Datahandler.user().getResearchpoint(0); + return research; + } + + public void SaveResearch() { + this.research=research; + AssetLoader.Datahandler.user().setResearchpoint(0,research); + } + + public void ActivateDebug() { + this.Debug=true; + } + + public void DesactivateDebug() { + this.Debug=false; + } + + public boolean isDebug() { + return this.Debug; + } + + public void SaveTransmuters() { + AssetLoader.Datahandler.user().setTransmuters(0,Transmuters); + } + + public void ReadTransmuters() { + Transmuters=AssetLoader.Datahandler.user().getTransmuters(0); + //String test=Transmuters.get(1).getInformations(); + if (Transmuters==null) + state=State.notloaded; + else + state=State.pause; + } + + public Array ViewGrids() { + if (usedlevel!=null) + return AssetLoader.Datahandler.user().getGrids(0,usedlevel.id); + else + return null; + } + + public void ReadGrid(int number) { + if (usedlevel!=null) + usedlevel.Grid = AssetLoader.Datahandler.user().getGrid(0, usedlevel.id, number); + } public void SaveGrid() { if (usedlevel!=null) AssetLoader.Datahandler.user().setGrid(0, usedlevel.id, usedlevel.Grid); } + public void ReadLastGrid() { + if (usedlevel!=null) + usedlevel.Grid = AssetLoader.Datahandler.user().getGrid(0, usedlevel.id, "LAST"); + } + public void SaveLastGrid() { if (usedlevel!=null) AssetLoader.Datahandler.user().setGrid(0, usedlevel.id, "LAST", usedlevel.Grid); @@ -116,7 +179,7 @@ public class Worlds extends Actor { public void NextWorld() { if (state!=State.notloaded) - if (usedworld Tilestype; private static OrderedMap Tilesid; @@ -97,6 +96,18 @@ public class distributor extends Transmuter { public Class getaClass() { return this.theClass; } + + public void savestatic() { + SetTemp(showed,UpgradedCycle,UpgradedTemp,UpgradedRayon,UpgradedNrj); + } + + public void restorestatic() { + this.UpgradedTemp = this.temp_UpgradedTemp; + this.UpgradedCycle = this.temp_UpgradedCycle; + this.UpgradedRayon = this.temp_UpgradedRayon; + this.UpgradedNrj = this.temp_UpgradedNrj; + this.showed=this.temp_showed; + } public void ProcessCycle() { this.level.Temp += TurnTemp * UpgradedTemp; diff --git a/core/src/fr/evolving/database/LocalBase.java b/core/src/fr/evolving/database/LocalBase.java index 8343f83..5e120da 100644 --- a/core/src/fr/evolving/database/LocalBase.java +++ b/core/src/fr/evolving/database/LocalBase.java @@ -202,16 +202,21 @@ public class LocalBase extends Base { } catch (SQLiteGdxException e) { return null; } - Transmuter[] mc = null; + Array mc=new Array(); if (cursor.next()) try { byte[] bytes = Base64Coder.decodeLines(cursor .getString(0)); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ins = new ObjectInputStream(bais); - mc = (Transmuter[]) ins.readObject(); + //mc = (Transmuter[]) ins.readObject(); + Object[] objects=(Object[])ins.readObject(); + for(Object object:objects) + mc.add((Transmuter)object); ins.close(); - return new Array(mc); + for(Transmuter transmuter:mc) + transmuter.restorestatic(); + return mc; } catch (Exception e) { e.printStackTrace(); } @@ -221,6 +226,8 @@ public class LocalBase extends Base { public boolean setTransmuters(int user, Array transmuters) { String encoded = ""; try { + for(Transmuter transmuter:transmuters) + transmuter.savestatic(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(transmuters.toArray()); diff --git a/core/src/fr/evolving/renderers/LevelRenderer.java b/core/src/fr/evolving/renderers/LevelRenderer.java index 078d2af..649107c 100644 --- a/core/src/fr/evolving/renderers/LevelRenderer.java +++ b/core/src/fr/evolving/renderers/LevelRenderer.java @@ -135,7 +135,7 @@ public class LevelRenderer { } } if (found != -1) { - if (!LevelScreen.logosmall.isChecked()) + if (!LevelScreen.worlds.isDebug()) Laser.draw( batcher, LevelScreen.buttonLevels[i].level.X, diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index b9269da..03bd32d 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -205,7 +205,7 @@ public class GameScreen implements Screen { this.worlds = aworlds; this.level=worlds.getInformations(); Gdx.app.debug(getClass().getSimpleName(),"Récupération des derniers niveaux."); - this.level.Grid = AssetLoader.Datahandler.user().getGrid(0, this.level.id, "LAST"); + worlds.ReadLastGrid(); if (this.level.Grid == null) { Gdx.app.debug(getClass().getSimpleName(), "Copie monde original."); this.level.Grid = this.level.Grid_orig; @@ -228,7 +228,7 @@ public class GameScreen implements Screen { map.setSelected(getselected()); } }); - vertibar=new VertiBarre(); + vertibar=new VertiBarre(worlds); Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table, level, world)"); fpsLabel = new Label("0 FPS", AssetLoader.Skin_level, "FPS"); fpsLabel.setPosition(AssetLoader.width - 75, AssetLoader.height - 220); @@ -259,7 +259,7 @@ public class GameScreen implements Screen { nrj.setPosition(610, AssetLoader.height - 74); tech = new ImageTextButton(String.valueOf(level.Tech),AssetLoader.Skin_level, "tech2"); tech.setPosition(1345, AssetLoader.height - 74); - tech.setVisible(level.Tech==1); + tech.setVisible(level.Tech>=1); cout = new ImageTextButton(String.valueOf(level.Cout),AssetLoader.Skin_level, "cout2"); cout.setVisible(level.Cout>0); cout.setPosition(1445, AssetLoader.height - 74); @@ -327,8 +327,12 @@ public class GameScreen implements Screen { info_up.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - if (menu.getTransmuter()!=null && menu.getTransmuter().isUpgradable(0)) + if (menu.getTransmuter()!=null && menu.getTransmuter().isUpgradable(worlds.ReadResearch())) + worlds.ModResearch(-menu.getTransmuter().getUpgrade().getResearch()); menu.getTransmuter().Upgrade(); + menu.update(); + info_up.setVisible(false); + hideInfo(); } }); dialog = new WarnDialog(AssetLoader.Skin_ui); @@ -372,7 +376,7 @@ public class GameScreen implements Screen { } } }); - menu = new Menu(level); + menu = new Menu(worlds); menu.setBounds(1531f, AssetLoader.height-780, 264, 480); menu.addListener(new ChangeListener() { @Override @@ -623,6 +627,13 @@ public class GameScreen implements Screen { } } + public void exit() + { + worlds.SaveLastGrid(); + worlds.SaveTransmuters(); + worlds.SaveResearch(); + } + @Override public void render(float delta) { stage.act(); @@ -720,17 +731,16 @@ public class GameScreen implements Screen { if (winSave.isVisible()) readsaved(); } else if (caller == "save") { - Gdx.app.debug("Barre", "Sauvegarde de la grille."); - Gdx.app.debug("Barre", AssetLoader.Datahandler.user().toString()); + Gdx.app.debug("Barre", "Sauvegarde de la grille."); worlds.SaveGrid(); readsaved(); } else if (caller == "levels") { Gdx.app.debug("Barre", "Affichage des niveaux."); - worlds.SaveLastGrid(); + exit(); ((Game) Gdx.app.getApplicationListener()).setScreen(new LevelScreen(worlds)); } else if (caller == "tree") { } else if (caller == "exits") { - worlds.SaveLastGrid(); + exit(); Gdx.app.exit(); } else if (caller == "screen") { DisplayMode currentMode = Gdx.graphics.getDesktopDisplayMode(); @@ -835,7 +845,7 @@ public class GameScreen implements Screen { AssetLoader.Atlas_level.findRegion("jauge" + transmuter.getUpgradeRayon())); info_up_rayonval.setColor(AssetLoader.Levelcolors[2]); - info_up.setVisible(transmuter.isUnlockable(0)||transmuter.isUpgradable(0)); + info_up.setVisible(transmuter.isUpgradable(worlds.ReadResearch())); } @@ -877,8 +887,7 @@ public class GameScreen implements Screen { selSaved.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { if (this.getTapCount() > 1) - level.Grid = AssetLoader.Datahandler.user().getGrid(0, - level.id, selSaved.getSelectedIndex()); + worlds.ReadGrid(selSaved.getSelectedIndex()); level.Grid.tiling_copper(); level.Grid.tiling_transmuter(); map.redraw(); @@ -892,8 +901,7 @@ public class GameScreen implements Screen { } public void readsaved() { - Array items = AssetLoader.Datahandler.user().getGrids(0, - level.id); + Array items = worlds.ViewGrids(); if (items != null) selSaved.setItems(items); } diff --git a/core/src/fr/evolving/screens/LevelScreen.java b/core/src/fr/evolving/screens/LevelScreen.java index 0ea71e9..5e6a692 100644 --- a/core/src/fr/evolving/screens/LevelScreen.java +++ b/core/src/fr/evolving/screens/LevelScreen.java @@ -236,7 +236,7 @@ public class LevelScreen implements Screen { float y, int pointer) { ButtonLevel abutton = (ButtonLevel) event .getListenerActor(); - if (logosmall.isChecked()) { + if (worlds.isDebug()) { abutton.setPosition(event.getStageX() - 56, event.getStageY() - 20); } @@ -355,8 +355,16 @@ public class LevelScreen implements Screen { }); Gdx.app.debug(getClass().getSimpleName(), "Création des boutons."); logosmall = new ImageButton(AssetLoader.Skin_level, "logosmall"); - logosmall.setPosition(20, - AssetLoader.height - 175 + logosmall.getHeight() / 2); + logosmall.setPosition(20,AssetLoader.height - 175 + logosmall.getHeight() / 2); + logosmall.setChecked(worlds.isDebug()); + logosmall.addListener(new ClickListener() { + public void clicked(InputEvent event, float x, float y) { + if (logosmall.isChecked()) + worlds.ActivateDebug(); + else + worlds.DesactivateDebug(); + } + }); TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level, "Descriptif"); TextDescriptive.setBounds(15, 15, 1185, 110); @@ -389,7 +397,7 @@ public class LevelScreen implements Screen { else Userdata.setColor(1f, 1f, 1f, 1f); Worlddata.Refresh(); - worlds.init(); + worlds.initialize(); } }); buttonSave = new TextButton(AssetLoader.language.get("[buttonSave-levelscreen]"), AssetLoader.Skin_ui);