fix: centralisation dans l'objet worlds des informations relatives à la gestion du monde sauvegarde/restauration des transmuteurs gestion des points de recherche sauvegarde/restauration de la grille par l'object worlds evolution des transmuteurs avec debit des points de recherche ajout d'un mode "debogue" qui permet l'édition et l'affichage de tout les transmuteurs

This commit is contained in:
Nicolas Hordé 2016-01-29 00:11:01 +01:00
parent e33cf80443
commit c99a916297
25 changed files with 545 additions and 217 deletions

View File

@ -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,18 +49,19 @@ 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));
@ -74,7 +75,7 @@ public class Menu extends Actor {
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");
@ -118,9 +119,9 @@ 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();
}
@ -129,9 +130,9 @@ public class Menu extends Actor {
}
public void unSelect() {
selected=null;
selected_transmuter=null;
EraseSurtile();
selected=null;
selected_transmuter=null;
EraseSurtile();
}
public String getSelection() {
@ -142,7 +143,7 @@ public class Menu extends Actor {
}
public Transmuter getTransmuter() {
return selected_transmuter;
return selected_transmuter;
}
public void onchanged() {
@ -223,45 +224,65 @@ public class Menu extends Actor {
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<Transmuter.Class.values().length;k++)
for (int j=0;j<nbpages;j++){
map[j][k].getTileSets().addTileSet(AssetLoader.tileSet);
for (int i = 0; i < map[j][k].getLayers().getCount(); i++) {
TiledMapTileLayer layer = (TiledMapTileLayer) map[j][k].getLayers().get(i);
for (int x = 0; x < layer.getWidth(); x++) {
for (int y = 0; y < layer.getHeight(); y++) {
layer.getCell(x, y).setTile(null);
}
}
}
}
}
private void initialize() {
for (int k=0;k<Transmuter.Class.values().length;k++)
for (int j=0;j<nbpages;j++){
map[j][k]=new TiledMap();
map[j][k].getTileSets().addTileSet(AssetLoader.tileSet);
MapLayers layers = map[j][k].getLayers();
for (int i = 0; i < 3; i++) {
TiledMapTileLayer layer = new TiledMapTileLayer(tilesizex,
tilesizey, 128, 128);
TiledMapTileLayer layer = new TiledMapTileLayer(tilesizex,tilesizey, 128, 128);
for (int x = 0; x < layer.getWidth(); x++) {
for (int y = 0; y < layer.getHeight(); y++) {
Cell cell = new Cell();
@ -273,6 +294,7 @@ public class Menu extends Actor {
layers.add(layer);
}
map[j][k].getLayers().get(1).setOpacity(0.5f);
map[j][k].getLayers().get(2).setOpacity(0.25f);
}
}
@ -296,12 +318,8 @@ public class Menu extends Actor {
Entries<Vector2, Integer> iterator = tiles.iterator();
while (iterator.hasNext()) {
Entry<Vector2, Integer> 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<Entry<Vector2, Integer>> keySetIterator = transmuter
.getTilesidrotated().iterator();
Iterator<Entry<Vector2, Integer>> keySetIterator = transmuter.getTilesidrotated().iterator();
while (keySetIterator.hasNext()) {
Entry<Vector2, Integer> 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);
}
}
}
}
}

View File

@ -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,27 +35,30 @@ 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);

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -106,6 +105,18 @@ public class Insufler100 extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -52,7 +51,7 @@ public class Insufler33 extends Transmuter {
this.Upgrade = null;
this.Unlock = new Array<Transmuter>();
this.Unlock.add(new Insufler50(null));
this.showed = false;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = false;
this.CanUpgradeRayon = false;
@ -107,6 +106,18 @@ public class Insufler33 extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -107,6 +106,18 @@ public class Insufler50 extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> 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;
@ -90,6 +89,18 @@ public class Inverter_I extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -89,6 +88,17 @@ 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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -90,6 +89,18 @@ public class Negativer extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> 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;
@ -92,6 +91,18 @@ public class Negativer_I extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -92,6 +91,18 @@ public class Negativer_II extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -90,6 +89,18 @@ public class Negativer_III extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> 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;
@ -90,6 +89,18 @@ public class Neutraliser_I extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -90,6 +89,18 @@ public class Neutraliser_II extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -52,7 +51,7 @@ public class Oneway extends Transmuter {
this.Upgrade = null;
this.Unlock = new Array<Transmuter>();
this.Unlock.add(new distributor(level));
this.showed = false;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = false;
this.CanUpgradeRayon = false;
@ -91,6 +90,18 @@ public class Oneway extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -90,6 +89,18 @@ public class Positiver extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> 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;
@ -92,6 +91,18 @@ public class Positiver_I extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -92,6 +91,18 @@ public class Positiver_II extends Transmuter {
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;

View File

@ -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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -89,6 +88,18 @@ public class Positiver_III extends Transmuter {
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;

View File

@ -41,7 +41,21 @@ 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;
@ -64,6 +78,12 @@ public abstract class Transmuter implements Cloneable, Serializable {
return null;
}
public void savestatic() {
}
public void restorestatic() {
}
public void ProcessCycle() {
}
@ -153,20 +173,29 @@ 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<Transmuter> 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;
}

View File

@ -17,17 +17,21 @@ public class Worlds extends Actor {
private Level usedlevel;
private Array<Transmuter> 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<String> 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<getMaxWorlds()-1) {
if (usedworld<getMaxWorlds()) {
usedworld++;
onchanged();
}
@ -149,15 +212,12 @@ public class Worlds extends Actor {
levels=AssetLoader.Datahandler.game().getCampaign(campaign);
name=campaign;
if (levels==null)
{
state=State.notloaded;
}
else
state=State.pause;
}
public void init(String campaign) {
public void create(String campaign) {
Gdx.app.log("*****", "initialisation de la compagne "+campaign);
try {
levels=InitWorlds.go();
@ -166,6 +226,10 @@ public class Worlds extends Actor {
name=campaign;
AssetLoader.Datahandler.game().setCampaign(levels,name);
state=State.pause;
research=0;
Transmuters=AssetLoader.allTransmuter;
SaveTransmuters();
SaveResearch();
}
catch (Exception e) {
state=State.notloaded;

View File

@ -34,9 +34,8 @@ public class distributor 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<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
@ -98,6 +97,18 @@ public class distributor extends Transmuter {
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;

View File

@ -202,16 +202,21 @@ public class LocalBase extends Base {
} catch (SQLiteGdxException e) {
return null;
}
Transmuter[] mc = null;
Array<Transmuter> mc=new Array<Transmuter>();
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<Transmuter>(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<Transmuter> transmuters) {
String encoded = "";
try {
for(Transmuter transmuter:transmuters)
transmuter.savestatic();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(transmuters.toArray());

View File

@ -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,

View File

@ -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();
@ -721,16 +732,15 @@ public class GameScreen implements Screen {
readsaved();
} else if (caller == "save") {
Gdx.app.debug("Barre", "Sauvegarde de la grille.");
Gdx.app.debug("Barre", AssetLoader.Datahandler.user().toString());
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<String> items = AssetLoader.Datahandler.user().getGrids(0,
level.id);
Array<String> items = worlds.ViewGrids();
if (items != null)
selSaved.setItems(items);
}

View File

@ -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);