fix: reformatage et nettoyage du code, oubli de modifier l'import decoder64, remplacé par decoder de libgdx, remplacement de la copie de la base par des fonctions intégrées, correction de différents bogues sous android, correction bogue adaptation=2 dans les préférences.

This commit is contained in:
Nicolas Hordé 2016-01-17 00:57:06 +01:00
parent df45882b62
commit 9251cd0834
37 changed files with 4455 additions and 4522 deletions

View File

@ -1,16 +1,11 @@
package fr.evolving.UI;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.Align;
import fr.evolving.assets.AssetLoader;
@ -27,7 +22,8 @@ public class ButtonLevel extends ImageTextButton {
LabelStyle stylelabel;
public ButtonLevel(Level level, boolean Activated, float ratio) {
super(level.Name, AssetLoader.Skin_level, "world"+String.valueOf(level.aWorld));
super(level.Name, AssetLoader.Skin_level, "world"
+ String.valueOf(level.aWorld));
this.level = level;
this.ratio = ratio;
this.Activated = Activated;
@ -38,19 +34,23 @@ public class ButtonLevel extends ImageTextButton {
this.setDisabled(true);
Locked = AssetLoader.Skin_level.getAtlas().findRegion("locked");
}
this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f);
this.setColor(1f, 0.47f + (float) level.X / 1024f * 0.529f,
0.607f + (float) level.X / 768f * 0.392f, 1f);
this.scale = 1f;
this.setBounds(level.X, level.Y * ratio, 111 * scale, 125 * scale);
Thelabel=new Label(level.Element, AssetLoader.Skin_level,"Levelshort");
Thelabel = new Label(level.Element, AssetLoader.Skin_level,
"Levelshort");
Thelabel.setColor(level.X / 1024f, level.X / 1024f, level.X / 1024f, 1f);
Thelabel.setPosition(level.X+54*scale, level.Y*ratio+20*scale, Align.bottom | Align.center);
Thelabel.setPosition(level.X + 54 * scale,
level.Y * ratio + 20 * scale, Align.bottom | Align.center);
}
@Override
public void setScale(float scale) {
this.scale = scale;
this.setBounds(level.X, level.Y * ratio, 111 * scale, 125 * scale);
Thelabel.setPosition(level.X+54*scale, level.Y*ratio+20*scale, Align.bottom | Align.center);
Thelabel.setPosition(level.X + 54 * scale,
level.Y * ratio + 20 * scale, Align.bottom | Align.center);
stylelabel = Thelabel.getStyle();
// stylelabel.font.setScale(scale);
Thelabel.setStyle(stylelabel);
@ -73,18 +73,27 @@ public class ButtonLevel extends ImageTextButton {
level.X = x;
level.Y = y;
Thelabel.setColor(level.X / 1024f, level.X / 1024f, level.X / 1024f, 1f);
Thelabel.setPosition(level.X+54*scale, level.Y*ratio+20*scale, Align.bottom | Align.center);
this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f);
Thelabel.setPosition(level.X + 54 * scale,
level.Y * ratio + 20 * scale, Align.bottom | Align.center);
this.setColor(1f, 0.47f + (float) level.X / 1024f * 0.529f,
0.607f + (float) level.X / 768f * 0.392f, 1f);
}
@Override
public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha);
if (level.Special) {
batch.draw(Finalled,level.X,level.Y*ratio,Finalled.getRegionWidth()*scale,Finalled.getRegionHeight()*scale);
batch.draw(Finalled, level.X, level.Y * ratio,
Finalled.getRegionWidth() * scale,
Finalled.getRegionHeight() * scale);
}
if (!Activated) {
batch.draw(Locked,level.X+this.getWidth()-Locked.getRegionWidth(),level.Y*ratio+this.getHeight()-Locked.getRegionHeight(),Locked.getRegionWidth()*scale,Locked.getRegionHeight()*scale);
batch.draw(
Locked,
level.X + this.getWidth() - Locked.getRegionWidth(),
level.Y * ratio + this.getHeight()
- Locked.getRegionHeight(), Locked.getRegionWidth()
* scale, Locked.getRegionHeight() * scale);
}
Thelabel.draw(batch, 1f);
}

View File

@ -1,6 +1,5 @@
package fr.evolving.UI;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
@ -19,10 +18,7 @@ import com.badlogic.gdx.utils.ObjectMap.Entry;
import com.badlogic.gdx.utils.OrderedMap;
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.Transmuter.CaseType;
public class Menu extends Actor {
@ -35,7 +31,6 @@ public class Menu extends Actor{
private float decy;
private int size = 32;
public Menu(int tilesizex, int tilesizey) {
this.tilesizex = tilesizex;
this.tilesizey = tilesizey;
@ -43,7 +38,8 @@ public Menu(int tilesizex,int tilesizey) {
map.getTileSets().addTileSet(AssetLoader.tileSet);
MapLayers layers = map.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();
@ -57,52 +53,57 @@ public Menu(int tilesizex,int tilesizey) {
map.getLayers().get(1).setOpacity(0.5f);
MapRenderer = new OrthogonalTiledMapRenderer(map, 1 / (float) size);
camera = new OrthographicCamera();
camera.setToOrtho(false, tilesizex*32,tilesizex*32*AssetLoader.height/AssetLoader.width);
Gdx.app.debug(getClass().getSimpleName(),"Caméra pour tilemap:"+(tilesizex*size)+"x"+(tilesizey*size));
camera.setToOrtho(false, tilesizex * 32, tilesizex * 32
* AssetLoader.height / AssetLoader.width);
Gdx.app.debug(getClass().getSimpleName(), "Caméra pour tilemap:"
+ (tilesizex * size) + "x" + (tilesizey * size));
decx = -102f;
decy = -20f;
if (AssetLoader.ratio == 1.44f)
decy -= 24;
camera.translate(decx, decy);
Gdx.app.debug(getClass().getSimpleName(),"Décalage:"+decx+"x"+decy);
Gdx.app.debug(getClass().getSimpleName(), "Décalage:" + decx + "x"
+ decy);
}
public void clear()
{
public void clear() {
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
for (int x = 0; x < layer.getWidth(); x++)
for (int y = 0; y < layer.getHeight(); y++)
layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(54));
}
public void setMenuTile(int x,int y,int tile,String title)
{
public void setMenuTile(int x, int y, int tile, String title) {
Cell cell = ((TiledMapTileLayer) map.getLayers().get(0)).getCell(x, y);
if (cell != null) {
cell.setTile(AssetLoader.tileSet.getTile(tile));
cell.getTile().getProperties().put("name", title);
cell.setRotation(0);
Gdx.app.debug(getClass().getSimpleName(),"Tile find:"+tile+" coords"+x+","+y);
Gdx.app.debug(getClass().getSimpleName(), "Tile find:" + tile
+ " coords" + x + "," + y);
}
}
public void setMenuTransmuterSurtile(int x,int y,Transmuter transmuter)
{
public void setMenuTransmuterSurtile(int x, int y, Transmuter transmuter) {
if (transmuter != null) {
Cell cell=((TiledMapTileLayer)map.getLayers().get(1)).getCell(x,y);
Cell cell = ((TiledMapTileLayer) map.getLayers().get(1)).getCell(x,
y);
OrderedMap<Vector2, Integer> tiles = transmuter.getTilesidrotated();
Entries<Vector2, Integer> iterator = tiles.iterator();
while (iterator.hasNext()) {
Entry<Vector2, Integer> all = iterator.next();
Cell subcell=((TiledMapTileLayer)map.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.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));
}
}
}
public void EraseMenuTransmuterSurtile()
{
public void EraseMenuTransmuterSurtile() {
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(1);
for (int x = 0; x < layer.getWidth(); x++)
for (int y = 0; y < layer.getHeight(); y++)
@ -117,30 +118,36 @@ public int getSizeY() {
return tilesizey;
}
public void setMenuTransmuter(int x,int y,String Name,Transmuter.Angular Angle)
{
public void setMenuTransmuter(int x, int y, String Name,
Transmuter.Angular Angle) {
Cell cell = ((TiledMapTileLayer) map.getLayers().get(0)).getCell(x, y);
if (cell != null) {
Transmuter transmuter = AssetLoader.getTransmuter(Name);
if (transmuter != null) {
Gdx.app.debug(getClass().getSimpleName(),"Transmuter find:"+transmuter.getName()+" Angle:"+Angle+" coords"+x+","+y);
Gdx.app.debug(getClass().getSimpleName(), "Transmuter find:"
+ transmuter.getName() + " Angle:" + Angle + " coords"
+ x + "," + y);
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=((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)(x+all.key.x),(int)(y+all.key.y));
Cell subcell = ((TiledMapTileLayer) map.getLayers().get(0))
.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);
}
}
}
}
public MapProperties getMenubyTile(int x,int y)
{
public MapProperties getMenubyTile(int x, int y) {
Cell cell = ((TiledMapTileLayer) map.getLayers().get(0)).getCell(x, y);
if (cell != null)
return cell.getTile().getProperties();
@ -148,8 +155,6 @@ public MapProperties getMenubyTile(int x,int y)
return null;
}
public Vector2 screentoworld(float x, float y) {
int xx = (int) ((x - 1531f) / 60f);
int yy = (int) ((y - (AssetLoader.height - 776f)) / 60f);
@ -171,6 +176,4 @@ public void draw(Batch batch, float parentAlpha) {
batch.begin();
}
}

View File

@ -1,8 +1,5 @@
package fr.evolving.UI;
import java.util.Arrays;
import java.util.Collections;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
@ -38,20 +35,23 @@ public class Objectives extends Actor {
batch.end();
shaperenderer.begin(ShapeType.Filled);
shaperenderer.setColor(AssetLoader.Typecolors[type]);
shaperenderer.rect(this.getX()+element*40, this.getY(), 40, 68);
shaperenderer.rect(this.getX() + element * 40, this.getY(), 40,
68);
shaperenderer.end();
shaperenderer.begin(ShapeType.Line);
shaperenderer.setColor(1, 1, 1, 1);
shaperenderer.rect(this.getX()+element*40, this.getY(), 40, 68);
shaperenderer.rect(this.getX() + element * 40, this.getY(), 40,
68);
shaperenderer.end();
batch.begin();
font.draw(batch, AssetLoader.Typenames[type], this.getX()+element*40+2,this.getY()+69);
font2.draw(batch, String.valueOf(vict), this.getX()+element*40+11,this.getY()+35);
font.draw(batch, AssetLoader.Typenames[type], this.getX()
+ element * 40 + 2, this.getY() + 69);
font2.draw(batch, String.valueOf(vict), this.getX() + element
* 40 + 11, this.getY() + 35);
element += 1;
}
type += 1;
}
}
}

View File

@ -1,7 +1,6 @@
package fr.evolving.UI;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Net.HttpMethods;
@ -18,9 +17,6 @@ import com.badlogic.gdx.utils.XmlReader.Element;
import fr.evolving.assets.AssetLoader;
import fr.evolving.database.Base;
import fr.evolving.database.Base.datatype;
import fr.evolving.database.LocalBase;
import fr.evolving.database.SqlBase;
public class ServerList extends List {
HashMap parameters;
@ -51,18 +47,18 @@ public class ServerList extends List {
public void Refresh() {
HttpRequest httpGet = new HttpRequest(HttpMethods.GET);
httpGet.setUrl(url);
httpGet.setContent(HttpParametersUtils.convertHttpParameters(parameters));
httpGet.setContent(HttpParametersUtils
.convertHttpParameters(parameters));
// If you want basic authentication, add this header
String authHeader = "Basic " + Base64Coder.encodeString("evolving:--evolvE2016__");
String authHeader = "Basic "
+ Base64Coder.encodeString("evolving:--evolvE2016__");
httpGet.setHeader("Authorization", authHeader);
httpGet.setHeader("Content-Type", "text/xml");
httpGet.setHeader("Accept", "text/xml");
Gdx.net.sendHttpRequest(httpGet, new HttpResponseListener() {
public void handleHttpResponse(HttpResponse httpResponse) {
if (httpResponse.getStatus().getStatusCode()==200)
{
if (httpResponse.getStatus().getStatusCode() == 200) {
String Response = "";
Array<Element> resultxml;
Array<String> resultstring = new Array<String>();
@ -71,25 +67,33 @@ public class ServerList extends List {
XmlReader.Element xml_element = xml.parse(Response);
resultxml = xml_element.getChildrenByName("server");
for (Element child : resultxml)
if (AssetLoader.Datahandler.isBackend(ServerList.this.model,child.getText()))
if (AssetLoader.Datahandler.isBackend(
ServerList.this.model, child.getText()))
resultstring.add(child.getText());
String old=AssetLoader.Datahandler.getOld(ServerList.this.model);
String old = AssetLoader.Datahandler
.getOld(ServerList.this.model);
if (!resultstring.contains(old, false))
resultstring.add(old);
ServerList.this.setItems(resultstring);
ServerList.this.setSelectedIndex(resultstring.indexOf(old, false));
if (list!=null && ServerList.this.model==Base.datatype.gamedata)
ServerList.this.setSelectedIndex(resultstring.indexOf(old,
false));
if (list != null
&& ServerList.this.model == Base.datatype.gamedata)
list.Refresh();
}
}
@Override
public void failed(Throwable t) {
Array<String> resultstring = new Array<String>();
String old=AssetLoader.Datahandler.getOld(ServerList.this.model);
String old = AssetLoader.Datahandler
.getOld(ServerList.this.model);
resultstring.add(old);
ServerList.this.setItems(resultstring);
ServerList.this.setSelectedIndex(resultstring.indexOf(old, false));
if (list!=null && ServerList.this.model==Base.datatype.gamedata)
ServerList.this.setSelectedIndex(resultstring.indexOf(old,
false));
if (list != null
&& ServerList.this.model == Base.datatype.gamedata)
list.Refresh();
}

View File

@ -1,7 +1,6 @@
package fr.evolving.UI;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.maps.MapLayers;
@ -14,8 +13,6 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
import fr.evolving.automata.Transmuter.Angular;
public class TouchMaptiles extends Actor {
@ -35,7 +32,8 @@ public TouchMaptiles(Level level,int sizex,int sizey) {
map.getTileSets().addTileSet(AssetLoader.tileSet);
MapLayers layers = map.getLayers();
for (int i = 0; i < 5; i++) {
TiledMapTileLayer layer = new TiledMapTileLayer(level.Grid.sizeX, level.Grid.sizeY, sizex, sizey);
TiledMapTileLayer layer = new TiledMapTileLayer(level.Grid.sizeX,
level.Grid.sizeY, sizex, sizey);
for (int x = 0; x < layer.getWidth(); x++) {
for (int y = 0; y < layer.getHeight(); y++) {
Cell cell = new Cell();
@ -64,77 +62,110 @@ public Vector2 screentoworldsize(float x, float y) {
return new Vector2(x, y);
}
public void tempdraw(float x,float y, int tile, int rotation, int surtile)
{
Cell cell=((TiledMapTileLayer)map.getLayers().get(3)).getCell((int)x, (int)y);
if (cell!=null)
{
((TiledMapTileLayer)map.getLayers().get(4)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(tile));
((TiledMapTileLayer)map.getLayers().get(4)).getCell((int)x, (int)y).setRotation(rotation);
if (surtile!=0) ((TiledMapTileLayer)map.getLayers().get(3)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(surtile));
public void tempdraw(float x, float y, int tile, int rotation, int surtile) {
Cell cell = ((TiledMapTileLayer) map.getLayers().get(3)).getCell(
(int) x, (int) y);
if (cell != null) {
((TiledMapTileLayer) map.getLayers().get(4)).getCell((int) x,
(int) y).setTile(AssetLoader.tileSet.getTile(tile));
((TiledMapTileLayer) map.getLayers().get(4)).getCell((int) x,
(int) y).setRotation(rotation);
if (surtile != 0)
((TiledMapTileLayer) map.getLayers().get(3)).getCell((int) x,
(int) y).setTile(AssetLoader.tileSet.getTile(surtile));
}
}
public void tempclear()
{
public void tempclear() {
for (int x = 0; x < level.Grid.sizeX; x++)
for (int y = 0; y < level.Grid.sizeY; y++) {
((TiledMapTileLayer)map.getLayers().get(3)).getCell((int)x, (int)y).setTile(null);
((TiledMapTileLayer)map.getLayers().get(4)).getCell((int)x, (int)y).setTile(null);
((TiledMapTileLayer) map.getLayers().get(3)).getCell((int) x,
(int) y).setTile(null);
((TiledMapTileLayer) map.getLayers().get(4)).getCell((int) x,
(int) y).setTile(null);
}
}
public void redraw(int tile) {
for (int x = 0; x < level.Grid.sizeX; x++)
for (int y = 0; y < level.Grid.sizeY; y++) {
((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).setTile(null);
((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)x, (int)y).setTile(null);
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(tile));
((TiledMapTileLayer) map.getLayers().get(2)).getCell((int) x,
(int) y).setTile(null);
((TiledMapTileLayer) map.getLayers().get(1)).getCell((int) x,
(int) y).setTile(null);
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x,
(int) y).setTile(AssetLoader.tileSet.getTile(tile));
}
for (int x = 0; x < level.Grid.sizeX; x++)
for (int y = 0; y < level.Grid.sizeY; y++) {
if (level.Grid.getCopper(x, y))
((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(level.Grid.getCoppercalc(x,y)));
((TiledMapTileLayer) map.getLayers().get(1)).getCell(
(int) x, (int) y).setTile(
AssetLoader.tileSet.getTile(level.Grid
.getCoppercalc(x, y)));
if (level.Grid.getFiber(x, y))
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(61));
if (level.Grid.getTransmutercalc(x, y)!=0)
{
((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(level.Grid.getTransmutercalc(x, y)));
((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).setRotation(level.Grid.getTransmuterrot(x, y));
((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).getTile().getProperties().put("movex",level.Grid.GetXY(x, y).Transmuter_movex);
((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).getTile().getProperties().put("movey",level.Grid.GetXY(x, y).Transmuter_movex);
};
((TiledMapTileLayer) map.getLayers().get(0)).getCell(
(int) x, (int) y).setTile(
AssetLoader.tileSet.getTile(61));
if (level.Grid.getTransmutercalc(x, y) != 0) {
((TiledMapTileLayer) map.getLayers().get(2)).getCell(
(int) x, (int) y).setTile(
AssetLoader.tileSet.getTile(level.Grid
.getTransmutercalc(x, y)));
((TiledMapTileLayer) map.getLayers().get(2)).getCell(
(int) x, (int) y).setRotation(
level.Grid.getTransmuterrot(x, y));
((TiledMapTileLayer) map.getLayers().get(2))
.getCell((int) x, (int) y)
.getTile()
.getProperties()
.put("movex",
level.Grid.GetXY(x, y).Transmuter_movex);
((TiledMapTileLayer) map.getLayers().get(2))
.getCell((int) x, (int) y)
.getTile()
.getProperties()
.put("movey",
level.Grid.GetXY(x, y).Transmuter_movex);
}
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)0, (int)0).setTile(AssetLoader.tileSet.getTile(1010));
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)1, (int)0).setTile(AssetLoader.tileSet.getTile(1010));
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)2, (int)0).setTile(AssetLoader.tileSet.getTile(1010));
;
}
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) 0, (int) 0)
.setTile(AssetLoader.tileSet.getTile(1010));
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) 1, (int) 0)
.setTile(AssetLoader.tileSet.getTile(1010));
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) 2, (int) 0)
.setTile(AssetLoader.tileSet.getTile(1010));
}
public void initzoom() {
if ((level.Grid.sizeX/(float)level.Grid.sizeY)>(AssetLoader.width/AssetLoader.height))
{
if ((level.Grid.sizeX / (float) level.Grid.sizeY) > (AssetLoader.width / AssetLoader.height)) {
viewwidth = level.Grid.sizeX;
viewheight=level.Grid.sizeX/((float)AssetLoader.width/AssetLoader.height);
}
else
{
viewheight = level.Grid.sizeX
/ ((float) AssetLoader.width / AssetLoader.height);
} else {
viewheight = level.Grid.sizeY;
viewwidth=level.Grid.sizeY*((float)AssetLoader.width/AssetLoader.height);
viewwidth = level.Grid.sizeY
* ((float) AssetLoader.width / AssetLoader.height);
}
Gdx.app.debug(getClass().getSimpleName(),"Caméra pour tilemap:"+viewwidth+"x"+viewheight);
Gdx.app.debug(getClass().getSimpleName(), "Caméra pour tilemap:"
+ viewwidth + "x" + viewheight);
camera.setToOrtho(false, viewwidth, viewheight);
decx = (level.Grid.sizeX - viewwidth) / 2.0f;
decy = (level.Grid.sizeY - viewheight) / 2.0f;
Gdx.app.debug(getClass().getSimpleName(),"Décalage:"+decx+"x"+decy);
Gdx.app.debug(getClass().getSimpleName(), "Décalage:" + decx + "x"
+ decy);
camera.translate(decx, decy);
}
public void fillempty(int tile)
{
public void fillempty(int tile) {
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
for (int x = 0; x < layer.getWidth(); x++)
for (int y = 0; y < layer.getHeight(); y++)
if (layer.getCell(x, y).getTile().getId()==53 || layer.getCell(x, y).getTile().getId()==60) layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(tile));
if (layer.getCell(x, y).getTile().getId() == 53
|| layer.getCell(x, y).getTile().getId() == 60)
layer.getCell(x, y).setTile(
AssetLoader.tileSet.getTile(tile));
}
public void setZoom(float factor) {
@ -142,7 +173,9 @@ public void setZoom(float factor) {
viewheight *= factor;
camera.setToOrtho(false, viewwidth, viewheight);
camera.translate(decx, decy);
Gdx.app.debug(getClass().getSimpleName(),"Caméra pour tilemap:"+camera.viewportWidth+"x"+camera.viewportHeight+" zoom:"+factor);
Gdx.app.debug(getClass().getSimpleName(), "Caméra pour tilemap:"
+ camera.viewportWidth + "x" + camera.viewportHeight + " zoom:"
+ factor);
}
public float getDecx() {
@ -159,7 +192,8 @@ public void setDec(float x,float y) {
decy = decy - dec.y;
camera.setToOrtho(false, viewwidth, viewheight);
camera.translate(decx, decy);
Gdx.app.debug(getClass().getSimpleName(),"Decalage:"+dec.x+"x"+dec.y+" newxy:"+decx+"x"+decy);
Gdx.app.debug(getClass().getSimpleName(), "Decalage:" + dec.x + "x"
+ dec.y + " newxy:" + decx + "x" + decy);
return;
}
@ -174,6 +208,4 @@ public void draw(Batch batch, float parentAlpha) {
batch.begin();
}
}

View File

@ -1,16 +1,11 @@
package fr.evolving.UI;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import fr.evolving.assets.AssetLoader;
@ -20,7 +15,9 @@ public class WarnDialog extends Dialog{
public WarnDialog(Skin skin) {
super("Informations", skin);
// TODO Auto-generated constructor stub
this.getContentTable().add(new ImageButton(AssetLoader.Skin_level,"Warnerbros")).left();
this.getContentTable()
.add(new ImageButton(AssetLoader.Skin_level, "Warnerbros"))
.left();
thelabel = new Label("MenuScenario", AssetLoader.Skin_level);
this.getContentTable().add(thelabel).right();
this.setModal(true);

View File

@ -1,12 +1,10 @@
package fr.evolving.UI;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.Array;
import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.Preference;
public class Worldlist extends List {

View File

@ -1,36 +1,24 @@
package fr.evolving.assets;
import java.util.Iterator;
import java.util.Locale;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.SkinLoader;
import com.badlogic.gdx.assets.loaders.TextureLoader;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.maps.tiled.TiledMapTileSet;
import com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile;
import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TooltipManager;
import com.badlogic.gdx.utils.Array;
@ -53,10 +41,10 @@ import fr.evolving.automata.Positiver_I;
import fr.evolving.automata.Positiver_II;
import fr.evolving.automata.Positiver_III;
import fr.evolving.automata.Transmuter;
import fr.evolving.database.Base.datatype;
import fr.evolving.database.DatabaseManager;
import fr.evolving.database.LocalBase;
import fr.evolving.database.SqlBase;
import fr.evolving.database.Base.datatype;
import fr.evolving.screens.GameScreen;
public class AssetLoader {
@ -93,14 +81,17 @@ public class AssetLoader {
params.genMipMaps = (quality == TextureFilter.MipMap);
Gdx.app.debug("AssetLoader", "Initialisation du asset manager");
manager = new AssetManager();
Gdx.app.debug("AssetLoader","Initialisation du chargement des éléments multimédia");
Gdx.app.debug("AssetLoader",
"Initialisation du chargement des éléments multimédia");
manager.load("textures/level.pack", TextureAtlas.class);
manager.load("textures/ui.pack", TextureAtlas.class);
manager.load("pictures/fond.png", Texture.class, params);
manager.load("pictures/fond2.png", Texture.class, params);
manager.load("musics/intro.mp3", Music.class);
manager.load("textures/level.json", Skin.class, new SkinLoader.SkinParameter("textures/level.pack"));
manager.load("textures/ui.json", Skin.class, new SkinLoader.SkinParameter("textures/ui.pack"));
manager.load("textures/level.json", Skin.class,
new SkinLoader.SkinParameter("textures/level.pack"));
manager.load("textures/ui.json", Skin.class,
new SkinLoader.SkinParameter("textures/ui.pack"));
}
public static void finishall() {
@ -119,11 +110,23 @@ public class AssetLoader {
Skin_ui = manager.get("textures/ui.json");
Gdx.app.debug("AssetLoader", "Definition des constantes");
Levelcolors = new Color[5];
Levelcolors=new Color[]{AssetLoader.Skin_level.getColor("world0"),AssetLoader.Skin_level.getColor("world1"),AssetLoader.Skin_level.getColor("world2"),AssetLoader.Skin_level.getColor("world3"),AssetLoader.Skin_level.getColor("world4")};
Levelcolors = new Color[] { AssetLoader.Skin_level.getColor("world0"),
AssetLoader.Skin_level.getColor("world1"),
AssetLoader.Skin_level.getColor("world2"),
AssetLoader.Skin_level.getColor("world3"),
AssetLoader.Skin_level.getColor("world4") };
Typecolors = new Color[13];
Typecolors=new Color[]{new Color(0,0,1f,1),new Color(0,0.6f,0,1),new Color(0.196f,0.803f,0.196f,1),new Color(0.5f,0.5f,0.5f,1),new Color(0.8f,0.8f,0.8f,1),new Color(0.6f,0,0,1),new Color(1f,0,0,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0,0,0.6f,1),new Color(0.294f,0.466f,0.615f,1),new Color(0.478f,0.192f,0.098f,1)};
Typecolors = new Color[] { new Color(0, 0, 1f, 1),
new Color(0, 0.6f, 0, 1), new Color(0.196f, 0.803f, 0.196f, 1),
new Color(0.5f, 0.5f, 0.5f, 1), new Color(0.8f, 0.8f, 0.8f, 1),
new Color(0.6f, 0, 0, 1), new Color(1f, 0, 0, 1),
new Color(0, 0, 0.6f, 1), new Color(0, 0, 0.6f, 1),
new Color(0, 0, 0.6f, 1), new Color(0, 0, 0.6f, 1),
new Color(0.294f, 0.466f, 0.615f, 1),
new Color(0.478f, 0.192f, 0.098f, 1) };
Typenames = new String[13];
Typenames=new String[]{"E-","e-","Ph","e0","E0","e+","E+","K","L","M","N","n","p"};
Typenames = new String[] { "E-", "e-", "Ph", "e0", "E0", "e+", "E+",
"K", "L", "M", "N", "n", "p" };
Gdx.app.debug("AssetLoader", "Création des tiles...");
tileSet = new TiledMapTileSet();
Array<TextureAtlas.AtlasRegion> allregions = Atlas_level.getRegions();
@ -131,38 +134,48 @@ public class AssetLoader {
for (int i = 0; i < allregions.size; i++) {
allregions.get(i).getTexture().setFilter(quality, quality);
if (allregions.get(i).name.startsWith("sprite")) {
if (allregions.get(i).name.contains("#"))
{
if (allregions.get(i).name.contains("#")) {
String[] name = allregions.get(i).name.split("_");
String[] type = name[0].split("-");
if (name[0].contains("sprite"))
{
if (name[0].contains("sprite")) {
int id = Integer.parseInt(name[1].split("#")[0]);
if (tileSet.getTile(1000 + id) == null) {
Gdx.app.debug("AssetLoader","Animated Tiles N°:"+String.valueOf(id+1000));
Gdx.app.debug("AssetLoader", "Animated Tiles N°:"
+ String.valueOf(id + 1000));
int maxid = 0;
for(int j=1;Atlas_level.findRegion("sprite-"+type[1]+"_"+id+"#"+j)!=null;j++)
for (int j = 1; Atlas_level.findRegion("sprite-"
+ type[1] + "_" + id + "#" + j) != null; j++)
maxid = j;
Array<StaticTiledMapTile> frameTiles=new Array<StaticTiledMapTile>(maxid);
Array<StaticTiledMapTile> frameTiles = new Array<StaticTiledMapTile>(
maxid);
for (int j = 1; j <= maxid; j++)
frameTiles.add(new StaticTiledMapTile((Atlas_level.findRegion("sprite-"+type[1]+"_"+id+"#"+j))));
AnimatedTiledMapTile atile=new AnimatedTiledMapTile(0.15f,frameTiles);
Gdx.app.debug("AssetLoader","Taille:"+String.valueOf(frameTiles.size));
frameTiles
.add(new StaticTiledMapTile(
(Atlas_level
.findRegion("sprite-"
+ type[1] + "_"
+ id + "#" + j))));
AnimatedTiledMapTile atile = new AnimatedTiledMapTile(
0.15f, frameTiles);
Gdx.app.debug("AssetLoader",
"Taille:" + String.valueOf(frameTiles.size));
atile.setId(1000 + id);
atile.getProperties().put("type", type[1]);
tileSet.putTile(1000 + id, atile);
}
}
}
else
{
} else {
String[] type = allregions.get(i).name.split("-");
StaticTiledMapTile atile= new StaticTiledMapTile(allregions.get(i));
StaticTiledMapTile atile = new StaticTiledMapTile(
allregions.get(i));
atile.setId(allregions.get(i).index);
atile.getProperties().put("type", type[1]);
tileSet.putTile(allregions.get(i).index, atile);
Gdx.app.debug("AssetLoader","Type:"+type[1]+" Tiles N°:"+String.valueOf(allregions.get(i).index));
Gdx.app.debug(
"AssetLoader",
"Type:" + type[1] + " Tiles N°:"
+ String.valueOf(allregions.get(i).index));
}
}
}
@ -183,15 +196,20 @@ public class AssetLoader {
Values<Integer> allTiles = transmuter.getTilesid().iterator();
while (allTiles.hasNext()) {
Integer atile = allTiles.next();
Gdx.app.debug("AssetLoader","Ajustement données Tiles N°:"+String.valueOf(atile)+" Nom:"+transmuter.getName());
AssetLoader.tileSet.getTile(atile).getProperties().put("transmuter", transmuter);
AssetLoader.tileSet.getTile(atile).getProperties().put("name", transmuter.getName());
Gdx.app.debug("AssetLoader",
"Ajustement données Tiles N°:" + String.valueOf(atile)
+ " Nom:" + transmuter.getName());
AssetLoader.tileSet.getTile(atile).getProperties()
.put("transmuter", transmuter);
AssetLoader.tileSet.getTile(atile).getProperties()
.put("name", transmuter.getName());
}
}
Gdx.app.debug("AssetLoader", "Ajout de la gestion des tooltips");
Tooltipmanager = new TooltipManager();
Gdx.app.debug("AssetLoader", "Ajout de la gestion des locales");
FileHandle baseFileHandle = Gdx.files.internal("i18n/messages/messages");
FileHandle baseFileHandle = Gdx.files
.internal("i18n/messages/messages");
usa = I18NBundle.createBundle(baseFileHandle, new Locale("en"));
french = I18NBundle.createBundle(baseFileHandle, new Locale("fr"));
if (Preference.prefs.getBoolean("Language"))
@ -208,15 +226,18 @@ public class AssetLoader {
public static void Databasemanagerfrompref() {
Datahandler.CloseAll();
if (Datahandler.Attach(datatype.userdata, Preference.prefs.getString("userdata")))
if (Datahandler.Attach(datatype.userdata,
Preference.prefs.getString("userdata")))
Gdx.app.debug("AssetLoader", "Base user ok");
else
Gdx.app.debug("AssetLoader", "Base user erreur");
if (Datahandler.Attach(datatype.statdata, Preference.prefs.getString("statdata")))
if (Datahandler.Attach(datatype.statdata,
Preference.prefs.getString("statdata")))
Gdx.app.debug("AssetLoader", "Base stat ok");
else
Gdx.app.debug("AssetLoader", "Base stat erreur");
if (Datahandler.Attach(datatype.gamedata, Preference.prefs.getString("gamedata")))
if (Datahandler.Attach(datatype.gamedata,
Preference.prefs.getString("gamedata")))
Gdx.app.debug("AssetLoader", "Base jeu ok");
else
Gdx.app.debug("AssetLoader", "Base jeu erreur");
@ -231,44 +252,53 @@ public class AssetLoader {
}
public static void init() {
Gdx.app.debug("AssetLoader","Initialisation de la résolution virtuelle...");
Gdx.app.debug("AssetLoader",
"Initialisation de la résolution virtuelle...");
int realWidth = Gdx.graphics.getWidth();
int realHeight = Gdx.graphics.getHeight();
float realRatio = realWidth / (float) realHeight;
Gdx.app.debug("AssetLoader","Résolution de "+realWidth+"x"+realHeight+" ratio de "+String.format("%.2f", realRatio)+".");
Gdx.app.debug("AssetLoader", "Résolution de " + realWidth + "x"
+ realHeight + " ratio de " + String.format("%.2f", realRatio)
+ ".");
ratio = 1;
width = 1920;
height = 1080;
if (Math.abs(16f / 9f - realRatio) > Math.abs(4f / 3f - realRatio)) {
ratio = 1.44f;
Gdx.app.debug("AssetLoader","Ratio 4/3, résolution virtuelle : 1920x1440.");
Gdx.app.debug("AssetLoader",
"Ratio 4/3, résolution virtuelle : 1920x1440.");
height = 1440;
}
else
Gdx.app.debug("AssetLoader","Ratio 16/9, résolution virtuelle : 1920x1080.");
} else
Gdx.app.debug("AssetLoader",
"Ratio 16/9, résolution virtuelle : 1920x1080.");
Camera = new OrthographicCamera(width, height);
Camera.position.set(width / 2, height / 2, 0);
Camera.update();
if (Preference.prefs.getInteger("Adaptation") == 1) {
viewport = new StretchViewport(width, height);
Gdx.app.debug("AssetLoader","Adaptation d'écran maximale, 'Aspect-Ratio' non conservé.");
}
else {
Gdx.app.debug("AssetLoader",
"Adaptation d'écran maximale, 'Aspect-Ratio' non conservé.");
} else {
viewport = new FitViewport(width, height);
Gdx.app.debug("AssetLoader","Adaptation d'écran totale, 'Aspect-Ratio' conservé.");
Gdx.app.debug("AssetLoader",
"Adaptation d'écran totale, 'Aspect-Ratio' conservé.");
}
viewport.apply();
}
public static void load() {
Gdx.app.debug("AssetLoader", "Réglage de la qualité des textures");
quality=GameScreen.quality.values()[Preference.prefs.getInteger("Quality")].getQuality();
quality = GameScreen.quality.values()[Preference.prefs
.getInteger("Quality")].getQuality();
Gdx.app.debug("AssetLoader", "Chargements des éléments minimalistes");
Texture_logo = new Texture(Gdx.files.internal("pictures/logo.png"),quality==TextureFilter.MipMap);
Texture_logo = new Texture(Gdx.files.internal("pictures/logo.png"),
quality == TextureFilter.MipMap);
Texture_logo.setFilter(quality, quality);
emptyT=new Texture(Gdx.files.internal("pictures/empty.png"),quality==TextureFilter.MipMap);
emptyT = new Texture(Gdx.files.internal("pictures/empty.png"),
quality == TextureFilter.MipMap);
emptyT.setFilter(quality, quality);
fullT=new Texture(Gdx.files.internal("pictures/full.png"),quality==TextureFilter.MipMap);
fullT = new Texture(Gdx.files.internal("pictures/full.png"),
quality == TextureFilter.MipMap);
fullT.setFilter(quality, quality);
empty = new NinePatch(new TextureRegion(emptyT, 24, 24), 8, 8, 8, 8);
full = new NinePatch(new TextureRegion(fullT, 24, 24), 8, 8, 8, 8);

View File

@ -2,7 +2,6 @@ package fr.evolving.assets;
import com.badlogic.gdx.utils.Array;
import fr.evolving.automata.Cell;
import fr.evolving.automata.Grid;
import fr.evolving.automata.Level;
@ -16,25 +15,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Introduction",
"Prise en main de l'interface de WireChem{#169} et amener l'électron neutre sur le senseur.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
38f,
740f,
-1,
0,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 1}, {0, 8}});
"e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 38f, 740f,
-1, 0, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999, 99999,
99999, "", false, new int[][] { { 0, 1 }, { 0, 8 } });
thelevels[1] = new Level(
0,
@ -42,25 +26,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Trajectoires",
"Comprendre les trajectoires empruntées par les électrons afin de mieux appréhender la conception de systèmes.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
38f,
260f,
-1,
0,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 2}});
"e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 38f, 260f,
-1, 0, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999, 99999,
99999, "", false, new int[][] { { 0, 2 } });
thelevels[2] = new Level(
0,
@ -68,26 +37,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Pistes",
"Utiliser des pistes afin de réaliser un circuit qui permet l'arrivée d'un électron neutre sur le senseur.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
180f,
460f,
-1,
15,
new Grid(10,3),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 3}});
"e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 180f,
460f, -1, 15, new Grid(10, 3), 0, 0, 0, 0, 99999, 99999, 99999,
99999, "", false, new int[][] { { 0, 3 } });
thelevels[3] = new Level(
0,
@ -95,25 +48,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Positiveur",
"Comprendre le fonctionnement de l'élément positiveur et générer 8 électrons positifs sur le senseur.",
"e+",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0},
380f,
550f,
0,
16,
new Grid(30,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 4}});
"e+", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0 }, 380f,
550f, 0, 16, new Grid(30, 20), 0, 0, 0, 0, 99999, 99999, 99999,
99999, "", false, new int[][] { { 0, 4 } });
thelevels[4] = new Level(
0,
@ -121,25 +59,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Super-électrons",
"Générer 2 super-électrons negatifs par colision et les amener sur le senseur.",
"E-",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
590f,
550f,
0,
16,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 5}});
"E-", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 590f,
550f, 0, 16, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999, 99999,
99999, "", false, new int[][] { { 0, 5 } });
thelevels[5] = new Level(
0,
@ -147,25 +70,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Activation",
"L'objectif est de générer 6 électrons neutres et de découvrir les liaisons de fibres par lesquelles transitent les photons. Certains modifieurs nécessitent désormais l'activation par des photons.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0},
590f,
220f,
1,
136,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 6}});
"e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 590f,
220f, 1, 136, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
99999, 99999, "", false, new int[][] { { 0, 6 } });
thelevels[6] = new Level(
0,
@ -173,26 +81,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Fibres",
"A vous de dessiner votre infrastructure à base de fibres et de pistes mais aussi de modifieur activable afin de faire parvenir des éléctrons positifs et neutres sur les senseurs.",
"eX",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0},
790f,
220f,
2,
230,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 7}});
"eX", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0 }, 790f,
220f, 2, 230, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
99999, 99999, "", false, new int[][] { { 0, 7 } });
thelevels[7] = new Level(
0,
@ -200,25 +92,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Protons",
"Générer deux protons sur le senseur en utilisant un réacteur et un super-positron. Le réacteur est un élément qui nécessite l'activation.",
"p",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
950f,
400f,
2,
370,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 8}});
"p", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, 950f,
400f, 2, 370, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
99999, 99999, "", false, new int[][] { { 0, 8 } });
thelevels[8] = new Level(
0,
@ -226,25 +103,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Hydrogène",
"Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.",
"H",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
1050f,
740f,
3,
750,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
true,
new int[][]{{1, 0},{1, 2}});
"H", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }, 1050f,
740f, 3, 750, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
99999, 99999, "", true, new int[][] { { 1, 0 }, { 1, 2 } });
thelevels[9] = new Level(
1,
@ -252,25 +114,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Deutérium",
"Générer le Deutérium, un isostope de l'hydrogène, celui-ci comporte un neutron en plus du proton et de l'électron négatif sur la couche K.",
"D",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
30f,
700f,
4,
1100,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 1}});
"D", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 }, 30f, 700f,
4, 1100, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999, 99999,
99999, "", false, new int[][] { { 1, 1 } });
thelevels[10] = new Level(
1,
@ -278,25 +125,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Tritium",
"Générer le second isostope de l'hydrogène : cet atome plus lourd que le Deutérium comporte alors deux neutrons, un proton ainsi qu'un électron négatif sur la couche K.",
"T",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1},
420f,
750f,
4,
1000,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{}});
"T", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1 }, 420f,
750f, 4, 1000, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
99999, 99999, "", false, new int[][] { {} });
thelevels[11] = new Level(
1,
@ -304,25 +136,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Hélium-4",
"L'isotope le plus courant de l'Hélium dans l'atmosphère terrestre est l'Hélium-4. Générer le en associant deux protons, deux neutrons et deux électrons négatifs sur la couche K.",
"He",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 2},
30f,
350f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
800,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 3},{1, 5}});
"He", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 2 }, 30f, 350f,
4, 1200, new Grid(20, 20), 0, 0, 0, 0, 800, 99999, 99999,
99999, "", false, new int[][] { { 1, 3 }, { 1, 5 } });
thelevels[12] = new Level(
1,
@ -330,25 +147,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Hélium-3",
"Générer le seul autre isotope stable de l'hélium, ce dernier n'étant présent qu'à l'état de traces sur Terre. Cet isotope comporte deux protons,un neutron et deux électrons négatifs sur la couche K.",
"He",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 2},
180f,
230f,
4,
1300,
new Grid(20,20),
0,
0,
0,
0,
700,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 4}});
"He", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 2 }, 180f,
230f, 4, 1300, new Grid(20, 20), 0, 0, 0, 0, 700, 99999, 99999,
99999, "", false, new int[][] { { 1, 4 } });
thelevels[13] = new Level(
1,
@ -356,25 +158,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Hélium-8",
"l'Hélium-8 est le plus étudié des isotopes lourds de l'Hélium avec l'Hélium-6. Cet isostope comporte deux protons, six neutrons et deux électrons négatifs sur la couche K.",
"He",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 6, 2},
420f,
230f,
5,
1500,
new Grid(20,20),
0,
0,
0,
0,
1800,
99999,
99999,
99999,
"",
false,
new int[][]{{}});
"He", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 6, 2 }, 420f,
230f, 5, 1500, new Grid(20, 20), 0, 0, 0, 0, 1800, 99999,
99999, 99999, "", false, new int[][] { {} });
thelevels[14] = new Level(
1,
@ -382,25 +169,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Lithium",
"Générer un isostope de l'hydrogène qui comporte un proton et un neutron ainsi qu'un électron négatif sur la couche K.",
"Li",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
300f,
490f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 6}});
"Li", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 }, 300f,
490f, 4, 1200, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
99999, 99999, "", false, new int[][] { { 1, 6 } });
thelevels[15] = new Level(
1,
@ -408,25 +180,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Carbone",
"Générer un isostope de l'hydrogène qui comporte un proton et un neutron ainsi qu'un électron négatif sur la couche K.",
"C",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
550f,
490f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 7}});
"C", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 }, 550f,
490f, 4, 1200, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
99999, 99999, "", false, new int[][] { { 1, 7 } });
thelevels[16] = new Level(
1,
@ -434,25 +191,10 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Oxygène",
"Générer un isostope de l'hydrogène qui comporte un proton et un neutron ainsi qu'un électron négatif sur la couche K.",
"O",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1},
800f,
570f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 8}});
"O", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 }, 800f,
570f, 4, 1200, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
99999, 99999, "", false, new int[][] { { 1, 8 } });
thelevels[17] = new Level(
1,
@ -460,189 +202,61 @@ public class InitWorlds {
(int) (Math.random() * Integer.MAX_VALUE),
"Néon",
"Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.",
"Ne",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1},
1000f,
750f,
6,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
true,
new int[][]{{}});
"Ne", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, 1000f,
750f, 6, 1200, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
99999, 99999, "", true, new int[][] { {} });
thelevels[18]=new Level(
2,
1,
(int)(Math.random()*Integer.MAX_VALUE),
"test",
"C'est un test.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
38f,
740f,
-1,
0,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
thelevels[18] = new Level(2, 1,
(int) (Math.random() * Integer.MAX_VALUE), "test",
"C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0 }, 38f, 740f, -1, 0, new Grid(20, 20), 0, 0, 0,
0, 99999, 99999, 99999, 99999, "", false,
new int[][] { { 2, 2 } });
thelevels[19]=new Level(
2,
2,
(int)(Math.random()*Integer.MAX_VALUE),
"test",
"C'est un test.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
238f,
340f,
-1,
0,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{});
thelevels[19] = new Level(2, 2,
(int) (Math.random() * Integer.MAX_VALUE), "test",
"C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0 }, 238f, 340f, -1, 0, new Grid(20, 20), 0, 0,
0, 0, 99999, 99999, 99999, 99999, "", false, new int[][] {});
thelevels[20]=new Level(
3,
1,
(int)(Math.random()*Integer.MAX_VALUE),
"test",
"C'est un test.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
38f,
740f,
-1,
0,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
thelevels[20] = new Level(3, 1,
(int) (Math.random() * Integer.MAX_VALUE), "test",
"C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0 }, 38f, 740f, -1, 0, new Grid(20, 20), 0, 0, 0,
0, 99999, 99999, 99999, 99999, "", false,
new int[][] { { 3, 2 } });
;
thelevels[21]=new Level(
3,
2,
(int)(Math.random()*Integer.MAX_VALUE),
"test",
"C'est un test.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
438f,
540f,
-1,
0,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{});
thelevels[21] = new Level(3, 2,
(int) (Math.random() * Integer.MAX_VALUE), "test",
"C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0 }, 438f, 540f, -1, 0, new Grid(20, 20), 0, 0,
0, 0, 99999, 99999, 99999, 99999, "", false, new int[][] {});
thelevels[22]=new Level(
4,
1,
(int)(Math.random()*Integer.MAX_VALUE),
"test",
"C'est un test.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
38f,
740f,
-1,
0,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
thelevels[22] = new Level(4, 1,
(int) (Math.random() * Integer.MAX_VALUE), "test",
"C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0 }, 38f, 740f, -1, 0, new Grid(20, 20), 0, 0, 0,
0, 99999, 99999, 99999, 99999, "", false,
new int[][] { { 4, 2 } });
;
thelevels[23]=new Level(
4,
2,
(int)(Math.random()*Integer.MAX_VALUE),
"test",
"C'est un test.",
"e0",
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
238f,
640f,
-1,
0,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{});
thelevels[23] = new Level(4, 2,
(int) (Math.random() * Integer.MAX_VALUE), "test",
"C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0 }, 238f, 640f, -1, 0, new Grid(20, 20), 0, 0,
0, 0, 99999, 99999, 99999, 99999, "", false, new int[][] {});
return new Array<Level>(thelevels);
}
}

View File

@ -1,5 +1,6 @@
package fr.evolving.assets;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.Graphics.DisplayMode;
@ -9,17 +10,11 @@ import com.badlogic.gdx.math.Vector2;
public class Preference {
public static Preferences prefs;
public static int init() {
public static void init() {
prefs = Gdx.app.getPreferences("WireWorld - Evolving Games");
//debug();
//test();
if (prefs.contains("log"))
return prefs.getInteger("log");
else
{
if (!prefs.contains("log"))
defaults();
return Gdx.app.LOG_INFO;
}
Gdx.app.setLogLevel(prefs.getInteger("log"));
}
public static Vector2 getmaxresolution() {
@ -28,7 +23,8 @@ public class Preference {
int res;
for (DisplayMode mode : modes) {
int temppixel = mode.height * mode.width;
if (temppixel>totalpixel) totalpixel=temppixel;
if (temppixel > totalpixel)
totalpixel = temppixel;
}
for (DisplayMode mode : modes)
if (totalpixel == mode.height * mode.width)
@ -38,7 +34,9 @@ public class Preference {
public static void defaults() {
Vector2 maxres = getmaxresolution();
Gdx.app.log("Preferences","Preference par defaut avec resolution native :"+maxres.x+"x"+maxres.y);
Gdx.app.log("Preferences",
"Preference par defaut avec resolution native :" + maxres.x
+ "x" + maxres.y);
Preference.prefs.putString("userdata", "local:test.db");
Preference.prefs.putString("gamedata", "local:test.db");
Preference.prefs.putString("statdata", "local:test.db");
@ -55,34 +53,9 @@ public class Preference {
Preference.prefs.putString("world", "test pour voir");
Preference.prefs.putFloat("Effect", 1.0f);
Preference.prefs.putFloat("Music", 0.75f);
Preference.prefs.putInteger("Adaptation", 2);
Preference.prefs.putInteger("Adaptation", 0);
Preference.prefs.putInteger("Quality", 2);
Preference.prefs.putInteger("log", Gdx.app.LOG_INFO);
Preference.prefs.flush();
}
public static void debug() {
Preference.prefs.putInteger("ResolutionX", 1280);
Preference.prefs.putInteger("ResolutionY", 720);
Preference.prefs.putBoolean("Fullscreen", false);
Preference.prefs.putBoolean("VSync", false);
Preference.prefs.putInteger("log", Gdx.app.LOG_DEBUG);
Gdx.app.setLogLevel(Gdx.app.LOG_DEBUG);
Preference.prefs.flush();
}
public static void test() {
Preference.prefs.putInteger("ResolutionX", 1920);
Preference.prefs.putInteger("ResolutionY", 1080);
Preference.prefs.putBoolean("Fullscreen", true);
Preference.prefs.putBoolean("VSync", true);
Preference.prefs.putInteger("log", Gdx.app.LOG_INFO);
Gdx.app.setLogLevel(Gdx.app.LOG_INFO);
Preference.prefs.flush();
}
}

View File

@ -1,7 +1,6 @@
package fr.evolving.automata;
import java.io.Serializable;
import com.badlogic.gdx.graphics.g2d.Sprite;
public class Cell implements Serializable {
public int Fiber;

View File

@ -1,15 +1,12 @@
package fr.evolving.automata;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.ObjectMap.Entry;
import fr.evolving.automata.Transmuter.CaseType;
public class Grid implements Serializable {
public Cell[][] Cells;
public Integer sizeX, sizeY;
@ -32,30 +29,31 @@ public class Grid implements Serializable{
for (int x = 0; x < this.sizeX; x++)
for (int y = 0; y < this.sizeY; y++) {
Transmuter transmuter = getTransmuter(x, y);
if (transmuter!=null)
{
Iterator<Entry<Vector2, Integer>> tiles = transmuter.getTilesidrotated().iterator();
if (transmuter != null) {
Iterator<Entry<Vector2, Integer>> tiles = transmuter
.getTilesidrotated().iterator();
while (tiles.hasNext()) {
Entry<Vector2, Integer> all = tiles.next();
GetXY(x+all.key.x,y+all.key.y).Transmuter_calc=(1<<16)*transmuter.getRotation().ordinal()+all.value;
GetXY(x + all.key.x, y + all.key.y).Transmuter_calc = (1 << 16)
* transmuter.getRotation().ordinal()
+ all.value;
GetXY(x + all.key.x, y + all.key.y).Transmuter_movex = (int) -all.key.x;
GetXY(x + all.key.x, y + all.key.y).Transmuter_movey = (int) -all.key.y;
}
}
}
for (int x = 0; x < this.sizeX; x++)
for (int y=0;y<this.sizeY;y++)
{
for (int y = 0; y < this.sizeY; y++) {
if (GetXY(x, y).Transmuter_calc > 0)
Gdx.app.debug("info",x+","+y+">"+GetXY(x, y).Transmuter_calc);
Gdx.app.debug("info", x + "," + y + ">"
+ GetXY(x, y).Transmuter_calc);
}
}
public void tiling_copper() {
for (int x = 0; x < this.sizeX; x++)
for (int y = 0; y < this.sizeY; y++)
if (getCopper(x,y))
{
if (getCopper(x, y)) {
int value = 0;
if (getCopper(x, y + 1))
value++;
@ -66,15 +64,12 @@ public class Grid implements Serializable{
if (getCopper(x + 1, y))
value += 2;
GetXY(x, y).Copper_calc = value;
}
else
} else
GetXY(x, y).Copper_calc = -1;
for (int x = 0; x < this.sizeX; x++)
for (int y=0;y<this.sizeY;y++)
{
for (int y = 0; y < this.sizeY; y++) {
int value = 0;
if (getCoppercalc(x,y)==15)
{
if (getCoppercalc(x, y) == 15) {
if (getCopper(x - 1, y - 1))
value++;
if (getCopper(x, y - 1))
@ -93,38 +88,43 @@ public class Grid implements Serializable{
value++;
if (value >= 5)
GetXY(x, y).Copper_calc = GetXY(x, y).Copper_calc + 20;
}
else
{
if (getCoppercalc(x,y)!=-1)
{
} else {
if (getCoppercalc(x, y) != -1) {
int oldvalue = GetXY(x, y).Copper_calc;
if (getCoppercalc(x-1,y-1)==15 || getCoppercalc(x-1,y-1)==35)
if (getCoppercalc(x - 1, y - 1) == 15
|| getCoppercalc(x - 1, y - 1) == 35)
value++;
if (getCoppercalc(x,y-1)==15 || getCoppercalc(x,y-1)==35)
if (getCoppercalc(x, y - 1) == 15
|| getCoppercalc(x, y - 1) == 35)
value++;
if (getCoppercalc(x+1,y-1)==15 || getCoppercalc(x+1,y-1)==35)
if (getCoppercalc(x + 1, y - 1) == 15
|| getCoppercalc(x + 1, y - 1) == 35)
value++;
if (getCoppercalc(x-1,y)==15 || getCoppercalc(x-1,y)==35)
if (getCoppercalc(x - 1, y) == 15
|| getCoppercalc(x - 1, y) == 35)
value++;
if (getCoppercalc(x+1,y)==15 || getCoppercalc(x+1,y)==35)
if (getCoppercalc(x + 1, y) == 15
|| getCoppercalc(x + 1, y) == 35)
value++;
if (getCoppercalc(x-1,y+1)==15 || getCoppercalc(x-1,y+1)==35)
if (getCoppercalc(x - 1, y + 1) == 15
|| getCoppercalc(x - 1, y + 1) == 35)
value++;
if (getCoppercalc(x,y+1)==15 || getCoppercalc(x,y+1)==35)
if (getCoppercalc(x, y + 1) == 15
|| getCoppercalc(x, y + 1) == 35)
value++;
if (getCoppercalc(x+1,y+1)==15 || getCoppercalc(x+1,y+1)==35)
if (getCoppercalc(x + 1, y + 1) == 15
|| getCoppercalc(x + 1, y + 1) == 35)
value++;
if (value>=1 && oldvalue!=1 && oldvalue!=2 && oldvalue!=4 && oldvalue!=8 && oldvalue!=10 && oldvalue!=5)
if (value >= 1 && oldvalue != 1 && oldvalue != 2
&& oldvalue != 4 && oldvalue != 8
&& oldvalue != 10 && oldvalue != 5)
GetXY(x, y).Copper_calc = oldvalue + 20;
}
}
}
for (int x = 0; x < this.sizeX; x++)
for (int y=0;y<this.sizeY;y++)
{
if (getCoppercalc(x,y)==35)
{
for (int y = 0; y < this.sizeY; y++) {
if (getCoppercalc(x, y) == 35) {
int value = 0;
if (!getCopper(x + 1, y + 1))
value += 2;
@ -138,11 +138,10 @@ public class Grid implements Serializable{
}
}
for (int x = 0; x < this.sizeX; x++)
for (int y=0;y<this.sizeY;y++)
{
for (int y = 0; y < this.sizeY; y++) {
int oldvalue = GetXY(x, y).Copper_calc;
if (oldvalue==27||oldvalue==31||oldvalue==33||oldvalue==34)
{
if (oldvalue == 27 || oldvalue == 31 || oldvalue == 33
|| oldvalue == 34) {
int value = 0;
if (getCopper(x, y + 1) && getCoppercalc(x, y + 1) < 15)
value += 1;
@ -156,21 +155,45 @@ public class Grid implements Serializable{
GetXY(x, y).Copper_calc = oldvalue + 22 + value;
}
int value = 0;
if (oldvalue==34 && (getCoppercalc(x-1,y)==31 || getCoppercalc(x-1,y)==55 || getCoppercalc(x-1,y)==58))
if (oldvalue == 34
&& (getCoppercalc(x - 1, y) == 31
|| getCoppercalc(x - 1, y) == 55 || getCoppercalc(
x - 1, y) == 58))
value = 62;
if (oldvalue==34 && (getCoppercalc(x+1,y)==31 || getCoppercalc(x+1,y)==55 || getCoppercalc(x+1,y)==58))
if (oldvalue == 34
&& (getCoppercalc(x + 1, y) == 31
|| getCoppercalc(x + 1, y) == 55 || getCoppercalc(
x + 1, y) == 58))
value = 58;
if (oldvalue==31 && (getCoppercalc(x-1,y)==34 || getCoppercalc(x-1,y)==58 || getCoppercalc(x-1,y)==62))
if (oldvalue == 31
&& (getCoppercalc(x - 1, y) == 34
|| getCoppercalc(x - 1, y) == 58 || getCoppercalc(
x - 1, y) == 62))
value = 59;
if (oldvalue==31 && (getCoppercalc(x+1,y)==34 || getCoppercalc(x+1,y)==58 || getCoppercalc(x+1,y)==62))
if (oldvalue == 31
&& (getCoppercalc(x + 1, y) == 34
|| getCoppercalc(x + 1, y) == 58 || getCoppercalc(
x + 1, y) == 62))
value = 55;
if (oldvalue==33 && (getCoppercalc(x,y-1)==27 || getCoppercalc(x,y-1)==50 || getCoppercalc(x,y-1)==51))
if (oldvalue == 33
&& (getCoppercalc(x, y - 1) == 27
|| getCoppercalc(x, y - 1) == 50 || getCoppercalc(
x, y - 1) == 51))
value = 57;
if (oldvalue==33 && (getCoppercalc(x,y+1)==27 || getCoppercalc(x,y+1)==50 || getCoppercalc(x,y+1)==51))
if (oldvalue == 33
&& (getCoppercalc(x, y + 1) == 27
|| getCoppercalc(x, y + 1) == 50 || getCoppercalc(
x, y + 1) == 51))
value = 56;
if (oldvalue==27 && (getCoppercalc(x,y-1)==33 || getCoppercalc(x,y-1)==56 || getCoppercalc(x,y-1)==57))
if (oldvalue == 27
&& (getCoppercalc(x, y - 1) == 33
|| getCoppercalc(x, y - 1) == 56 || getCoppercalc(
x, y - 1) == 57))
value = 51;
if (oldvalue==27 && (getCoppercalc(x,y+1)==33 || getCoppercalc(x,y+1)==56 || getCoppercalc(x,y+1)==57))
if (oldvalue == 27
&& (getCoppercalc(x, y + 1) == 33
|| getCoppercalc(x, y + 1) == 56 || getCoppercalc(
x, y + 1) == 57))
value = 50;
if (value > 0)
GetXY(x, y).Copper_calc = value;
@ -179,7 +202,6 @@ public class Grid implements Serializable{
return;
}
public Cell GetXY(float X, float Y) {
if (X < 0 || Y < 0 || X >= this.sizeX || Y >= this.sizeY)
return null;
@ -235,5 +257,4 @@ public class Grid implements Serializable{
return cell.Copper_calc;
}
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Inverter_I extends Transmuter {
private static String Name, Desc;
@ -151,8 +146,12 @@ public class Inverter_I extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Inverter_II extends Transmuter {
private static String Name, Desc;
@ -151,8 +146,12 @@ public class Inverter_II extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -29,7 +29,11 @@ public class Level implements Serializable{
public String Tuto;
public int[][] Link;
public Level(int aWorld, int aLevel,int id,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){
public Level(int aWorld, int aLevel, int id, 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;

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Negativer extends Transmuter {
private static String Name, Desc;
@ -151,8 +146,12 @@ public class Negativer extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Negativer_I extends Transmuter {
private static String Name, Desc;
@ -153,8 +148,12 @@ public class Negativer_I extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Negativer_II extends Transmuter {
private static String Name, Desc;
@ -153,8 +148,12 @@ public class Negativer_II extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Negativer_III extends Transmuter {
private static String Name, Desc;
@ -152,8 +147,12 @@ public class Negativer_III extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Neutraliser_I extends Transmuter {
private static String Name, Desc;
@ -151,8 +146,12 @@ public class Neutraliser_I extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Neutraliser_II extends Transmuter {
private static String Name, Desc;
@ -151,8 +146,12 @@ public class Neutraliser_II extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Positiver extends Transmuter {
private static String Name, Desc;
@ -151,8 +146,12 @@ public class Positiver extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,16 +1,11 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
public class Positiver_I extends Transmuter {
private static String Name, Desc;
private static Class theClass;
@ -153,8 +148,12 @@ public class Positiver_I extends Transmuter {
while (tiles.hasNext()) {
Vector2 key = tiles.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Positiver_II extends Transmuter {
private static String Name, Desc;
@ -153,8 +148,12 @@ public class Positiver_II extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,15 +1,10 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Positiver_III extends Transmuter {
private static String Name, Desc;
@ -151,8 +146,12 @@ public class Positiver_III extends Transmuter {
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}

View File

@ -1,10 +1,7 @@
package fr.evolving.automata;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.ObjectMap.Entries;
import com.badlogic.gdx.utils.ObjectMap.Entry;
@ -12,9 +9,18 @@ import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
public abstract class Transmuter implements Cloneable, Serializable {
public enum CaseType{Rien,Cuivre_seul,Fibre_seul,Cuivre,Fibre,Tout,Nimporte};
public enum Class{Structure,Charge,Direction,Filtrage,Synthese,Detection,Divers,Scenario};
public enum Angular{A00,A90,A180,A270};
public enum CaseType {
Rien, Cuivre_seul, Fibre_seul, Cuivre, Fibre, Tout, Nimporte
};
public enum Class {
Structure, Charge, Direction, Filtrage, Synthese, Detection, Divers, Scenario
};
public enum Angular {
A00, A90, A180, A270
};
protected Level level;
protected Angular Rotation;
@ -193,13 +199,55 @@ public abstract class Transmuter implements Cloneable,Serializable {
OrderedMap<Vector2, Integer> tiles = this.getTilesidrotated();
Entries<Vector2, Integer> iterator = tiles.iterator();
String result;
result="**********************************\n"+"Name:"+this.getName()+"\nClass:"+this.getaClass()+" Rotation:"+this.getRotation()+"\nPrice:"+this.getPrice()+" Tech:"+this.getTechnology()+"\nResearch:"+this.getResearch()+" Size:"+this.getSize()+"\nActivable:"+this.isActivable()+" Activation:"+this.getActivationLevel()+" Visible:"+this.isShowed()+"\nUpgradable:"+((this.isUpgradable())?this.getUpgrade().getName():this.isUpgradable())+" Unlockable:"+((this.isUnlockable())?this.getUnlock().getName():this.isUnlockable())+"\nUpgrade Cycle:"+this.getUpgradeCycle()+" upgrade:"+this.isUpgradableCycle()+"\nUpgrade Temperature:"+this.getUpgradeTemp()+" upgrade:"+this.isUpgradableTemp()+"\nUpgrade Nrj:"+this.getUpgradeNrj()+" upgrade:"+this.isUpgradableNrj()+"\nUpgrade Rayon:"+this.getUpgradeRayon()+" upgrade:"+this.isUpgradableRayon()+"\nTemperature /turn:"+this.getTurnTemp()+" Rayon /turn:"+this.getTurnRayon()+" Nrj /turn:"+this.getTurnNrj()+"\nTemperature /use:"+this.getUsedTemp()+" Rayon /use:"+this.getUsedRayon()+" Nrj /use:"+this.getUsedNrj()+"\nTiles:";
result = "**********************************\n" + "Name:"
+ this.getName()
+ "\nClass:"
+ this.getaClass()
+ " Rotation:"
+ this.getRotation()
+ "\nPrice:"
+ this.getPrice()
+ " Tech:"
+ this.getTechnology()
+ "\nResearch:"
+ this.getResearch()
+ " Size:"
+ this.getSize()
+ "\nActivable:"
+ this.isActivable()
+ " Activation:"
+ this.getActivationLevel()
+ " Visible:"
+ this.isShowed()
+ "\nUpgradable:"
+ ((this.isUpgradable()) ? this.getUpgrade().getName() : this
.isUpgradable())
+ " Unlockable:"
+ ((this.isUnlockable()) ? this.getUnlock().getName() : this
.isUnlockable()) + "\nUpgrade Cycle:"
+ this.getUpgradeCycle() + " upgrade:"
+ this.isUpgradableCycle() + "\nUpgrade Temperature:"
+ this.getUpgradeTemp() + " upgrade:" + this.isUpgradableTemp()
+ "\nUpgrade Nrj:" + this.getUpgradeNrj() + " upgrade:"
+ this.isUpgradableNrj() + "\nUpgrade Rayon:"
+ this.getUpgradeRayon() + " upgrade:"
+ this.isUpgradableRayon() + "\nTemperature /turn:"
+ this.getTurnTemp() + " Rayon /turn:" + this.getTurnRayon()
+ " Nrj /turn:" + this.getTurnNrj() + "\nTemperature /use:"
+ this.getUsedTemp() + " Rayon /use:" + this.getUsedRayon()
+ " Nrj /use:" + this.getUsedNrj() + "\nTiles:";
Values<Integer> allTiles = this.getTilesid().iterator();
while (allTiles.hasNext())
result += String.valueOf(allTiles.next()) + " ";
while (iterator.hasNext()) {
Entry<Vector2, Integer> all = iterator.next();
result+="\ncoords:" + all.key.x+","+all.key.y + " type: " + this.getTilestype(tiles.keys().toArray().indexOf(all.key, false)) +" id:"+all.value;
result += "\ncoords:"
+ all.key.x
+ ","
+ all.key.y
+ " type: "
+ this.getTilestype(tiles.keys().toArray()
.indexOf(all.key, false)) + " id:" + all.value;
}
result += "\n**********************************";
return result;

View File

@ -7,7 +7,9 @@ import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
public abstract class Base {
public enum datatype{statdata,userdata,gamedata}
public enum datatype {
statdata, userdata, gamedata
}
public Base(datatype model, String param) {
}
@ -84,7 +86,6 @@ public abstract class Base {
// Gestion type Stat
// Commun
public boolean Eraseall(datatype base) {
@ -102,6 +103,4 @@ public abstract class Base {
return "";
}
}

View File

@ -55,9 +55,7 @@ public class DatabaseManager {
bases[model.ordinal()] = backend;
old[model.ordinal()] = Url;
return true;
}
else
{
} else {
bases[model.ordinal()] = null;
old[model.ordinal()] = null;
return false;
@ -74,7 +72,8 @@ public class DatabaseManager {
try {
back = (Base) classe.newInstance();
if (back.getprefix().equals(Type)) {
back = (Base) classe.getDeclaredConstructor(cArg).newInstance(model,Url);
back = (Base) classe.getDeclaredConstructor(cArg)
.newInstance(model, Url);
return back;
}
} catch (InstantiationException | IllegalAccessException

View File

@ -2,17 +2,9 @@ package fr.evolving.database;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import javax.xml.bind.DatatypeConverter;
import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.sql.Database;
@ -22,11 +14,9 @@ import com.badlogic.gdx.sql.SQLiteGdxException;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Base64Coder;
import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Grid;
import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
import fr.evolving.database.Base.datatype;
public class LocalBase extends Base {
private static Database dbHandler;
@ -52,16 +42,13 @@ public class LocalBase extends Base {
switch (Gdx.app.getType()) {
case Android:
try {
if (!Gdx.files.absolute("/data/data/fr.evolving.game.android/databases/"+databasename).exists()) {
FileHandle newbase = Gdx.files.absolute("/data/data/fr.evolving.game.android/databases/"+ databasename);
if (!newbase.exists()) {
Gdx.app.log("Base", "Copie de la base de donnee android");
byte[] ByteSource = Gdx.files.internal("bases/"+databasename).readBytes();
FileOutputStream destination = new FileOutputStream("/data/data/fr.evolving.game.android/databases/"+databasename);
destination.write(ByteSource);
destination.close();
Gdx.files.internal("bases/" + databasename).copyTo(newbase);
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (Exception e1) {
Gdx.app.error("Base", "Erreur de copie");
}
break;
case Desktop:
@ -71,22 +58,23 @@ public class LocalBase extends Base {
if (!newbase.exists())
Gdx.files.internal("bases/" + databasename).copyTo(newbase);
} catch (Exception e1) {
e1.printStackTrace();
Gdx.app.error("Base", "Erreur de copie");
}
break;
}
if (dbHandler != null)
Gdx.app.log("Local", "Reprise de la base '"+databasename+"', table:"+model.toString());
else
{
Gdx.app.log("Local", "Utilisation de la base '"+databasename+"', table:"+model.toString());
dbHandler = DatabaseFactory.getNewDatabase(databasename,1, null, null);
Gdx.app.log("Local", "Reprise de la base '" + databasename
+ "', table:" + model.toString());
else {
Gdx.app.log("Local", "Utilisation de la base '" + databasename
+ "', table:" + model.toString());
dbHandler = DatabaseFactory.getNewDatabase(databasename, 1, null,
null);
dbHandler.setupDatabase();
try {
dbHandler.openOrCreateDatabase();
}
catch (SQLiteGdxException e) {
} catch (SQLiteGdxException e) {
e.printStackTrace();
Gdx.app.log("Local", "Erreur à l'ouverture de la base");
}
@ -95,13 +83,17 @@ public class LocalBase extends Base {
if (model == datatype.statdata)
creation = "create table if not exists stat (id integer)";
else if (model == datatype.userdata) {
dbHandler.execSQL("CREATE TABLE if not exists locks(date DATETIME DEFAULT CURRENT_TIMESTAMP, level INTEGER NOT NULL, user INTEGER NOT NULL, PRIMARY KEY(level,user));");
dbHandler.execSQL("CREATE TABLE if not exists grids(date DATETIME DEFAULT CURRENT_TIMESTAMP, level INTEGER NOT NULL, user INTEGER NOT NULL, tag TEXT, object TEXT, PRIMARY KEY(level,user,date));");
dbHandler.execSQL("CREATE TABLE if not exists transmuters(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, object TEXT, PRIMARY KEY(user));");
dbHandler.execSQL("CREATE TABLE if not exists research(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, value INT, PRIMARY KEY(user));");
}
else
dbHandler.execSQL("CREATE TABLE if not exists worlds(date DATETIME DEFAULT CURRENT_TIMESTAMP, desc TEXT NOT NULL, object TEXT, PRIMARY KEY(desc));");
dbHandler
.execSQL("CREATE TABLE if not exists locks(date DATETIME DEFAULT CURRENT_TIMESTAMP, level INTEGER NOT NULL, user INTEGER NOT NULL, PRIMARY KEY(level,user));");
dbHandler
.execSQL("CREATE TABLE if not exists grids(date DATETIME DEFAULT CURRENT_TIMESTAMP, level INTEGER NOT NULL, user INTEGER NOT NULL, tag TEXT, object TEXT, PRIMARY KEY(level,user,date));");
dbHandler
.execSQL("CREATE TABLE if not exists transmuters(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, object TEXT, PRIMARY KEY(user));");
dbHandler
.execSQL("CREATE TABLE if not exists research(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, value INT, PRIMARY KEY(user));");
} else
dbHandler
.execSQL("CREATE TABLE if not exists worlds(date DATETIME DEFAULT CURRENT_TIMESTAMP, desc TEXT NOT NULL, object TEXT, PRIMARY KEY(desc));");
} catch (SQLiteGdxException e) {
e.printStackTrace();
}
@ -125,7 +117,9 @@ public class LocalBase extends Base {
public Array<Level> getworld(String description) {
DatabaseCursor cursor = null;
try {
cursor = dbHandler.rawQuery("select object from worlds where desc='"+description+"';");
cursor = dbHandler
.rawQuery("select object from worlds where desc='"
+ description + "';");
} catch (SQLiteGdxException e) {
return null;
}
@ -138,8 +132,7 @@ public class LocalBase extends Base {
mc = (Level[]) ins.readObject();
ins.close();
return new Array<Level>(mc);
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
@ -147,7 +140,8 @@ public class LocalBase extends Base {
public boolean deleteworld(String description) {
try {
dbHandler.rawQuery("delete from worlds where desc='"+description+"';");
dbHandler.rawQuery("delete from worlds where desc='" + description
+ "';");
} catch (SQLiteGdxException e) {
return false;
}
@ -165,7 +159,8 @@ public class LocalBase extends Base {
bos.close();
byte[] bytes = bos.toByteArray();
encoded = Base64Coder.encodeLines(bytes);
dbHandler.rawQuery("replace into worlds (desc,object) values ('"+description+"','"+encoded+"');");
dbHandler.rawQuery("replace into worlds (desc,object) values ('"
+ description + "','" + encoded + "');");
} catch (Exception e) {
return false;
}
@ -177,18 +172,21 @@ public class LocalBase extends Base {
public boolean getlevellock(int user, int level) {
DatabaseCursor cursor = null;
try {
cursor=dbHandler.rawQuery("select user from locks where user="+user+" and level="+level+";");
cursor = dbHandler.rawQuery("select user from locks where user="
+ user + " and level=" + level + ";");
} catch (SQLiteGdxException e) {
return false;
}
if (cursor.next())
return true;
else return false;
else
return false;
}
public boolean setlevelunlock(int user, int level) {
try {
dbHandler.rawQuery("insert into locks (user,level) values ("+user+","+level+");");
dbHandler.rawQuery("insert into locks (user,level) values (" + user
+ "," + level + ");");
} catch (SQLiteGdxException e) {
return false;
}
@ -198,21 +196,23 @@ public class LocalBase extends Base {
public Array<Transmuter> getTransmuters(int user) {
DatabaseCursor cursor = null;
try {
cursor = dbHandler.rawQuery("select object from transmuters where user="+user+";");
cursor = dbHandler
.rawQuery("select object from transmuters where user="
+ user + ";");
} catch (SQLiteGdxException e) {
return null;
}
Transmuter[] mc = null;
if (cursor.next())
try {
byte[] bytes = DatatypeConverter.parseBase64Binary(cursor.getString(0));
byte[] bytes = Base64Coder.decodeLines(cursor
.getString(0));
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ins = new ObjectInputStream(bais);
mc = (Transmuter[]) ins.readObject();
ins.close();
return new Array<Transmuter>(mc);
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
@ -228,19 +228,22 @@ public class LocalBase extends Base {
oos.close();
bos.close();
byte[] bytes = bos.toByteArray();
encoded = DatatypeConverter.printBase64Binary(bytes);
dbHandler.rawQuery("replace into transmuters (user,object) values ("+user+",'"+encoded+"');");
encoded = Base64Coder.encodeLines(bytes);
dbHandler
.rawQuery("replace into transmuters (user,object) values ("
+ user + ",'" + encoded + "');");
} catch (Exception e) {
return false;
}
return true;
}
public int getResearchpoint(int user) {
DatabaseCursor cursor = null;
try {
cursor = dbHandler.rawQuery("select value from research where user="+user+";");
cursor = dbHandler
.rawQuery("select value from research where user=" + user
+ ";");
} catch (SQLiteGdxException e) {
return 0;
}
@ -252,7 +255,8 @@ public class LocalBase extends Base {
public boolean setResearchpoint(int user, int point) {
try {
dbHandler.rawQuery("replace into research (user,value) values ("+user+","+point+");");
dbHandler.rawQuery("replace into research (user,value) values ("
+ user + "," + point + ");");
} catch (Exception e) {
return false;
}
@ -262,21 +266,24 @@ public class LocalBase extends Base {
public Grid getGrid(int user, int level, int place) {
DatabaseCursor cursor = null;
try {
cursor = dbHandler.rawQuery("select object from grids where user="+user+" and level="+level+" and tag is null order by date desc limit "+place+",1;");
cursor = dbHandler.rawQuery("select object from grids where user="
+ user + " and level=" + level
+ " and tag is null order by date desc limit " + place
+ ",1;");
} catch (SQLiteGdxException e) {
return null;
}
Grid mc = null;
if (cursor.next())
try {
byte[] bytes = DatatypeConverter.parseBase64Binary(cursor.getString(0));
byte[] bytes = Base64Coder.decodeLines(cursor
.getString(0));
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ins = new ObjectInputStream(bais);
mc = (Grid) ins.readObject();
ins.close();
return mc;
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
@ -285,21 +292,23 @@ public class LocalBase extends Base {
public Grid getGrid(int user, int level, String tag) {
DatabaseCursor cursor = null;
try {
cursor = dbHandler.rawQuery("select object from grids where user="+user+" and level="+level+" and tag='"+tag+"' order by date desc limit 1;");
cursor = dbHandler.rawQuery("select object from grids where user="
+ user + " and level=" + level + " and tag='" + tag
+ "' order by date desc limit 1;");
} catch (SQLiteGdxException e) {
return null;
}
Grid mc = null;
if (cursor.next())
try {
byte[] bytes = DatatypeConverter.parseBase64Binary(cursor.getString(0));
byte[] bytes = Base64Coder.decodeLines(cursor
.getString(0));
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ins = new ObjectInputStream(bais);
mc = (Grid) ins.readObject();
ins.close();
return mc;
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
@ -315,8 +324,9 @@ public class LocalBase extends Base {
oos.close();
bos.close();
byte[] bytes = bos.toByteArray();
encoded = DatatypeConverter.printBase64Binary(bytes);
dbHandler.rawQuery("insert into grids (user,level,object) values ("+user+","+level+",'"+encoded+"');");
encoded = Base64Coder.encodeLines(bytes);
dbHandler.rawQuery("insert into grids (user,level,object) values ("
+ user + "," + level + ",'" + encoded + "');");
} catch (Exception e) {
return false;
}
@ -333,14 +343,24 @@ public class LocalBase extends Base {
oos.close();
bos.close();
byte[] bytes = bos.toByteArray();
encoded = DatatypeConverter.printBase64Binary(bytes);
encoded = Base64Coder.encodeLines(bytes);
try {
dbHandler.rawQuery("delete from grids where user="+user+" and level="+level+" and tag='"+tag+"';");
} catch (Exception e) {}
dbHandler.rawQuery("insert into grids (user,level,tag,object) values ("+user+","+level+",'"+tag+"','"+encoded+"');");
return true;
dbHandler.rawQuery("delete from grids where user=" + user
+ " and level=" + level + " and tag='" + tag + "';");
} catch (Exception e) {
}
catch (Exception e) {
dbHandler
.rawQuery("insert into grids (user,level,tag,object) values ("
+ user
+ ","
+ level
+ ",'"
+ tag
+ "','"
+ encoded
+ "');");
return true;
} catch (Exception e) {
return false;
}
}
@ -348,7 +368,9 @@ public class LocalBase extends Base {
public Array<String> getGrids(int user, int level) {
DatabaseCursor cursor = null;
try {
cursor = dbHandler.rawQuery("select date from grids where level="+level+" and user="+user+" and tag is null order by date desc;");
cursor = dbHandler.rawQuery("select date from grids where level="
+ level + " and user=" + user
+ " and tag is null order by date desc;");
} catch (SQLiteGdxException e) {
return null;
}
@ -360,7 +382,6 @@ public class LocalBase extends Base {
// Gestion type Stat
// Commun
public boolean Eraseall(datatype base) {

View File

@ -1,11 +1,5 @@
package fr.evolving.database;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.sql.DatabaseFactory;
import com.badlogic.gdx.sql.SQLiteGdxException;
import fr.evolving.database.Base.datatype;
public class SqlBase extends Base {
public SqlBase(datatype model, String param) {

View File

@ -3,16 +3,10 @@ package fr.evolving.effects;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import fr.evolving.assets.AssetLoader;
@ -24,12 +18,15 @@ public class Laser {
public Laser() {
i = 0;
overlaymiddle=AssetLoader.Skin_level.getAtlas().findRegion("overlay-middle");
overlaymiddle = AssetLoader.Skin_level.getAtlas().findRegion(
"overlay-middle");
middle = AssetLoader.Skin_level.getAtlas().findRegion("middle");
overlay = AssetLoader.Skin_level.getAtlas().findRegion("overlay");
}
public void draw(Batch Laser,float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) {
public void draw(Batch Laser, float xx1, float yy1, float xx2, float yy2,
float maxwidth, float power, boolean active, Color colorsrc,
Color colordst) {
float x1 = xx1 + 26;
float y1 = yy1 + 20;
float x2 = xx2 + 26;
@ -43,16 +40,24 @@ public class Laser {
Laser.begin();
Laser.setColor(colorsrc);
Laser.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
Laser.draw(overlaymiddle,x1,y1,32,0,64,vectorall.len(),1f,1f,vectorall.angle()+270);
Laser.draw(middle,x1,y1,32,0,64,vectorall.len(),1f,1f,vectorall.angle()+270);
Laser.draw(overlaymiddle, x1, y1, 32, 0, 64, vectorall.len(), 1f, 1f,
vectorall.angle() + 270);
Laser.draw(middle, x1, y1, 32, 0, 64, vectorall.len(), 1f, 1f,
vectorall.angle() + 270);
Laser.setColor(new Color(1f, 1f, 1f, 1f));
for(int j=0;j<(vectorall.len()-vectoradd.cpy().setLength(i*inc).len())/64-1;j++)
Laser.draw(overlay,x1+i*vectoradd.x+j*vectoraddit.x,y1+i*vectoradd.y+j*vectoraddit.y,32,0,64,64,1f,1f,vectorall.angle()+270);
Laser.draw(overlay,x1,y1,32,0,64,i*inc,1f,1f,vectorall.angle()+270);
for (int j = 0; j < (vectorall.len() - vectoradd.cpy()
.setLength(i * inc).len()) / 64 - 1; j++)
Laser.draw(overlay, x1 + i * vectoradd.x + j * vectoraddit.x, y1
+ i * vectoradd.y + j * vectoraddit.y, 32, 0, 64, 64, 1f,
1f, vectorall.angle() + 270);
Laser.draw(overlay, x1, y1, 32, 0, 64, i * inc, 1f, 1f,
vectorall.angle() + 270);
Laser.end();
}
public void drawnotsoold(ShapeRenderer Laser,float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) {
public void drawnotsoold(ShapeRenderer Laser, float xx1, float yy1,
float xx2, float yy2, float maxwidth, float power, boolean active,
Color colorsrc, Color colordst) {
float x1 = xx1 + 58;
float y1 = yy1 + 20;
float x2 = xx2 + 58;
@ -65,21 +70,21 @@ public class Laser {
float size = 20;
Vector2 vectoradd = vectorall.scl(size / length);
float adding = 0;
for(float i = 2; i+2 < length/size; i += 1)
{
for (float i = 2; i + 2 < length / size; i += 1) {
float width = (float) (maxwidth - Math.random() * 2);
while(width >= 0)
{
while (width >= 0) {
adding = (width * power / maxwidth);
Color Acolor=colorsrc.cpy().lerp(colordst.cpy(), (i/(length/size)));
Color Acolor = colorsrc.cpy().lerp(colordst.cpy(),
(i / (length / size)));
Laser.setColor(Acolor.add(adding, adding, adding, 0.5f));
if (Math.random()>0.4) Laser.rectLine(x1 + i*vectoradd.x, y1 + i*vectoradd.y, x1+ (i+1)*vectoradd.x, y1+(i+1)* vectoradd.y, width);
if (Math.random() > 0.4)
Laser.rectLine(x1 + i * vectoradd.x, y1 + i
* vectoradd.y, x1 + (i + 1) * vectoradd.x, y1
+ (i + 1) * vectoradd.y, width);
width = width - 1;
}
}
}
else
{
} else {
Color Acolor = new Color(0.5f, 0.5f, 0.5f, 1f);
Laser.setColor(Acolor);
Laser.rectLine(x1, y1, x2, y2, 2);
@ -88,8 +93,9 @@ public class Laser {
Gdx.gl.glDisable(GL20.GL_BLEND);
}
public void drawold(ShapeRenderer Laser,float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) {
public void drawold(ShapeRenderer Laser, float xx1, float yy1, float xx2,
float yy2, float maxwidth, float power, boolean active,
Color colorsrc, Color colordst) {
float x1 = xx1 + 20;
float y1 = yy1 + 20;
float x2 = xx2 + 20;
@ -109,11 +115,14 @@ public class Laser {
vec2.clamp(length - i, length - i);
while (width >= 0) {
adding = (width * power / maxwidth);
Color Acolor=colordst.cpy().lerp(colorsrc.cpy(), (i/length));
Color Acolor = colordst.cpy()
.lerp(colorsrc.cpy(), (i / length));
Laser.setColor(Acolor.add(adding, adding, adding, 1f));
if (size > 0.4f) {
Laser.point(x1 + vec2.x-width/2, y1 + vec2.y+width/2, 0);
Laser.point(x1 + vec2.x+width/2, y1 + vec2.y-width/2, 0);
Laser.point(x1 + vec2.x - width / 2, y1 + vec2.y + width
/ 2, 0);
Laser.point(x1 + vec2.x + width / 2, y1 + vec2.y - width
/ 2, 0);
}
width = width - 1;
}
@ -121,5 +130,3 @@ public class Laser {
Laser.end();
}
}

View File

@ -3,36 +3,40 @@ package fr.evolving.game;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import fr.evolving.screens.GameScreen;
import fr.evolving.screens.SplashScreen;
import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.Preference;
import fr.evolving.screens.SplashScreen;
public class main extends Game {
@Override
public void create() {
Gdx.app.setLogLevel(Preference.init());
Gdx.app.debug(getClass().getSimpleName(), "Récupération de la résolution des préférences.");
if (Preference.prefs.getInteger("ResolutionX")>0 && Preference.prefs.getInteger("ResolutionY")>0) {
Preference.init();
Gdx.app.debug(getClass().getSimpleName(),
"Récupération de la résolution des préférences.");
if (Preference.prefs.getInteger("ResolutionX") > 0
&& Preference.prefs.getInteger("ResolutionY") > 0) {
try {
int ResolutionX = Preference.prefs.getInteger("ResolutionX");
int ResolutionY = Preference.prefs.getInteger("ResolutionY");
boolean Fullscreen = Preference.prefs.getBoolean("Fullscreen");
boolean VSync = Preference.prefs.getBoolean("VSync");
Gdx.graphics.setDisplayMode(ResolutionX, ResolutionY, Fullscreen);
Gdx.graphics.setDisplayMode(ResolutionX, ResolutionY,
Fullscreen);
Gdx.graphics.setVSync(VSync);
} catch (ClassCastException e) {
Gdx.app.error("****","Impossible d'appliquer les préférences graphiques");
Gdx.app.error("****",
"Impossible d'appliquer les préférences graphiques");
Gdx.app.debug(getClass().getSimpleName(), e.getMessage());
} finally {
Gdx.app.log("****","Changement de résolution selon préférences graphiques");
Gdx.app.log("****",
"Changement de résolution selon préférences graphiques");
}
}
else
} else
Gdx.app.debug(getClass().getSimpleName(), "...Aucune préférence !");
AssetLoader.init();
Gdx.app.debug(getClass().getSimpleName(), "Creation de l'objet SplashScreen.");
Gdx.app.debug(getClass().getSimpleName(),
"Creation de l'objet SplashScreen.");
setScreen(new SplashScreen(this));
}

View File

@ -1,12 +1,7 @@
package fr.evolving.renderers;
import java.util.List;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
@ -40,25 +35,32 @@ public class GameRenderer {
if (layer == 0) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
else if (layer==1) {
} else if (layer == 1) {
batcher.begin();
batcher.setColor(0.25f, 0.25f, 0.25f, 1f);
batcher.draw(AssetLoader.Atlas_level.findRegion("barrehaut"),0.0f,AssetLoader.height-198.0f,1920.0f,200.0f);
batcher.draw(AssetLoader.Atlas_level.findRegion("barrecentre"),1480f,AssetLoader.height-785.0f,590f,530.0f);
batcher.draw(AssetLoader.Atlas_level.findRegion("barrebas"),0.0f,0.0f,1920.0f,170.0f);
batcher.draw(AssetLoader.Atlas_level.findRegion("barrehaut"), 0.0f,
AssetLoader.height - 198.0f, 1920.0f, 200.0f);
batcher.draw(AssetLoader.Atlas_level.findRegion("barrecentre"),
1480f, AssetLoader.height - 785.0f, 590f, 530.0f);
batcher.draw(AssetLoader.Atlas_level.findRegion("barrebas"), 0.0f,
0.0f, 1920.0f, 170.0f);
if (GameScreen.unroll)
batcher.draw(AssetLoader.Atlas_level.findRegion("barrecentre2"),1180f,AssetLoader.height-1000.0f,880f,386.0f);
batcher.draw(
AssetLoader.Atlas_level.findRegion("barrecentre2"),
1180f, AssetLoader.height - 1000.0f, 880f, 386.0f);
batcher.end();
}
else if (layer==2) {
} else if (layer == 2) {
shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.end();
batcher.begin();
if (GameScreen.selected!=null)
{
if (GameScreen.selected != null) {
batcher.setColor(1f, 0f, 0f, 1f);
batcher.draw(oneselection, GameScreen.selected.getX(), GameScreen.selected.getY(), GameScreen.selected.getWidth()/2,GameScreen.selected.getHeight()/2,GameScreen.selected.getWidth(), GameScreen.selected.getHeight(),1f,1f,rotation);
batcher.draw(oneselection, GameScreen.selected.getX(),
GameScreen.selected.getY(),
GameScreen.selected.getWidth() / 2,
GameScreen.selected.getHeight() / 2,
GameScreen.selected.getWidth(),
GameScreen.selected.getHeight(), 1f, 1f, rotation);
}
batcher.end();
}

View File

@ -1,20 +1,14 @@
package fr.evolving.renderers;
import java.util.List;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import fr.evolving.UI.Objectives;
import fr.evolving.assets.AssetLoader;
import fr.evolving.effects.Laser;
import fr.evolving.screens.LevelScreen;
@ -73,21 +67,25 @@ public class LevelRenderer {
batcher.begin();
batcher.setProjectionMatrix(AssetLoader.Camera.combined);
batcher.setColor(0.25f, 0.25f, 0.25f, 1f);
batcher.draw(AssetLoader.Texture_fond2, 0, 0, this.scrollx/2, this.scrolly/2, AssetLoader.width, AssetLoader.height);
batcher.draw(AssetLoader.Texture_fond2, 0, 0, this.scrollx / 2,
this.scrolly / 2, AssetLoader.width, AssetLoader.height);
batcher.setColor(0.7f, 0.7f, 0.7f, 1);
batcher.draw(AssetLoader.Texture_fond, 0, 0, this.scrollx, this.scrolly, AssetLoader.width, AssetLoader.height);
batcher.draw(AssetLoader.Texture_fond, 0, 0, this.scrollx,
this.scrolly, AssetLoader.width, AssetLoader.height);
batcher.end();
batcher2.begin();
batcher2.setProjectionMatrix(AssetLoader.Camera.combined);
batcher2.setColor(Color.WHITE);
Texture_logobig = AssetLoader.Skin_level.getRegion("logo3");
batcher2.draw(Texture_logobig,120, AssetLoader.height-Texture_logobig.getRegionHeight());
batcher2.draw(Texture_logobig, 120, AssetLoader.height
- Texture_logobig.getRegionHeight());
if (LevelScreen.selected != null) {
font.draw(batcher2, LevelScreen.selected.level.Name, 15, 145);
if (LevelScreen.selected.level.Tech > 0)
font.draw(batcher2, "Recompenses", 1215, AssetLoader.height-15);
font.draw(batcher2, "Recompenses", 1215,
AssetLoader.height - 15);
if (LevelScreen.selected.level.Cout > 0) {
font.draw(batcher2, "Ressources", 1215, 145);
font.draw(batcher2, "Objectifs", 1215, 295);
@ -120,22 +118,50 @@ public class LevelRenderer {
if (LevelScreen.buttonLevels != null)
for (int i = 0; i < LevelScreen.buttonLevels.length; i++) {
if (LevelScreen.buttonLevels[i] != null) {
for (int[] item : LevelScreen.buttonLevels[i].level.Link)
{
for (int[] item : LevelScreen.buttonLevels[i].level.Link) {
int found = -1;
for (int j=0;j<LevelScreen.buttonLevels.length;j++)
{
if ((item.length==2) && (LevelScreen.buttonLevels[j]!=null) && (LevelScreen.buttonLevels[j].level.aWorld==item[0]) && (LevelScreen.buttonLevels[j].level.aLevel==item[1])) {
for (int j = 0; j < LevelScreen.buttonLevels.length; j++) {
if ((item.length == 2)
&& (LevelScreen.buttonLevels[j] != null)
&& (LevelScreen.buttonLevels[j].level.aWorld == item[0])
&& (LevelScreen.buttonLevels[j].level.aLevel == item[1])) {
found = j;
break;
}
}
if (found!=-1)
{
if (found != -1) {
if (!LevelScreen.logosmall.isChecked())
Laser.draw(batcher,LevelScreen.buttonLevels[i].level.X,LevelScreen.buttonLevels[i].level.Y*AssetLoader.ratio,LevelScreen.buttonLevels[found].level.X,LevelScreen.buttonLevels[found].level.Y*AssetLoader.ratio,10,0.5f,LevelScreen.buttonLevels[found].Activated,LevelScreen.buttonLevels[i].getLevelcolor(),LevelScreen.buttonLevels[found].getLevelcolor());
Laser.draw(
batcher,
LevelScreen.buttonLevels[i].level.X,
LevelScreen.buttonLevels[i].level.Y
* AssetLoader.ratio,
LevelScreen.buttonLevels[found].level.X,
LevelScreen.buttonLevels[found].level.Y
* AssetLoader.ratio,
10,
0.5f,
LevelScreen.buttonLevels[found].Activated,
LevelScreen.buttonLevels[i]
.getLevelcolor(),
LevelScreen.buttonLevels[found]
.getLevelcolor());
else
Laser.drawnotsoold(shapeRenderer,LevelScreen.buttonLevels[i].level.X,LevelScreen.buttonLevels[i].level.Y*AssetLoader.ratio,LevelScreen.buttonLevels[found].level.X,LevelScreen.buttonLevels[found].level.Y*AssetLoader.ratio,10,0.5f,LevelScreen.buttonLevels[found].Activated,LevelScreen.buttonLevels[i].getLevelcolor(),LevelScreen.buttonLevels[found].getLevelcolor());
Laser.drawnotsoold(
shapeRenderer,
LevelScreen.buttonLevels[i].level.X,
LevelScreen.buttonLevels[i].level.Y
* AssetLoader.ratio,
LevelScreen.buttonLevels[found].level.X,
LevelScreen.buttonLevels[found].level.Y
* AssetLoader.ratio,
10,
0.5f,
LevelScreen.buttonLevels[found].Activated,
LevelScreen.buttonLevels[i]
.getLevelcolor(),
LevelScreen.buttonLevels[found]
.getLevelcolor());
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,55 +1,35 @@
package fr.evolving.screens;
import java.util.Timer;
import java.util.TimerTask;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
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.ImageTextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.viewport.FillViewport;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.ScalingViewport;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import fr.evolving.renderers.LevelRenderer;
import fr.evolving.UI.ButtonLevel;
import fr.evolving.UI.Objectives;
import fr.evolving.UI.ServerList;
import fr.evolving.UI.WarnDialog;
import fr.evolving.UI.Worldlist;
import fr.evolving.game.main;
import java.util.Timer;
import java.util.TimerTask;
import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.InitWorlds;
import fr.evolving.assets.Preference;
import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
import fr.evolving.database.Base;
import fr.evolving.database.Base.datatype;
import fr.evolving.database.DatabaseManager;
import fr.evolving.database.LocalBase;
import fr.evolving.database.SqlBase;
import fr.evolving.effects.Laser;
import fr.evolving.renderers.LevelRenderer;
public class LevelScreen implements Screen {
public ButtonLevel[] buttonLevels;
@ -64,7 +44,8 @@ public class LevelScreen implements Screen {
public ImageButton logosmall;
public Image MenuSolo, MenuMulti, MenuScenario;
private ImageTextButton cout, tech, cycle, temp, rayon, nrj;
private TextButton buttonConnect,buttonPlay,buttonStat,buttonSave, buttonApply, buttonPlaythis;
private TextButton buttonConnect, buttonPlay, buttonStat, buttonSave,
buttonApply, buttonPlaythis;
private ServerList Statdata, Userdata, Gamedata;
private Worldlist Worlddata;
private Label Statdatalabel, Userdatalabel, Gamedatalabel, Worlddatalabel;
@ -74,7 +55,6 @@ public class LevelScreen implements Screen {
private Objectives Victory;
public ButtonLevel selected;
public int getMaxWorld() {
int max = 0;
for (Level level : thelevels)
@ -85,23 +65,27 @@ public class LevelScreen implements Screen {
public void play() {
if (!AssetLoader.Datahandler.verifyall())
Gdx.app.debug(getClass().getSimpleName(),"Pilotes de bases de donnée défaillant.");
else
{
Gdx.app.debug(getClass().getSimpleName(),"Chargement des mondes depuis la base.");
Gdx.app.debug(getClass().getSimpleName(),
"Pilotes de bases de donnée défaillant.");
else {
Gdx.app.debug(getClass().getSimpleName(),
"Chargement des mondes depuis la base.");
try {
if (world < 0)
world = 0;
thelevels=AssetLoader.Datahandler.game().getworld(Preference.prefs.getString("world"));
/*thelevels= InitWorlds.go();
AssetLoader.Datahandler.game().setworld(thelevels,Preference.prefs.getString("world")); */
thelevels = AssetLoader.Datahandler.game().getworld(
Preference.prefs.getString("world"));
/*
* thelevels= InitWorlds.go();
* AssetLoader.Datahandler.game().setworld
* (thelevels,Preference.prefs.getString("world"));
*/
loadWorld(world);
Previous.setVisible(true);
Next.setVisible(true);
buttonPlay.setVisible(true);
TextDescriptive.setVisible(true);
}
catch (Exception e) {
} catch (Exception e) {
Previous.setVisible(false);
Next.setVisible(false);
buttonPlay.setVisible(false);
@ -153,9 +137,15 @@ public class LevelScreen implements Screen {
MenuScenario.setScale(1f);
MenuScenario.setColor(1f, 1f, 1f, 1f);
MenuScenario.setPosition(0, AssetLoader.height * 7 / 20 - 300);
MenuSolo.addAction(Actions.sequence(Actions.moveTo((AssetLoader.width-MenuSolo.getWidth())/2, AssetLoader.height*17/20-300, 0.25f)));
MenuMulti.addAction(Actions.sequence(Actions.fadeIn(0.1f),Actions.moveTo((AssetLoader.width-MenuMulti.getWidth())/2, AssetLoader.height*12/20-300, 0.25f)));
MenuScenario.addAction(Actions.sequence(Actions.fadeIn(0.2f),Actions.moveTo((AssetLoader.width-MenuScenario.getWidth())/2, AssetLoader.height*7/20-300, 0.25f)));
MenuSolo.addAction(Actions.sequence(Actions.moveTo(
(AssetLoader.width - MenuSolo.getWidth()) / 2,
AssetLoader.height * 17 / 20 - 300, 0.25f)));
MenuMulti.addAction(Actions.sequence(Actions.fadeIn(0.1f), Actions
.moveTo((AssetLoader.width - MenuMulti.getWidth()) / 2,
AssetLoader.height * 12 / 20 - 300, 0.25f)));
MenuScenario.addAction(Actions.sequence(Actions.fadeIn(0.2f), Actions
.moveTo((AssetLoader.width - MenuScenario.getWidth()) / 2,
AssetLoader.height * 7 / 20 - 300, 0.25f)));
}
@ -238,26 +228,39 @@ public class LevelScreen implements Screen {
buttonLevels = new ButtonLevel[10];
for (Level level : thelevels) {
if (level != null && level.aWorld == aworld) {
buttonLevels[i]=new ButtonLevel(level,true,AssetLoader.ratio);
Gdx.app.debug(getClass().getSimpleName(),"Ajout du niveau :"+level.Name+""+String.valueOf(level.aLevel));
buttonLevels[i] = new ButtonLevel(level, true,
AssetLoader.ratio);
Gdx.app.debug(getClass().getSimpleName(), "Ajout du niveau :"
+ level.Name + "" + String.valueOf(level.aLevel));
buttonLevels[i++].addListener(new ClickListener() {
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ButtonLevel abutton = (ButtonLevel)event.getListenerActor();
Gdx.app.debug(event.getListenerActor().toString(), "Enter button ");
public void enter(InputEvent event, float x, float y,
int pointer, Actor fromActor) {
ButtonLevel abutton = (ButtonLevel) event
.getListenerActor();
Gdx.app.debug(event.getListenerActor().toString(),
"Enter button ");
if (!abutton.isChecked())
showlevel(abutton);
}
public void exit(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ButtonLevel abutton = (ButtonLevel)event.getListenerActor();
Gdx.app.debug(event.getListenerActor().toString(), "Enter button ");
public void exit(InputEvent event, float x, float y,
int pointer, Actor fromActor) {
ButtonLevel abutton = (ButtonLevel) event
.getListenerActor();
Gdx.app.debug(event.getListenerActor().toString(),
"Enter button ");
if (!abutton.isChecked())
showlevel(abutton);
}
public void touchDragged(InputEvent event,float x,float y,int pointer) {
ButtonLevel abutton = (ButtonLevel)event.getListenerActor();
public void touchDragged(InputEvent event, float x,
float y, int pointer) {
ButtonLevel abutton = (ButtonLevel) event
.getListenerActor();
if (logosmall.isChecked()) {
abutton.setPosition(event.getStageX()-56, event.getStageY()-20);
abutton.setPosition(event.getStageX() - 56,
event.getStageY() - 20);
}
}
});
@ -276,18 +279,17 @@ public class LevelScreen implements Screen {
public LevelScreen(int aworld) {
this.world = aworld;
Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table)");
Gdx.app.debug(getClass().getSimpleName(),
"Création des elements primordiaux du screen (stage, renderer, table)");
stage = new Stage(AssetLoader.viewport);
table = new Table();
Renderer = new LevelRenderer(this);
dialog = new WarnDialog(AssetLoader.Skin_ui);
Gdx.app.debug(getClass().getSimpleName(), "Mise en place du timer.");
ScrollTimer = new Timer();
ScrollTask = new TimerTask()
{
ScrollTask = new TimerTask() {
@Override
public void run()
{
public void run() {
Renderer.evolve();
}
};
@ -299,60 +301,74 @@ public class LevelScreen implements Screen {
public void clicked(InputEvent event, float x, float y) {
MenuMulti.addAction(Actions.fadeOut(0.5f));
MenuScenario.addAction(Actions.fadeOut(0.5f));
MenuSolo.addAction(Actions.sequence(Actions.parallel(Actions.rotateBy(640, 0.5f),Actions.scaleTo(0.05f, 0.05f, 0.5f)),Actions.run(new Runnable() {
MenuSolo.addAction(Actions.sequence(
Actions.parallel(Actions.rotateBy(640, 0.5f),
Actions.scaleTo(0.05f, 0.05f, 0.5f)),
Actions.run(new Runnable() {
public void run() {
level();
}
})));
}
});
MenuMulti = new Image(AssetLoader.Skin_level, "menu2");
MenuMulti.setOrigin(MenuMulti.getWidth()/2, MenuMulti.getHeight()/2);
MenuMulti
.setOrigin(MenuMulti.getWidth() / 2, MenuMulti.getHeight() / 2);
MenuMulti.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
MenuSolo.addAction(Actions.fadeOut(0.5f));
MenuScenario.addAction(Actions.fadeOut(0.5f));
MenuMulti.addAction(Actions.sequence(Actions.parallel(Actions.rotateBy(640, 0.5f),Actions.scaleTo(0.05f, 0.05f, 0.5f)),Actions.run(new Runnable() {
MenuMulti.addAction(Actions.sequence(
Actions.parallel(Actions.rotateBy(640, 0.5f),
Actions.scaleTo(0.05f, 0.05f, 0.5f)),
Actions.run(new Runnable() {
public void run() {
level();
}
})));
}
});
MenuScenario = new Image(AssetLoader.Skin_level, "menu3");
MenuScenario.setOrigin(MenuScenario.getWidth()/2, MenuScenario.getHeight()/2);
MenuScenario.setOrigin(MenuScenario.getWidth() / 2,
MenuScenario.getHeight() / 2);
MenuScenario.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
MenuMulti.addAction(Actions.fadeOut(0.5f));
MenuSolo.addAction(Actions.fadeOut(0.5f));
MenuScenario.addAction(Actions.sequence(Actions.parallel(Actions.rotateBy(640, 0.5f),Actions.scaleTo(0.05f, 0.05f, 0.5f)),Actions.run(new Runnable() {
MenuScenario.addAction(Actions.sequence(
Actions.parallel(Actions.rotateBy(640, 0.5f),
Actions.scaleTo(0.05f, 0.05f, 0.5f)),
Actions.run(new Runnable() {
public void run() {
level();
}
})));
}
});
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);
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,"Descriptif");
logosmall.setPosition(20,
AssetLoader.height - 175 + logosmall.getHeight() / 2);
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,
"Descriptif");
TextDescriptive.setBounds(15, 15, 1185, 100);
buttonApply = new TextButton("Appliquer", AssetLoader.Skin_ui);
buttonApply.setBounds(1680, 350, 190, 40);
buttonApply.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
AssetLoader.Datahandler.CloseAll();
AssetLoader.Datahandler.Attach(Userdata.getModel(),Userdata.getUrl());
AssetLoader.Datahandler.Attach(Statdata.getModel(),Statdata.getUrl());
AssetLoader.Datahandler.Attach(Gamedata.getModel(),Gamedata.getUrl());
AssetLoader.Datahandler.Attach(Userdata.getModel(),
Userdata.getUrl());
AssetLoader.Datahandler.Attach(Statdata.getModel(),
Statdata.getUrl());
AssetLoader.Datahandler.Attach(Gamedata.getModel(),
Gamedata.getUrl());
if (!AssetLoader.Datahandler.verifyall()) {
dialog.Show("Un problème est survenu lors du changement de base de donnée.",stage);
dialog.Show(
"Un problème est survenu lors du changement de base de donnée.",
stage);
initlevel();
}
else
} else
menu();
if (AssetLoader.Datahandler.stat() == null)
Statdata.setColor(1f, 0, 0, 1f);
@ -377,7 +393,9 @@ public class LevelScreen implements Screen {
Preference.prefs.putString("userdata", Userdata.getUrl());
Preference.prefs.putString("gamedata", Gamedata.getUrl());
Preference.prefs.putString("statdata", Statdata.getUrl());
dialog.Show("Vous devez redemarrer pour bénéfier des changements.",stage);
dialog.Show(
"Vous devez redemarrer pour bénéfier des changements.",
stage);
}
});
buttonConnect = new TextButton("Connexions", AssetLoader.Skin_ui);
@ -393,7 +411,8 @@ public class LevelScreen implements Screen {
buttonPlay.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
((Game)Gdx.app.getApplicationListener()).setScreen(new GameScreen(selected.level));
((Game) Gdx.app.getApplicationListener())
.setScreen(new GameScreen(selected.level));
}
});
buttonStat = new TextButton("Statistiques", AssetLoader.Skin_ui);
@ -409,14 +428,15 @@ public class LevelScreen implements Screen {
buttonPlaythis.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
if (!AssetLoader.Datahandler.verifyall())
dialog.Show("Impossible de jouer sans bases de données correctement configurée, cliquer sur RAZ si vous ne savez pas revenir à une situation jouable.", stage);
else
{
dialog.Show(
"Impossible de jouer sans bases de données correctement configurée, cliquer sur RAZ si vous ne savez pas revenir à une situation jouable.",
stage);
else {
if (Worlddata.getSelected() == null)
dialog.Show("Aucun monde n'a été sélectionné", stage);
else
{
Preference.prefs.putString("world", (String)Worlddata.getSelected());
else {
Preference.prefs.putString("world",
(String) Worlddata.getSelected());
Preference.prefs.flush();
play();
}
@ -443,7 +463,9 @@ public class LevelScreen implements Screen {
world++;
loadWorld(world);
}
Gdx.app.debug(event.getListenerActor().toString(),"World:"+String.valueOf(world)+" Maxworld:"+String.valueOf(getMaxWorld()));
Gdx.app.debug(event.getListenerActor().toString(),
"World:" + String.valueOf(world) + " Maxworld:"
+ String.valueOf(getMaxWorld()));
}
});
Previous = new ImageButton(AssetLoader.Skin_level, "Previous");
@ -455,7 +477,9 @@ public class LevelScreen implements Screen {
world--;
loadWorld(world);
}
Gdx.app.debug(event.getListenerActor().toString(),"World:"+String.valueOf(world)+" Maxworld:"+String.valueOf(getMaxWorld()));
Gdx.app.debug(event.getListenerActor().toString(),
"World:" + String.valueOf(world) + " Maxworld:"
+ String.valueOf(getMaxWorld()));
}
});
cout = new ImageTextButton("5", AssetLoader.Skin_level, "cout");
@ -475,20 +499,27 @@ public class LevelScreen implements Screen {
Victory.setVictory(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
Victory.setPosition(1216, 185);
String url = "http://evolving.fr/servers/list.xml";
Statdata=new ServerList(url,Base.datatype.statdata,AssetLoader.Skin_ui);
Statdatalabel=new Label("Stockage des statistiques:", AssetLoader.Skin_ui, "grey");
Statdata = new ServerList(url, Base.datatype.statdata,
AssetLoader.Skin_ui);
Statdatalabel = new Label("Stockage des statistiques:",
AssetLoader.Skin_ui, "grey");
Statdata.setBounds(1480, AssetLoader.height - 250, 420, 150);
Statdatalabel.setPosition(1480, AssetLoader.height - 100);
Userdata=new ServerList(url,Base.datatype.userdata,AssetLoader.Skin_ui);
Userdatalabel=new Label("Stockage des données du joueur:", AssetLoader.Skin_ui, "grey");
Userdata = new ServerList(url, Base.datatype.userdata,
AssetLoader.Skin_ui);
Userdatalabel = new Label("Stockage des données du joueur:",
AssetLoader.Skin_ui, "grey");
Userdata.setBounds(1480, AssetLoader.height - 450, 420, 150);
Userdatalabel.setPosition(1480, AssetLoader.height - 300);
Gamedata=new ServerList(url,Base.datatype.gamedata,AssetLoader.Skin_ui);
Gamedatalabel=new Label("Stockage des données du jeu:", AssetLoader.Skin_ui, "grey");
Gamedata = new ServerList(url, Base.datatype.gamedata,
AssetLoader.Skin_ui);
Gamedatalabel = new Label("Stockage des données du jeu:",
AssetLoader.Skin_ui, "grey");
Gamedata.setBounds(1480, AssetLoader.height - 650, 420, 150);
Gamedatalabel.setPosition(1480, AssetLoader.height - 500);
Worlddata = new Worldlist(AssetLoader.Skin_ui);
Worlddatalabel=new Label("Mondes disponibles:", AssetLoader.Skin_ui, "grey");
Worlddatalabel = new Label("Mondes disponibles:", AssetLoader.Skin_ui,
"grey");
Worlddata.setBounds(1480, 100, 420, 200);
Worlddatalabel.setPosition(1480, 300);
Gamedata.setWorldlist(Worlddata);
@ -572,49 +603,41 @@ public class LevelScreen implements Screen {
}
public void showlevel(ButtonLevel button) {
Gdx.app.debug(getClass().getSimpleName(), "Reading button "+button.level.Name);
Gdx.app.debug(getClass().getSimpleName(), "Reading button "
+ button.level.Name);
TextDescriptive.setText(button.level.Description);
if (button.level.Maxcycle < 99999 && button.level.Maxcycle > 0) {
cycle.setText(String.valueOf(button.level.Maxcycle));
cycle.setVisible(true);
}
else
} else
cycle.setVisible(false);
if (button.level.Maxtemp < 99999 && button.level.Maxtemp > 0) {
temp.setText(String.valueOf(button.level.Maxtemp));
temp.setVisible(true);
}
else
} else
temp.setVisible(false);
if (button.level.Maxnrj < 99999 && button.level.Maxnrj > 0) {
nrj.setText(String.valueOf(button.level.Maxnrj));
nrj.setVisible(true);
}
else
} else
nrj.setVisible(false);
if (button.level.Maxrayon < 99999 && button.level.Maxrayon > 0) {
rayon.setText(String.valueOf(button.level.Maxrayon));
rayon.setVisible(true);
}
else
} else
rayon.setVisible(false);
if (button.level.Cout > 0) {
cout.setText(String.valueOf(button.level.Cout));
cout.setVisible(true);
}
else
} else
cout.setVisible(false);
if (button.level.Tech >= 1) {
tech.setText(String.valueOf(button.level.Tech));
tech.setVisible(true);
}
else
} else
tech.setVisible(false);
Victory.setVisible(button.level.Cout > 0);
Victory.setVictory(button.level.Victory);
//for (int i = 0;i<thelevels.length;i++) {
// if (thelevels[i] != null && buttonLevels[i]!=button)
// buttonLevels[i].setChecked(false);
if (selected != null)
selected.setChecked(false);
selected = button;

View File

@ -1,12 +1,10 @@
package fr.evolving.screens;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
@ -36,9 +34,13 @@ public class SplashScreen implements Screen {
Gdx.app.log("****", "Affichage du SplashScreen");
scale = 2;
splashImage.setScale(scale);
splashImage.setPosition((AssetLoader.width / 2) - (scale * splashImage.getWidth() / 2), (AssetLoader.height / 2) - (scale * splashImage.getHeight() / 2));
splashImage.setPosition(
(AssetLoader.width / 2) - (scale * splashImage.getWidth() / 2),
(AssetLoader.height / 2)
- (scale * splashImage.getHeight() / 2));
stage.addActor(splashImage);
splashImage.addAction(Actions.sequence(Actions.alpha(0),Actions.fadeIn(3f),Actions.run(new Runnable() {
splashImage.addAction(Actions.sequence(Actions.alpha(0),
Actions.fadeIn(3f), Actions.run(new Runnable() {
@Override
public void run() {
AssetLoader.finishall();
@ -46,7 +48,8 @@ public class SplashScreen implements Screen {
}), Actions.run(new Runnable() {
@Override
public void run() {
((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen(-1));
((Game) Gdx.app.getApplicationListener())
.setScreen(new LevelScreen(-1));
}
})));
}
@ -60,8 +63,10 @@ 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();
}