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; package fr.evolving.UI;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; 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.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.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle; import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import fr.evolving.assets.AssetLoader; import fr.evolving.assets.AssetLoader;
@ -19,47 +14,52 @@ import fr.evolving.automata.Level;
public class ButtonLevel extends ImageTextButton { public class ButtonLevel extends ImageTextButton {
public Level level; public Level level;
public boolean Activated; public boolean Activated;
TextureRegion Finalled,Locked; TextureRegion Finalled, Locked;
Label Thelabel; Label Thelabel;
float scale; float scale;
float ratio; float ratio;
ImageTextButtonStyle style; ImageTextButtonStyle style;
LabelStyle stylelabel; LabelStyle stylelabel;
public ButtonLevel(Level level, boolean Activated,float ratio) { 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"
this.level=level; + String.valueOf(level.aWorld));
this.ratio=ratio; this.level = level;
this.Activated=Activated; this.ratio = ratio;
if (level.Special==true) { this.Activated = Activated;
Finalled=AssetLoader.Skin_level.getAtlas().findRegion("boss"); if (level.Special == true) {
Finalled = AssetLoader.Skin_level.getAtlas().findRegion("boss");
} }
if (Activated==false) { if (Activated == false) {
this.setDisabled(true); this.setDisabled(true);
Locked=AssetLoader.Skin_level.getAtlas().findRegion("locked"); 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,
this.scale=1f; 0.607f + (float) level.X / 768f * 0.392f, 1f);
this.setBounds(level.X, level.Y*ratio, 111*scale, 125*scale); this.scale = 1f;
Thelabel=new Label(level.Element, AssetLoader.Skin_level,"Levelshort"); this.setBounds(level.X, level.Y * ratio, 111 * scale, 125 * scale);
Thelabel.setColor(level.X/1024f,level.X/1024f,level.X/1024f,1f); Thelabel = new Label(level.Element, AssetLoader.Skin_level,
Thelabel.setPosition(level.X+54*scale, level.Y*ratio+20*scale, Align.bottom | Align.center); "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);
} }
@Override @Override
public void setScale(float scale) { public void setScale(float scale) {
this.scale=scale; this.scale = scale;
this.setBounds(level.X, level.Y*ratio, 111*scale, 125*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,
stylelabel=Thelabel.getStyle(); level.Y * ratio + 20 * scale, Align.bottom | Align.center);
//stylelabel.font.setScale(scale); stylelabel = Thelabel.getStyle();
// stylelabel.font.setScale(scale);
Thelabel.setStyle(stylelabel); Thelabel.setStyle(stylelabel);
style= this.getStyle(); style = this.getStyle();
style.pressedOffsetX=style.pressedOffsetX*scale; style.pressedOffsetX = style.pressedOffsetX * scale;
style.pressedOffsetY=style.pressedOffsetY*scale; style.pressedOffsetY = style.pressedOffsetY * scale;
style.unpressedOffsetX=style.unpressedOffsetX*scale; style.unpressedOffsetX = style.unpressedOffsetX * scale;
style.unpressedOffsetY=style.unpressedOffsetY*scale; style.unpressedOffsetY = style.unpressedOffsetY * scale;
//style.font.setScale(scale); // style.font.setScale(scale);
this.setStyle(this.style); this.setStyle(this.style);
} }
@ -69,22 +69,31 @@ public class ButtonLevel extends ImageTextButton {
@Override @Override
public void setPosition(float x, float y) { public void setPosition(float x, float y) {
super.setPosition(x,y); super.setPosition(x, y);
level.X=x; level.X = x;
level.Y=y; level.Y = y;
Thelabel.setColor(level.X/1024f,level.X/1024f,level.X/1024f,1f); 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,
this.setColor(1f, 0.47f+(float)level.X/1024f*0.529f,0.607f+(float)level.X/768f*0.392f, 1f); 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 @Override
public void draw(Batch batch, float parentAlpha) { public void draw(Batch batch, float parentAlpha) {
super.draw(batch, parentAlpha); super.draw(batch, parentAlpha);
if (level.Special) { 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) { 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); Thelabel.draw(batch, 1f);
} }

View File

@ -1,6 +1,5 @@
package fr.evolving.UI; package fr.evolving.UI;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
@ -19,12 +18,9 @@ import com.badlogic.gdx.utils.ObjectMap.Entry;
import com.badlogic.gdx.utils.OrderedMap; import com.badlogic.gdx.utils.OrderedMap;
import fr.evolving.assets.AssetLoader; import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter; import fr.evolving.automata.Transmuter;
import fr.evolving.automata.Transmuter.Angular;
import fr.evolving.automata.Transmuter.CaseType;
public class Menu extends Actor{ public class Menu extends Actor {
private TiledMap map; private TiledMap map;
private OrthogonalTiledMapRenderer MapRenderer; private OrthogonalTiledMapRenderer MapRenderer;
@ -33,144 +29,151 @@ public class Menu extends Actor{
private int tilesizey; private int tilesizey;
private float decx; private float decx;
private float decy; private float decy;
private int size=32; private int size = 32;
public Menu(int tilesizex, int tilesizey) {
public Menu(int tilesizex,int tilesizey) { this.tilesizex = tilesizex;
this.tilesizex=tilesizex; this.tilesizey = tilesizey;
this.tilesizey=tilesizey; map = new TiledMap();
map=new TiledMap(); map.getTileSets().addTileSet(AssetLoader.tileSet);
map.getTileSets().addTileSet(AssetLoader.tileSet); MapLayers layers = map.getLayers();
MapLayers layers = map.getLayers(); for (int i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) { TiledMapTileLayer layer = new TiledMapTileLayer(tilesizex,
TiledMapTileLayer layer = new TiledMapTileLayer(tilesizex, tilesizey, 128, 128); tilesizey, 128, 128);
for (int x = 0; x < layer.getWidth(); x++) { for (int x = 0; x < layer.getWidth(); x++) {
for (int y = 0; y < layer.getHeight(); y++) { for (int y = 0; y < layer.getHeight(); y++) {
Cell cell = new Cell(); Cell cell = new Cell();
if (i==0) if (i == 0)
cell.setTile(AssetLoader.tileSet.getTile(54)); cell.setTile(AssetLoader.tileSet.getTile(54));
layer.setCell(x, y, cell); layer.setCell(x, y, cell);
} }
} }
layers.add(layer); layers.add(layer);
} }
map.getLayers().get(1).setOpacity(0.5f); map.getLayers().get(1).setOpacity(0.5f);
MapRenderer = new OrthogonalTiledMapRenderer(map,1/(float)size); MapRenderer = new OrthogonalTiledMapRenderer(map, 1 / (float) size);
camera = new OrthographicCamera(); camera = new OrthographicCamera();
camera.setToOrtho(false, tilesizex*32,tilesizex*32*AssetLoader.height/AssetLoader.width); camera.setToOrtho(false, tilesizex * 32, tilesizex * 32
Gdx.app.debug(getClass().getSimpleName(),"Caméra pour tilemap:"+(tilesizex*size)+"x"+(tilesizey*size)); * AssetLoader.height / AssetLoader.width);
decx=-102f; Gdx.app.debug(getClass().getSimpleName(), "Caméra pour tilemap:"
decy=-20f; + (tilesizex * size) + "x" + (tilesizey * size));
if (AssetLoader.ratio==1.44f) decx = -102f;
decy-=24; decy = -20f;
camera.translate(decx,decy); if (AssetLoader.ratio == 1.44f)
Gdx.app.debug(getClass().getSimpleName(),"Décalage:"+decx+"x"+decy); decy -= 24;
} camera.translate(decx, decy);
Gdx.app.debug(getClass().getSimpleName(), "Décalage:" + decx + "x"
public void clear() + decy);
{
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)
{
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);
} }
}
public void setMenuTransmuterSurtile(int x,int y,Transmuter transmuter) public void clear() {
{ TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
if (transmuter!=null) { for (int x = 0; x < layer.getWidth(); x++)
Cell cell=((TiledMapTileLayer)map.getLayers().get(1)).getCell(x,y); for (int y = 0; y < layer.getHeight(); y++)
OrderedMap<Vector2, Integer> tiles=transmuter.getTilesidrotated(); layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(54));
Entries<Vector2, Integer> iterator=tiles.iterator(); }
while(iterator.hasNext()){
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);
}
}
public void setMenuTransmuterSurtile(int x, int y, Transmuter transmuter) {
if (transmuter != null) {
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(); Entry<Vector2, Integer> all = iterator.next();
Cell subcell=((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)(x+all.key.x),(int)(y+all.key.y)); Cell subcell = ((TiledMapTileLayer) map.getLayers().get(1))
subcell.setTile(AssetLoader.tileSet.getTile(transmuter.getTilestype(tiles.keys().toArray().indexOf(all.key, false)).ordinal()+80)); .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()
{
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(1);
for (int x = 0; x < layer.getWidth(); x++)
for (int y = 0; y < layer.getHeight(); y++)
layer.getCell(x, y).setTile(null);
}
public int getSizeX() {
return tilesizex;
}
public int getSizeY() {
return tilesizey;
}
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);
transmuter.setRotation(Angle);
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));
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);
} }
} }
} }
}
public MapProperties getMenubyTile(int x,int y) public void EraseMenuTransmuterSurtile() {
{ TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(1);
Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y); for (int x = 0; x < layer.getWidth(); x++)
if (cell!=null) for (int y = 0; y < layer.getHeight(); y++)
return cell.getTile().getProperties(); layer.getCell(x, y).setTile(null);
else }
return null;
}
public int getSizeX() {
return tilesizex;
}
public int getSizeY() {
return tilesizey;
}
public Vector2 screentoworld(float x, float y) { public void setMenuTransmuter(int x, int y, String Name,
int xx=(int) ((x-1531f)/60f); Transmuter.Angular Angle) {
int yy=(int) ((y-(AssetLoader.height-776f))/60f); Cell cell = ((TiledMapTileLayer) map.getLayers().get(0)).getCell(x, y);
return new Vector2(xx,yy); 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);
transmuter.setRotation(Angle);
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));
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);
}
public Vector2 worldtoscreen(int x, int y) { }
float xx=1531.0f+x*60f; }
float yy=AssetLoader.height-776.0f+y*60f; }
return new Vector2(xx,yy);
}
@Override public MapProperties getMenubyTile(int x, int y) {
public void draw(Batch batch, float parentAlpha) { Cell cell = ((TiledMapTileLayer) map.getLayers().get(0)).getCell(x, y);
batch.end(); if (cell != null)
camera.update(); return cell.getTile().getProperties();
MapRenderer.setView(camera); else
MapRenderer.render(); return null;
batch.begin(); }
}
public Vector2 screentoworld(float x, float y) {
int xx = (int) ((x - 1531f) / 60f);
int yy = (int) ((y - (AssetLoader.height - 776f)) / 60f);
return new Vector2(xx, yy);
}
public Vector2 worldtoscreen(int x, int y) {
float xx = 1531.0f + x * 60f;
float yy = AssetLoader.height - 776.0f + y * 60f;
return new Vector2(xx, yy);
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.end();
camera.update();
MapRenderer.setView(camera);
MapRenderer.render();
batch.begin();
}
} }

View File

@ -1,8 +1,5 @@
package fr.evolving.UI; 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.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
@ -20,38 +17,41 @@ public class Objectives extends Actor {
public Objectives() { public Objectives() {
shaperenderer = new ShapeRenderer(); shaperenderer = new ShapeRenderer();
font=AssetLoader.Skin_level.getFont("Vademecum-18"); font = AssetLoader.Skin_level.getFont("Vademecum-18");
font2=AssetLoader.Skin_level.getFont("OpenDyslexicAlta-28"); font2 = AssetLoader.Skin_level.getFont("OpenDyslexicAlta-28");
} }
public void setVictory(int[] Victory) { public void setVictory(int[] Victory) {
this.Victory=Victory; this.Victory = Victory;
} }
@Override @Override
public final void draw(Batch batch, float parentAlpha) { public final void draw(Batch batch, float parentAlpha) {
shaperenderer.setProjectionMatrix(batch.getProjectionMatrix()); shaperenderer.setProjectionMatrix(batch.getProjectionMatrix());
int element=0; int element = 0;
int type=0; int type = 0;
for(int vict: Victory) { for (int vict : Victory) {
if (vict!=0) { if (vict != 0) {
batch.end(); batch.end();
shaperenderer.begin(ShapeType.Filled); shaperenderer.begin(ShapeType.Filled);
shaperenderer.setColor(AssetLoader.Typecolors[type]); 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.end();
shaperenderer.begin(ShapeType.Line); shaperenderer.begin(ShapeType.Line);
shaperenderer.setColor(1, 1, 1, 1); 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(); shaperenderer.end();
batch.begin(); batch.begin();
font.draw(batch, AssetLoader.Typenames[type], this.getX()+element*40+2,this.getY()+69); font.draw(batch, AssetLoader.Typenames[type], this.getX()
font2.draw(batch, String.valueOf(vict), this.getX()+element*40+11,this.getY()+35); + element * 40 + 2, this.getY() + 69);
element+=1; font2.draw(batch, String.valueOf(vict), this.getX() + element
* 40 + 11, this.getY() + 35);
element += 1;
} }
type+=1; type += 1;
} }
} }
} }

View File

@ -1,7 +1,6 @@
package fr.evolving.UI; package fr.evolving.UI;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Net.HttpMethods; 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.assets.AssetLoader;
import fr.evolving.database.Base; 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 { public class ServerList extends List {
HashMap parameters; HashMap parameters;
@ -28,16 +24,16 @@ public class ServerList extends List {
Base.datatype model; Base.datatype model;
Worldlist list; Worldlist list;
public ServerList(String url,Base.datatype model,Skin skin) { public ServerList(String url, Base.datatype model, Skin skin) {
super(skin); super(skin);
this.url=url; this.url = url;
this.model=model; this.model = model;
parameters = new HashMap(); parameters = new HashMap();
parameters.put("version", "last"); parameters.put("version", "last");
} }
public String getUrl() { public String getUrl() {
return (String)this.getSelected(); return (String) this.getSelected();
} }
public Base.datatype getModel() { public Base.datatype getModel() {
@ -45,56 +41,64 @@ public class ServerList extends List {
} }
public void setWorldlist(Worldlist list) { public void setWorldlist(Worldlist list) {
this.list=list; this.list = list;
} }
public void Refresh() { public void Refresh() {
HttpRequest httpGet = new HttpRequest(HttpMethods.GET); HttpRequest httpGet = new HttpRequest(HttpMethods.GET);
httpGet.setUrl(url); httpGet.setUrl(url);
httpGet.setContent(HttpParametersUtils.convertHttpParameters(parameters)); httpGet.setContent(HttpParametersUtils
//If you want basic authentication, add this header .convertHttpParameters(parameters));
String authHeader = "Basic " + Base64Coder.encodeString("evolving:--evolvE2016__"); // If you want basic authentication, add this header
httpGet.setHeader("Authorization", authHeader); String authHeader = "Basic "
httpGet.setHeader("Content-Type", "text/xml"); + Base64Coder.encodeString("evolving:--evolvE2016__");
httpGet.setHeader("Accept", "text/xml"); 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) {
String Response = "";
Array<Element> resultxml;
Array<String> resultstring = new Array<String>();
Response = httpResponse.getResultAsString();
XmlReader xml = new XmlReader();
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()))
resultstring.add(child.getText());
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)
list.Refresh();
}
}
Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() { @Override
public void handleHttpResponse(HttpResponse httpResponse) { public void failed(Throwable t) {
if (httpResponse.getStatus().getStatusCode()==200) Array<String> resultstring = new Array<String>();
{ String old = AssetLoader.Datahandler
String Response = ""; .getOld(ServerList.this.model);
Array<Element> resultxml; resultstring.add(old);
Array<String> resultstring=new Array<String>(); ServerList.this.setItems(resultstring);
Response = httpResponse.getResultAsString(); ServerList.this.setSelectedIndex(resultstring.indexOf(old,
XmlReader xml = new XmlReader(); false));
XmlReader.Element xml_element = xml.parse(Response); if (list != null
resultxml= xml_element.getChildrenByName("server"); && ServerList.this.model == Base.datatype.gamedata)
for(Element child : resultxml) list.Refresh();
if (AssetLoader.Datahandler.isBackend(ServerList.this.model,child.getText())) }
resultstring.add(child.getText());
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)
list.Refresh();
}
}
@Override
public void failed(Throwable t) {
Array<String> resultstring=new Array<String>();
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)
list.Refresh();
}
public void cancelled() { public void cancelled() {
} }
}); });
} }
} }

View File

@ -1,7 +1,6 @@
package fr.evolving.UI; package fr.evolving.UI;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.maps.MapLayers; import com.badlogic.gdx.maps.MapLayers;
@ -14,10 +13,8 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
import fr.evolving.assets.AssetLoader; import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Level; import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
import fr.evolving.automata.Transmuter.Angular;
public class TouchMaptiles extends Actor{ public class TouchMaptiles extends Actor {
private TiledMap map; private TiledMap map;
private OrthogonalTiledMapRenderer MapRenderer; private OrthogonalTiledMapRenderer MapRenderer;
@ -25,155 +22,190 @@ public class TouchMaptiles extends Actor{
private Level level; private Level level;
private int sizex; private int sizex;
private int sizey; private int sizey;
private float viewwidth,viewheight,decx,decy; private float viewwidth, viewheight, decx, decy;
public TouchMaptiles(Level level,int sizex,int sizey) { public TouchMaptiles(Level level, int sizex, int sizey) {
this.level=level; this.level = level;
this.sizex=sizex; this.sizex = sizex;
this.sizey=sizey; this.sizey = sizey;
map=new TiledMap(); map = new TiledMap();
map.getTileSets().addTileSet(AssetLoader.tileSet); map.getTileSets().addTileSet(AssetLoader.tileSet);
MapLayers layers = map.getLayers(); MapLayers layers = map.getLayers();
for (int i = 0; i < 5; i++) { 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,
for (int x = 0; x < layer.getWidth();x++) { level.Grid.sizeY, sizex, sizey);
for (int y = 0; y < layer.getHeight(); y++) { for (int x = 0; x < layer.getWidth(); x++) {
Cell cell = new Cell(); for (int y = 0; y < layer.getHeight(); y++) {
if (i==0) Cell cell = new Cell();
cell.setTile(AssetLoader.tileSet.getTile(53)); if (i == 0)
layer.setCell(x, y, cell); cell.setTile(AssetLoader.tileSet.getTile(53));
} layer.setCell(x, y, cell);
} }
layers.add(layer); }
} layers.add(layer);
layers.get(3).setOpacity(0.9f); }
MapRenderer = new OrthogonalTiledMapRenderer(map,1/128.0f); layers.get(3).setOpacity(0.9f);
camera = new OrthographicCamera(); MapRenderer = new OrthogonalTiledMapRenderer(map, 1 / 128.0f);
initzoom(); camera = new OrthographicCamera();
} initzoom();
public Vector2 screentoworld(float x, float y) {
x=(int)((x/AssetLoader.width*camera.viewportWidth)+decx);
y=(int)((y/AssetLoader.height*camera.viewportHeight)+decy);
return new Vector2(x,y);
}
public Vector2 screentoworldsize(float x, float y) {
x=((x/AssetLoader.width*camera.viewportWidth));
y=((y/AssetLoader.height*camera.viewportHeight));
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 tempclear() public Vector2 screentoworld(float x, float y) {
{ x = (int) ((x / AssetLoader.width * camera.viewportWidth) + decx);
for (int x=0;x<level.Grid.sizeX;x++) y = (int) ((y / AssetLoader.height * camera.viewportHeight) + decy);
for (int y=0;y<level.Grid.sizeY;y++) { return new Vector2(x, 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);
public Vector2 screentoworldsize(float x, float y) {
x = ((x / AssetLoader.width * camera.viewportWidth));
y = ((y / AssetLoader.height * camera.viewportHeight));
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 redraw(int tile) { public void tempclear() {
for (int x=0;x<level.Grid.sizeX;x++) for (int x = 0; x < level.Grid.sizeX; x++)
for (int y=0;y<level.Grid.sizeY;y++) { 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(3)).getCell((int) x,
((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)x, (int)y).setTile(null); (int) y).setTile(null);
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(tile)); ((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));
}
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)));
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) 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)) {
viewwidth = level.Grid.sizeX;
viewheight = level.Grid.sizeX
/ ((float) AssetLoader.width / AssetLoader.height);
} else {
viewheight = level.Grid.sizeY;
viewwidth = level.Grid.sizeY
* ((float) AssetLoader.width / AssetLoader.height);
} }
for (int x=0;x<level.Grid.sizeX;x++) Gdx.app.debug(getClass().getSimpleName(), "Caméra pour tilemap:"
for (int y=0;y<level.Grid.sizeY;y++) { + viewwidth + "x" + viewheight);
if (level.Grid.getCopper(x,y)) camera.setToOrtho(false, viewwidth, viewheight);
((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(level.Grid.getCoppercalc(x,y))); decx = (level.Grid.sizeX - viewwidth) / 2.0f;
if (level.Grid.getFiber(x,y)) decy = (level.Grid.sizeY - viewheight) / 2.0f;
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(61)); Gdx.app.debug(getClass().getSimpleName(), "Décalage:" + decx + "x"
if (level.Grid.getTransmutercalc(x, y)!=0) + decy);
{ camera.translate(decx, decy);
((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));
}
public void initzoom() { public void fillempty(int tile) {
if ((level.Grid.sizeX/(float)level.Grid.sizeY)>(AssetLoader.width/AssetLoader.height)) TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
{ for (int x = 0; x < layer.getWidth(); x++)
viewwidth=level.Grid.sizeX; for (int y = 0; y < layer.getHeight(); y++)
viewheight=level.Grid.sizeX/((float)AssetLoader.width/AssetLoader.height); if (layer.getCell(x, y).getTile().getId() == 53
} || layer.getCell(x, y).getTile().getId() == 60)
else layer.getCell(x, y).setTile(
{ AssetLoader.tileSet.getTile(tile));
viewheight=level.Grid.sizeY; }
viewwidth=level.Grid.sizeY*((float)AssetLoader.width/AssetLoader.height);
}
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);
camera.translate(decx,decy);
}
public void fillempty(int tile) public void setZoom(float factor) {
{ viewwidth *= factor;
TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get(0); viewheight *= factor;
for (int x = 0; x < layer.getWidth(); x++) camera.setToOrtho(false, viewwidth, viewheight);
for (int y = 0; y < layer.getHeight(); y++) camera.translate(decx, decy);
if (layer.getCell(x, y).getTile().getId()==53 || layer.getCell(x, y).getTile().getId()==60) layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(tile)); Gdx.app.debug(getClass().getSimpleName(), "Caméra pour tilemap:"
} + camera.viewportWidth + "x" + camera.viewportHeight + " zoom:"
+ factor);
}
public void setZoom(float factor) { public float getDecx() {
viewwidth*=factor; return decx;
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);
}
public float getDecx() { public float getDecy() {
return decx; return decy;
} }
public float getDecy() {
return decy;
}
public void setDec(float x,float y) {
Vector2 dec=screentoworldsize(x,y);
decx=decx-dec.x;
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);
return;
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.end();
//batch.setProjectionMatrix(camera.combined);
camera.update();
MapRenderer.setView(camera);
//MapRenderer.setView(camera.combined,0,0,maxx,maxx);
MapRenderer.render();
batch.begin();
}
public void setDec(float x, float y) {
Vector2 dec = screentoworldsize(x, y);
decx = decx - dec.x;
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);
return;
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.end();
// batch.setProjectionMatrix(camera.combined);
camera.update();
MapRenderer.setView(camera);
// MapRenderer.setView(camera.combined,0,0,maxx,maxx);
MapRenderer.render();
batch.begin();
}
} }

View File

@ -1,34 +1,31 @@
package fr.evolving.UI; package fr.evolving.UI;
import com.badlogic.gdx.Input; 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.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog; import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; 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; import fr.evolving.assets.AssetLoader;
public class WarnDialog extends Dialog{ public class WarnDialog extends Dialog {
Label thelabel; Label thelabel;
public WarnDialog(Skin skin) { public WarnDialog(Skin skin) {
super("Informations", skin); super("Informations", skin);
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
this.getContentTable().add(new ImageButton(AssetLoader.Skin_level,"Warnerbros")).left(); this.getContentTable()
thelabel=new Label("MenuScenario",AssetLoader.Skin_level); .add(new ImageButton(AssetLoader.Skin_level, "Warnerbros"))
.left();
thelabel = new Label("MenuScenario", AssetLoader.Skin_level);
this.getContentTable().add(thelabel).right(); this.getContentTable().add(thelabel).right();
this.setModal(true); this.setModal(true);
this.button("Ok"); this.button("Ok");
this.key(Input.Keys.ENTER, true); this.key(Input.Keys.ENTER, true);
} }
public void Show(String info,Stage stage) { public void Show(String info, Stage stage) {
this.thelabel.setText(info); this.thelabel.setText(info);
this.show(stage); this.show(stage);
} }

View File

@ -1,12 +1,10 @@
package fr.evolving.UI; package fr.evolving.UI;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.ui.List; import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import fr.evolving.assets.AssetLoader; import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.Preference;
public class Worldlist extends List { public class Worldlist extends List {
@ -16,11 +14,11 @@ public class Worldlist extends List {
} }
public void Refresh() { public void Refresh() {
Array<String> worlds=null; Array<String> worlds = null;
if (AssetLoader.Datahandler.game()!=null) if (AssetLoader.Datahandler.game() != null)
worlds=AssetLoader.Datahandler.game().getworlds(); worlds = AssetLoader.Datahandler.game().getworlds();
if (worlds==null) if (worlds == null)
worlds=new Array<String>(); worlds = new Array<String>();
this.setItems(worlds); this.setItems(worlds);
} }
} }

View File

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

View File

@ -2,647 +2,261 @@ package fr.evolving.assets;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import fr.evolving.automata.Cell;
import fr.evolving.automata.Grid; import fr.evolving.automata.Grid;
import fr.evolving.automata.Level; import fr.evolving.automata.Level;
public class InitWorlds { public class InitWorlds {
public static Array<Level> go() { public static Array<Level> go() {
Level[] thelevels=new Level[35]; Level[] thelevels = new Level[35];
thelevels[0]=new Level( thelevels[0] = new Level(
0, 0,
0, 0,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Introduction", "Introduction",
"Prise en main de l'interface de WireChem{#169} et amener l'électron neutre sur le senseur.", "Prise en main de l'interface de WireChem{#169} et amener l'électron neutre sur le senseur.",
"e0", "e0", 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, 0}, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 38f, 740f,
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -1, 0, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999, 99999,
38f, 99999, "", false, new int[][] { { 0, 1 }, { 0, 8 } });
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( thelevels[1] = new Level(
0, 0,
1, 1,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Trajectoires", "Trajectoires",
"Comprendre les trajectoires empruntées par les électrons afin de mieux appréhender la conception de systèmes.", "Comprendre les trajectoires empruntées par les électrons afin de mieux appréhender la conception de systèmes.",
"e0", "e0", 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, 0}, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 38f, 260f,
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -1, 0, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999, 99999,
38f, 99999, "", false, new int[][] { { 0, 2 } });
260f,
-1,
0,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 2}});
thelevels[2]=new Level( thelevels[2] = new Level(
0, 0,
2, 2,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Pistes", "Pistes",
"Utiliser des pistes afin de réaliser un circuit qui permet l'arrivée d'un électron neutre sur le senseur.", "Utiliser des pistes afin de réaliser un circuit qui permet l'arrivée d'un électron neutre sur le senseur.",
"e0", "e0", 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, 0}, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 180f,
new int[]{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 460f, -1, 15, new Grid(10, 3), 0, 0, 0, 0, 99999, 99999, 99999,
180f, 99999, "", false, new int[][] { { 0, 3 } });
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,
3,
(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 } });
thelevels[3]=new Level( thelevels[4] = new Level(
0, 0,
3, 4,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Positiveur", "Super-électrons",
"Comprendre le fonctionnement de l'élément positiveur et générer 8 électrons positifs sur le senseur.", "Générer 2 super-électrons negatifs par colision et les amener sur le senseur.",
"e+", "E-", 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, 0}, new int[] { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 590f,
new int[]{0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0}, 550f, 0, 16, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999, 99999,
380f, 99999, "", false, new int[][] { { 0, 5 } });
550f,
0,
16,
new Grid(30,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 4}});
thelevels[4]=new Level( thelevels[5] = new Level(
0, 0,
4, 5,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Super-électrons", "Activation",
"Générer 2 super-électrons negatifs par colision et les amener sur le senseur.", "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.",
"E-", "e0", 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, 0}, new int[] { 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 590f,
new int[]{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 220f, 1, 136, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
590f, 99999, 99999, "", false, new int[][] { { 0, 6 } });
550f,
0,
16,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 5}});
thelevels[5]=new Level( thelevels[6] = new Level(
0, 0,
5, 6,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Activation", "Fibres",
"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.", "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.",
"e0", "eX", 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, 0}, new int[] { 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0 }, 790f,
new int[]{0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 220f, 2, 230, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
590f, 99999, 99999, "", false, new int[][] { { 0, 7 } });
220f,
1,
136,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 6}});
thelevels[6]=new Level( thelevels[7] = new Level(
0, 0,
6, 7,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Fibres", "Protons",
"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.", "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.",
"eX", "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, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }, 950f,
new int[]{0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0}, 400f, 2, 370, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
790f, 99999, 99999, "", false, new int[][] { { 0, 8 } });
220f,
2,
230,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 7}});
thelevels[8] = new Level(
0,
8,
(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 } });
thelevels[7]=new Level( thelevels[9] = new Level(
0, 1,
7, 0,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Protons", "Deutérium",
"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.", "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.",
"p", "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, 0, 0, 0, 0, 0, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 }, 30f, 700f,
new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}, 4, 1100, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999, 99999,
950f, 99999, "", false, new int[][] { { 1, 1 } });
400f,
2,
370,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{0, 8}});
thelevels[8]=new Level( thelevels[10] = new Level(
0, 1,
8, 1,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Hydrogène", "Tritium",
"Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.", "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.",
"H", "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, 0, 0, 0, 0, 0, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1 }, 420f,
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, 750f, 4, 1000, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
1050f, 99999, 99999, "", false, new int[][] { {} });
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( thelevels[11] = new Level(
1, 1,
0, 2,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Deutérium", "Hélium-4",
"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.", "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.",
"D", "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, 0, 0, 0, 0, 0, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 2 }, 30f, 350f,
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1}, 4, 1200, new Grid(20, 20), 0, 0, 0, 0, 800, 99999, 99999,
30f, 99999, "", false, new int[][] { { 1, 3 }, { 1, 5 } });
700f,
4,
1100,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 1}});
thelevels[10]=new Level( thelevels[12] = new Level(
1, 1,
1, 3,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Tritium", "Hélium-3",
"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.", "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.",
"T", "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, 0, 0, 0, 0, 0, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 2 }, 180f,
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1}, 230f, 4, 1300, new Grid(20, 20), 0, 0, 0, 0, 700, 99999, 99999,
420f, 99999, "", false, new int[][] { { 1, 4 } });
750f,
4,
1000,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{}});
thelevels[11]=new Level( thelevels[13] = new Level(
1, 1,
2, 4,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Hélium-4", "Hélium-8",
"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.", "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", "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, 0, 0, 0, 0, 0, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 6, 2 }, 420f,
new int[]{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 2}, 230f, 5, 1500, new Grid(20, 20), 0, 0, 0, 0, 1800, 99999,
30f, 99999, 99999, "", false, new int[][] { {} });
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( thelevels[14] = new Level(
1, 1,
3, 5,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Hélium-3", "Lithium",
"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.", "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.",
"He", "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, 0, 0, 0, 0, 0, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 }, 300f,
new int[]{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 2}, 490f, 4, 1200, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
180f, 99999, 99999, "", false, new int[][] { { 1, 6 } });
230f,
4,
1300,
new Grid(20,20),
0,
0,
0,
0,
700,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 4}});
thelevels[13]=new Level( thelevels[15] = new Level(
1, 1,
4, 6,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Hélium-8", "Carbone",
"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.", "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.",
"He", "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, 0, 0, 0, 0, 0, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 }, 550f,
new int[]{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 6, 2}, 490f, 4, 1200, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
420f, 99999, 99999, "", false, new int[][] { { 1, 7 } });
230f,
5,
1500,
new Grid(20,20),
0,
0,
0,
0,
1800,
99999,
99999,
99999,
"",
false,
new int[][]{{}});
thelevels[14]=new Level( thelevels[16] = new Level(
1, 1,
5, 7,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Lithium", "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.", "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", "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, 0, 0, 0, 0, 0, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1 }, 800f,
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1}, 570f, 4, 1200, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
300f, 99999, 99999, "", false, new int[][] { { 1, 8 } });
490f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 6}});
thelevels[15]=new Level( thelevels[17] = new Level(
1, 1,
6, 8,
(int)(Math.random()*Integer.MAX_VALUE), (int) (Math.random() * Integer.MAX_VALUE),
"Carbone", "Néon",
"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.", "Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.",
"C", "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, 0, 0, 0, 0, 0, 0}, new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 }, 1000f,
new int[]{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1}, 750f, 6, 1200, new Grid(20, 20), 0, 0, 0, 0, 99999, 99999,
550f, 99999, 99999, "", true, new int[][] { {} });
490f,
4,
1200,
new Grid(20,20),
0,
0,
0,
0,
99999,
99999,
99999,
99999,
"",
false,
new int[][]{{1, 7}});
thelevels[16]=new Level( thelevels[18] = new Level(2, 1,
1, (int) (Math.random() * Integer.MAX_VALUE), "test",
7, "C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
(int)(Math.random()*Integer.MAX_VALUE), 0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
"Oxygène", 0, 0, 0 }, 38f, 740f, -1, 0, new Grid(20, 20), 0, 0, 0,
"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.", 0, 99999, 99999, 99999, 99999, "", false,
"O", new int[][] { { 2, 2 } });
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( thelevels[19] = new Level(2, 2,
1, (int) (Math.random() * Integer.MAX_VALUE), "test",
8, "C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
(int)(Math.random()*Integer.MAX_VALUE), 0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
"Néon", 0, 0, 0 }, 238f, 340f, -1, 0, new Grid(20, 20), 0, 0,
"Générer le premier atome complet : l'hydrogène avec un proton et un électron négatif sur la couche K.", 0, 0, 99999, 99999, 99999, 99999, "", false, 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( thelevels[20] = new Level(3, 1,
2, (int) (Math.random() * Integer.MAX_VALUE), "test",
1, "C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
(int)(Math.random()*Integer.MAX_VALUE), 0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
"test", 0, 0, 0 }, 38f, 740f, -1, 0, new Grid(20, 20), 0, 0, 0,
"C'est un test.", 0, 99999, 99999, 99999, 99999, "", false,
"e0", new int[][] { { 3, 2 } });
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[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[20]=new Level( thelevels[22] = new Level(4, 1,
3, (int) (Math.random() * Integer.MAX_VALUE), "test",
1, "C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
(int)(Math.random()*Integer.MAX_VALUE), 0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
"test", 0, 0, 0 }, 38f, 740f, -1, 0, new Grid(20, 20), 0, 0, 0,
"C'est un test.", 0, 99999, 99999, 99999, 99999, "", false,
"e0", new int[][] { { 4, 2 } });
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( thelevels[23] = new Level(4, 2,
3, (int) (Math.random() * Integer.MAX_VALUE), "test",
2, "C'est un test.", "e0", new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0,
(int)(Math.random()*Integer.MAX_VALUE), 0, 0, 0, 0 }, new int[] { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
"test", 0, 0, 0 }, 238f, 640f, -1, 0, new Grid(20, 20), 0, 0,
"C'est un test.", 0, 0, 99999, 99999, 99999, 99999, "", false, new int[][] {});
"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,
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[][]{});
return new Array<Level>(thelevels);
}
return new Array<Level>(thelevels);
}
} }

View File

@ -1,5 +1,6 @@
package fr.evolving.assets; package fr.evolving.assets;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics; import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.Graphics.DisplayMode; import com.badlogic.gdx.Graphics.DisplayMode;
@ -9,41 +10,38 @@ import com.badlogic.gdx.math.Vector2;
public class Preference { public class Preference {
public static Preferences prefs; public static Preferences prefs;
public static int init() { public static void init() {
prefs = Gdx.app.getPreferences("WireWorld - Evolving Games"); prefs = Gdx.app.getPreferences("WireWorld - Evolving Games");
//debug(); if (!prefs.contains("log"))
//test();
if (prefs.contains("log"))
return prefs.getInteger("log");
else
{
defaults(); defaults();
return Gdx.app.LOG_INFO; Gdx.app.setLogLevel(prefs.getInteger("log"));
}
} }
public static Vector2 getmaxresolution() { public static Vector2 getmaxresolution() {
Graphics.DisplayMode[] modes=Gdx.graphics.getDisplayModes(); Graphics.DisplayMode[] modes = Gdx.graphics.getDisplayModes();
int totalpixel=0; int totalpixel = 0;
int res; int res;
for(DisplayMode mode:modes) { for (DisplayMode mode : modes) {
int temppixel=mode.height*mode.width; int temppixel = mode.height * mode.width;
if (temppixel>totalpixel) totalpixel=temppixel; if (temppixel > totalpixel)
totalpixel = temppixel;
} }
for(DisplayMode mode:modes) for (DisplayMode mode : modes)
if (totalpixel==mode.height*mode.width) if (totalpixel == mode.height * mode.width)
return new Vector2(mode.width,mode.height); return new Vector2(mode.width, mode.height);
return null; return null;
} }
public static void defaults() { public static void defaults() {
Vector2 maxres=getmaxresolution(); 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("userdata", "local:test.db");
Preference.prefs.putString("gamedata", "local:test.db"); Preference.prefs.putString("gamedata", "local:test.db");
Preference.prefs.putString("statdata", "local:test.db"); Preference.prefs.putString("statdata", "local:test.db");
Preference.prefs.putInteger("ResolutionX", (int)maxres.x); Preference.prefs.putInteger("ResolutionX", (int) maxres.x);
Preference.prefs.putInteger("ResolutionY", (int)maxres.y); Preference.prefs.putInteger("ResolutionY", (int) maxres.y);
Preference.prefs.putInteger("Resolution", 9); Preference.prefs.putInteger("Resolution", 9);
Preference.prefs.putBoolean("Fullscreen", true); Preference.prefs.putBoolean("Fullscreen", true);
Preference.prefs.putBoolean("Sound", true); Preference.prefs.putBoolean("Sound", true);
@ -54,35 +52,10 @@ public class Preference {
Preference.prefs.putBoolean("Language", false); Preference.prefs.putBoolean("Language", false);
Preference.prefs.putString("world", "test pour voir"); Preference.prefs.putString("world", "test pour voir");
Preference.prefs.putFloat("Effect", 1.0f); Preference.prefs.putFloat("Effect", 1.0f);
Preference.prefs.putFloat("Music",0.75f); Preference.prefs.putFloat("Music", 0.75f);
Preference.prefs.putInteger("Adaptation", 2); Preference.prefs.putInteger("Adaptation", 0);
Preference.prefs.putInteger("Quality", 2); 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); Preference.prefs.putInteger("log", Gdx.app.LOG_DEBUG);
Gdx.app.setLogLevel(Gdx.app.LOG_DEBUG);
Preference.prefs.flush(); 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,9 +1,8 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.io.Serializable; import java.io.Serializable;
import com.badlogic.gdx.graphics.g2d.Sprite;
public class Cell implements Serializable{ public class Cell implements Serializable {
public int Fiber; public int Fiber;
public boolean Copper; public boolean Copper;
public transient int Copper_calc; public transient int Copper_calc;
@ -14,13 +13,13 @@ public class Cell implements Serializable{
public transient int Transmuter_movey; public transient int Transmuter_movey;
public Cell() { public Cell() {
this.Fiber=0; this.Fiber = 0;
this.Copper=false; this.Copper = false;
this.Fiber_old=0; this.Fiber_old = 0;
this.Transmuter=null; this.Transmuter = null;
this.Transmuter_calc=0; this.Transmuter_calc = 0;
this.Transmuter_movex=0; this.Transmuter_movex = 0;
this.Transmuter_movey=0; this.Transmuter_movey = 0;
} }
} }

View File

@ -1,239 +1,260 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.ObjectMap.Entry; import com.badlogic.gdx.utils.ObjectMap.Entry;
import fr.evolving.automata.Transmuter.CaseType; public class Grid implements Serializable {
public class Grid implements Serializable{
public Cell[][] Cells; public Cell[][] Cells;
public Integer sizeX,sizeY; public Integer sizeX, sizeY;
public Grid(Integer X,Integer Y) { public Grid(Integer X, Integer Y) {
this.sizeX=X; this.sizeX = X;
this.sizeY=Y; this.sizeY = Y;
this.Cells = new Cell[this.sizeX][this.sizeY]; this.Cells = new Cell[this.sizeX][this.sizeY];
for (int x=0;x<this.sizeX;x++) { for (int x = 0; x < this.sizeX; x++) {
for (int y=0;y<this.sizeY;y++) { for (int y = 0; y < this.sizeY; y++) {
this.Cells[x][y]=new Cell(); this.Cells[x][y] = new Cell();
} }
} }
} }
public void tiling_transmuter() { public void tiling_transmuter() {
for (int x=0;x<this.sizeX;x++) for (int x = 0; x < this.sizeX; x++)
for (int y=0;y<this.sizeY;y++) for (int y = 0; y < this.sizeY; y++)
GetXY(x,y).Transmuter_calc=0; GetXY(x, y).Transmuter_calc = 0;
for (int x=0;x<this.sizeX;x++) for (int x = 0; x < this.sizeX; x++)
for (int y=0;y<this.sizeY;y++) { for (int y = 0; y < this.sizeY; y++) {
Transmuter transmuter=getTransmuter(x,y); Transmuter transmuter = getTransmuter(x, y);
if (transmuter!=null) if (transmuter != null) {
{ Iterator<Entry<Vector2, Integer>> tiles = transmuter
Iterator<Entry<Vector2, Integer>> tiles = transmuter.getTilesidrotated().iterator(); .getTilesidrotated().iterator();
while(tiles.hasNext()){ while (tiles.hasNext()) {
Entry<Vector2, Integer> all=tiles.next(); 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)
GetXY(x+all.key.x,y+all.key.y).Transmuter_movex=(int)-all.key.x; * transmuter.getRotation().ordinal()
GetXY(x+all.key.x,y+all.key.y).Transmuter_movey=(int)-all.key.y; + 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 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 + ">"
if (GetXY(x, y).Transmuter_calc>0) + GetXY(x, y).Transmuter_calc);
Gdx.app.debug("info",x+","+y+">"+GetXY(x, y).Transmuter_calc); }
} }
}
public void tiling_copper() { public void tiling_copper() {
for (int x=0;x<this.sizeX;x++) 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 (getCopper(x,y)) if (getCopper(x, y)) {
{ int value = 0;
int value=0; if (getCopper(x, y + 1))
if (getCopper(x,y+1))
value++;
if (getCopper(x-1,y))
value+=8;
if (getCopper(x,y-1))
value+=4;
if (getCopper(x+1,y))
value+=2;
GetXY(x,y).Copper_calc=value;
}
else
GetXY(x,y).Copper_calc=-1;
for (int x=0;x<this.sizeX;x++)
for (int y=0;y<this.sizeY;y++)
{
int value=0;
if (getCoppercalc(x,y)==15)
{
if (getCopper(x-1,y-1))
value++; value++;
if (getCopper(x,y-1)) if (getCopper(x - 1, y))
value += 8;
if (getCopper(x, y - 1))
value += 4;
if (getCopper(x + 1, y))
value += 2;
GetXY(x, y).Copper_calc = value;
} else
GetXY(x, y).Copper_calc = -1;
for (int x = 0; x < this.sizeX; x++)
for (int y = 0; y < this.sizeY; y++) {
int value = 0;
if (getCoppercalc(x, y) == 15) {
if (getCopper(x - 1, y - 1))
value++; value++;
if (getCopper(x+1,y-1)) if (getCopper(x, y - 1))
value++; value++;
if (getCopper(x-1,y)) if (getCopper(x + 1, y - 1))
value++; value++;
if (getCopper(x+1,y)) if (getCopper(x - 1, y))
value++; value++;
if (getCopper(x-1,y+1)) if (getCopper(x + 1, y))
value++; value++;
if (getCopper(x,y+1)) if (getCopper(x - 1, y + 1))
value++; value++;
if (getCopper(x+1,y+1)) if (getCopper(x, y + 1))
value++; value++;
if (value>=5) if (getCopper(x + 1, y + 1))
GetXY(x,y).Copper_calc=GetXY(x,y).Copper_calc+20; value++;
} if (value >= 5)
else GetXY(x, y).Copper_calc = GetXY(x, y).Copper_calc + 20;
{ } else {
if (getCoppercalc(x,y)!=-1) if (getCoppercalc(x, y) != -1) {
{ int oldvalue = GetXY(x, y).Copper_calc;
int oldvalue=GetXY(x,y).Copper_calc; if (getCoppercalc(x - 1, y - 1) == 15
if (getCoppercalc(x-1,y-1)==15 || getCoppercalc(x-1,y-1)==35) || getCoppercalc(x - 1, y - 1) == 35)
value++; value++;
if (getCoppercalc(x,y-1)==15 || getCoppercalc(x,y-1)==35) if (getCoppercalc(x, y - 1) == 15
|| getCoppercalc(x, y - 1) == 35)
value++; 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++; value++;
if (getCoppercalc(x-1,y)==15 || getCoppercalc(x-1,y)==35) if (getCoppercalc(x - 1, y) == 15
|| getCoppercalc(x - 1, y) == 35)
value++; value++;
if (getCoppercalc(x+1,y)==15 || getCoppercalc(x+1,y)==35) if (getCoppercalc(x + 1, y) == 15
|| getCoppercalc(x + 1, y) == 35)
value++; 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++; value++;
if (getCoppercalc(x,y+1)==15 || getCoppercalc(x,y+1)==35) if (getCoppercalc(x, y + 1) == 15
|| getCoppercalc(x, y + 1) == 35)
value++; 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++; value++;
if (value>=1 && oldvalue!=1 && oldvalue!=2 && oldvalue!=4 && oldvalue!=8 && oldvalue!=10 && oldvalue!=5) if (value >= 1 && oldvalue != 1 && oldvalue != 2
GetXY(x,y).Copper_calc=oldvalue+20; && 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 x = 0; x < this.sizeX; x++)
for (int y=0;y<this.sizeY;y++) for (int y = 0; y < this.sizeY; y++) {
{ if (getCoppercalc(x, y) == 35) {
if (getCoppercalc(x,y)==35) int value = 0;
{ if (!getCopper(x + 1, y + 1))
int value=0; value += 2;
if (!getCopper(x+1,y+1)) if (!getCopper(x - 1, y - 1))
value+=2; value += 8;
if (!getCopper(x-1,y-1)) if (!getCopper(x + 1, y - 1))
value+=8; value += 4;
if (!getCopper(x+1,y-1)) if (!getCopper(x - 1, y + 1))
value+=4; value += 1;
if (!getCopper(x-1,y+1)) GetXY(x, y).Copper_calc = GetXY(x, y).Copper_calc + value;
value+=1;
GetXY(x,y).Copper_calc=GetXY(x,y).Copper_calc+value;
} }
} }
for (int x=0;x<this.sizeX;x++) 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;
int oldvalue=GetXY(x,y).Copper_calc; if (oldvalue == 27 || oldvalue == 31 || oldvalue == 33
if (oldvalue==27||oldvalue==31||oldvalue==33||oldvalue==34) || oldvalue == 34) {
{ int value = 0;
int value=0; if (getCopper(x, y + 1) && getCoppercalc(x, y + 1) < 15)
if (getCopper(x,y+1) && getCoppercalc(x,y+1)<15) value += 1;
value+=1; if (getCopper(x - 1, y) && getCoppercalc(x - 1, y) < 15)
if (getCopper(x-1,y) && getCoppercalc(x-1,y)<15) value += 6;
value+=6; if (getCopper(x, y - 1) && getCoppercalc(x, y - 1) < 15)
if (getCopper(x,y-1) && getCoppercalc(x,y-1)<15) value += 2;
value+=2; if (getCopper(x + 1, y) && getCoppercalc(x + 1, y) < 15)
if (getCopper(x+1,y) && getCoppercalc(x+1,y)<15) value += 2;
value+=2; if (value > 0)
if (value>0) GetXY(x, y).Copper_calc = oldvalue + 22 + value;
GetXY(x,y).Copper_calc=oldvalue+22+value; }
} int value = 0;
int value=0; if (oldvalue == 34
if (oldvalue==34 && (getCoppercalc(x-1,y)==31 || getCoppercalc(x-1,y)==55 || getCoppercalc(x-1,y)==58)) && (getCoppercalc(x - 1, y) == 31
value=62; || getCoppercalc(x - 1, y) == 55 || getCoppercalc(
if (oldvalue==34 && (getCoppercalc(x+1,y)==31 || getCoppercalc(x+1,y)==55 || getCoppercalc(x+1,y)==58)) x - 1, y) == 58))
value=58; value = 62;
if (oldvalue==31 && (getCoppercalc(x-1,y)==34 || getCoppercalc(x-1,y)==58 || getCoppercalc(x-1,y)==62)) if (oldvalue == 34
value=59; && (getCoppercalc(x + 1, y) == 31
if (oldvalue==31 && (getCoppercalc(x+1,y)==34 || getCoppercalc(x+1,y)==58 || getCoppercalc(x+1,y)==62)) || getCoppercalc(x + 1, y) == 55 || getCoppercalc(
value=55; x + 1, y) == 58))
if (oldvalue==33 && (getCoppercalc(x,y-1)==27 || getCoppercalc(x,y-1)==50 || getCoppercalc(x,y-1)==51)) value = 58;
value=57; if (oldvalue == 31
if (oldvalue==33 && (getCoppercalc(x,y+1)==27 || getCoppercalc(x,y+1)==50 || getCoppercalc(x,y+1)==51)) && (getCoppercalc(x - 1, y) == 34
value=56; || getCoppercalc(x - 1, y) == 58 || getCoppercalc(
if (oldvalue==27 && (getCoppercalc(x,y-1)==33 || getCoppercalc(x,y-1)==56 || getCoppercalc(x,y-1)==57)) x - 1, y) == 62))
value=51; value = 59;
if (oldvalue==27 && (getCoppercalc(x,y+1)==33 || getCoppercalc(x,y+1)==56 || getCoppercalc(x,y+1)==57)) if (oldvalue == 31
value=50; && (getCoppercalc(x + 1, y) == 34
if (value>0) || getCoppercalc(x + 1, y) == 58 || getCoppercalc(
GetXY(x,y).Copper_calc=value; x + 1, y) == 62))
value = 55;
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))
value = 56;
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))
value = 50;
if (value > 0)
GetXY(x, y).Copper_calc = value;
} }
return; return;
} }
public Cell GetXY(float X, float Y) {
public Cell GetXY(float X,float Y) { if (X < 0 || Y < 0 || X >= this.sizeX || Y >= this.sizeY)
if (X<0 || Y<0 || X>=this.sizeX || Y>=this.sizeY)
return null; return null;
else else
return this.Cells[(int)X][(int)Y]; return this.Cells[(int) X][(int) Y];
} }
public Transmuter getTransmuter(float X,float Y) { public Transmuter getTransmuter(float X, float Y) {
Cell cell=GetXY(X,Y); Cell cell = GetXY(X, Y);
if (cell==null) if (cell == null)
return null; return null;
else else
return cell.Transmuter; return cell.Transmuter;
} }
public int getTransmutercalc(float X,float Y) { public int getTransmutercalc(float X, float Y) {
Cell cell=GetXY(X,Y); Cell cell = GetXY(X, Y);
if (cell==null) if (cell == null)
return 0; return 0;
else else
return cell.Transmuter_calc & 0xFFFF; return cell.Transmuter_calc & 0xFFFF;
} }
public int getTransmuterrot(float X,float Y) { public int getTransmuterrot(float X, float Y) {
Cell cell=GetXY(X,Y); Cell cell = GetXY(X, Y);
if (cell==null) if (cell == null)
return 0; return 0;
else else
return cell.Transmuter_calc>>16; return cell.Transmuter_calc >> 16;
} }
public boolean getCopper(float X,float Y) { public boolean getCopper(float X, float Y) {
Cell cell=GetXY(X,Y); Cell cell = GetXY(X, Y);
if (cell==null) if (cell == null)
return false; return false;
else else
return cell.Copper; return cell.Copper;
} }
public boolean getFiber(float X,float Y) { public boolean getFiber(float X, float Y) {
Cell cell=GetXY(X,Y); Cell cell = GetXY(X, Y);
if (cell==null) if (cell == null)
return false; return false;
else else
return cell.Fiber>0; return cell.Fiber > 0;
} }
public int getCoppercalc(float X,float Y) { public int getCoppercalc(float X, float Y) {
Cell cell=GetXY(X,Y); Cell cell = GetXY(X, Y);
if (cell==null) if (cell == null)
return 0; return 0;
else else
return cell.Copper_calc; return cell.Copper_calc;
} }
} }

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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 Inverter_I extends Transmuter { public class Inverter_I extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,35 +37,35 @@ public class Inverter_I extends Transmuter {
public Inverter_I(Level level) { public Inverter_I(Level level) {
super(level); super(level);
this.Name="Inverseur I"; this.Name = "Inverseur I";
this.Desc="Inverseur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Inverseur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=new Inverter_II(level); this.Upgrade = new Inverter_II(level);
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 112); this.Tilesid.put(new Vector2(0, 0), 112);
} }
public String getName() { public String getName() {
@ -86,27 +81,27 @@ public class Inverter_I extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -114,30 +109,30 @@ public class Inverter_I extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -146,15 +141,19 @@ public class Inverter_I extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -162,7 +161,7 @@ public class Inverter_I extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -174,7 +173,7 @@ public class Inverter_I extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -196,11 +195,11 @@ public class Inverter_I extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -208,63 +207,63 @@ public class Inverter_I extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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 Inverter_II extends Transmuter { public class Inverter_II extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,35 +37,35 @@ public class Inverter_II extends Transmuter {
public Inverter_II(Level level) { public Inverter_II(Level level) {
super(level); super(level);
this.Name="Inverseur II"; this.Name = "Inverseur II";
this.Desc="Inverseur de degré 2 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Inverseur de degré 2 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=null; this.Upgrade = null;
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 113); this.Tilesid.put(new Vector2(0, 0), 113);
} }
public String getName() { public String getName() {
@ -86,27 +81,27 @@ public class Inverter_II extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -114,30 +109,30 @@ public class Inverter_II extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -146,15 +141,19 @@ public class Inverter_II extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -162,7 +161,7 @@ public class Inverter_II extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -174,7 +173,7 @@ public class Inverter_II extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -196,11 +195,11 @@ public class Inverter_II extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -208,63 +207,63 @@ public class Inverter_II extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -2,7 +2,7 @@ package fr.evolving.automata;
import java.io.Serializable; import java.io.Serializable;
public class Level implements Serializable{ public class Level implements Serializable {
public String Name; public String Name;
public String Description; public String Description;
public String Element; public String Element;
@ -29,31 +29,35 @@ public class Level implements Serializable{
public String Tuto; public String Tuto;
public int[][] Link; 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,
this.aWorld=aWorld; String Description, String Element, int[] Current, int[] Victory,
this.aLevel=aLevel; float X, float Y, int Tech, int Cout, Grid World, int Cycle,
this.id=id; int Temp, int Rayon, int Nrj, int Maxcycle, int Maxtemp,
this.Name=Name; int Maxrayon, int Maxnrj, String Tuto, boolean Special, int[][] Link) {
this.Description=Description; this.aWorld = aWorld;
this.Element=Element; this.aLevel = aLevel;
this.Current=Current; this.id = id;
this.Victory=Victory; this.Name = Name;
this.X=X; this.Description = Description;
this.Y=Y; this.Element = Element;
this.Tech=Tech; this.Current = Current;
this.Cout=Cout; this.Victory = Victory;
this.Grid=World; this.X = X;
this.Grid_orig=World; this.Y = Y;
this.Cycle=Cycle; this.Tech = Tech;
this.Temp=Temp; this.Cout = Cout;
this.Rayon=Rayon; this.Grid = World;
this.Nrj=Nrj; this.Grid_orig = World;
this.Maxcycle=Maxcycle; this.Cycle = Cycle;
this.Maxtemp=Maxtemp; this.Temp = Temp;
this.Maxrayon=Maxrayon; this.Rayon = Rayon;
this.Maxnrj=Maxnrj; this.Nrj = Nrj;
this.Special=Special; this.Maxcycle = Maxcycle;
this.Tuto=Tuto; this.Maxtemp = Maxtemp;
this.Link=Link; this.Maxrayon = Maxrayon;
} this.Maxnrj = Maxnrj;
this.Special = Special;
this.Tuto = Tuto;
this.Link = Link;
}
} }

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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 Negativer extends Transmuter { public class Negativer extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,35 +37,35 @@ public class Negativer extends Transmuter {
public Negativer(Level level) { public Negativer(Level level) {
super(level); super(level);
this.Name="Negativeur non activable"; this.Name = "Negativeur non activable";
this.Desc="Negativeur avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Negativeur avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=null; this.Upgrade = null;
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Nimporte); this.Tilestype.put(new Vector2(0, 0), CaseType.Nimporte);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 101); this.Tilesid.put(new Vector2(0, 0), 101);
} }
public String getName() { public String getName() {
@ -86,27 +81,27 @@ public class Negativer extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -114,30 +109,30 @@ public class Negativer extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -146,15 +141,19 @@ public class Negativer extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -162,7 +161,7 @@ public class Negativer extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -174,7 +173,7 @@ public class Negativer extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -196,11 +195,11 @@ public class Negativer extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -208,63 +207,63 @@ public class Negativer extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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 Negativer_I extends Transmuter { public class Negativer_I extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,37 +37,37 @@ public class Negativer_I extends Transmuter {
public Negativer_I(Level level) { public Negativer_I(Level level) {
super(level); super(level);
this.Name="Negativeur I"; this.Name = "Negativeur I";
this.Desc="Negativeur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Negativeur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=new Negativer_II(level); this.Upgrade = new Negativer_II(level);
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul);
this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 108); this.Tilesid.put(new Vector2(0, 0), 108);
this.Tilesid.put(new Vector2(1,0), 105); this.Tilesid.put(new Vector2(1, 0), 105);
} }
public String getName() { public String getName() {
@ -88,27 +83,27 @@ public class Negativer_I extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -116,30 +111,30 @@ public class Negativer_I extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -148,15 +143,19 @@ public class Negativer_I extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -164,7 +163,7 @@ public class Negativer_I extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -176,7 +175,7 @@ public class Negativer_I extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -198,11 +197,11 @@ public class Negativer_I extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -210,63 +209,63 @@ public class Negativer_I extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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 Negativer_II extends Transmuter { public class Negativer_II extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,37 +37,37 @@ public class Negativer_II extends Transmuter {
public Negativer_II(Level level) { public Negativer_II(Level level) {
super(level); super(level);
this.Name="Negativeur II"; this.Name = "Negativeur II";
this.Desc="Negativeur de degré 3 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Negativeur de degré 3 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=new Negativer_III(level); this.Upgrade = new Negativer_III(level);
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre);
this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 109); this.Tilesid.put(new Vector2(0, 0), 109);
this.Tilesid.put(new Vector2(1,0), 107); this.Tilesid.put(new Vector2(1, 0), 107);
} }
public String getName() { public String getName() {
@ -88,27 +83,27 @@ public class Negativer_II extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -116,30 +111,30 @@ public class Negativer_II extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -148,15 +143,19 @@ public class Negativer_II extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -164,7 +163,7 @@ public class Negativer_II extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -176,7 +175,7 @@ public class Negativer_II extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -198,11 +197,11 @@ public class Negativer_II extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -210,63 +209,63 @@ public class Negativer_II extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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 Negativer_III extends Transmuter { public class Negativer_III extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,36 +37,36 @@ public class Negativer_III extends Transmuter {
public Negativer_III(Level level) { public Negativer_III(Level level) {
super(level); super(level);
this.Name="Negativeur III"; this.Name = "Negativeur III";
this.Desc="Negativeur de degré 3 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Negativeur de degré 3 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=null; this.Upgrade = null;
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Tout); this.Tilestype.put(new Vector2(0, 0), CaseType.Tout);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 103); this.Tilesid.put(new Vector2(0, 0), 103);
} }
public String getName() { public String getName() {
@ -87,27 +82,27 @@ public class Negativer_III extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -115,30 +110,30 @@ public class Negativer_III extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -147,15 +142,19 @@ public class Negativer_III extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -163,7 +162,7 @@ public class Negativer_III extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -175,7 +174,7 @@ public class Negativer_III extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -197,11 +196,11 @@ public class Negativer_III extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -209,63 +208,63 @@ public class Negativer_III extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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 Neutraliser_I extends Transmuter { public class Neutraliser_I extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,35 +37,35 @@ public class Neutraliser_I extends Transmuter {
public Neutraliser_I(Level level) { public Neutraliser_I(Level level) {
super(level); super(level);
this.Name="Neutraliseur I"; this.Name = "Neutraliseur I";
this.Desc="Neutraliseur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Neutraliseur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=new Neutraliser_II(level); this.Upgrade = new Neutraliser_II(level);
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 110); this.Tilesid.put(new Vector2(0, 0), 110);
} }
public String getName() { public String getName() {
@ -86,27 +81,27 @@ public class Neutraliser_I extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -114,30 +109,30 @@ public class Neutraliser_I extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -146,15 +141,19 @@ public class Neutraliser_I extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -162,7 +161,7 @@ public class Neutraliser_I extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -174,7 +173,7 @@ public class Neutraliser_I extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -196,11 +195,11 @@ public class Neutraliser_I extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -208,63 +207,63 @@ public class Neutraliser_I extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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 Neutraliser_II extends Transmuter { public class Neutraliser_II extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,35 +37,35 @@ public class Neutraliser_II extends Transmuter {
public Neutraliser_II(Level level) { public Neutraliser_II(Level level) {
super(level); super(level);
this.Name="Neutraliseur II"; this.Name = "Neutraliseur II";
this.Desc="Neutraliseur de degré 2 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Neutraliseur de degré 2 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=null; this.Upgrade = null;
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 111); this.Tilesid.put(new Vector2(0, 0), 111);
} }
public String getName() { public String getName() {
@ -86,27 +81,27 @@ public class Neutraliser_II extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -114,30 +109,30 @@ public class Neutraliser_II extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -146,15 +141,19 @@ public class Neutraliser_II extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -162,7 +161,7 @@ public class Neutraliser_II extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -174,7 +173,7 @@ public class Neutraliser_II extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -196,11 +195,11 @@ public class Neutraliser_II extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -208,63 +207,63 @@ public class Neutraliser_II extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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 extends Transmuter { public class Positiver extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,35 +37,35 @@ public class Positiver extends Transmuter {
public Positiver(Level level) { public Positiver(Level level) {
super(level); super(level);
this.Name="Positiveur non activable"; this.Name = "Positiveur non activable";
this.Desc="Positiveur ...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Positiveur ...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=null; this.Upgrade = null;
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Nimporte); this.Tilestype.put(new Vector2(0, 0), CaseType.Nimporte);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 100); this.Tilesid.put(new Vector2(0, 0), 100);
} }
public String getName() { public String getName() {
@ -86,27 +81,27 @@ public class Positiver extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -114,30 +109,30 @@ public class Positiver extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -146,15 +141,19 @@ public class Positiver extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -162,7 +161,7 @@ public class Positiver extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -174,7 +173,7 @@ public class Positiver extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -196,11 +195,11 @@ public class Positiver extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -208,63 +207,63 @@ public class Positiver extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.ObjectMap.Values; import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap; import com.badlogic.gdx.utils.OrderedMap;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
public class Positiver_I extends Transmuter { public class Positiver_I extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,37 +37,37 @@ public class Positiver_I extends Transmuter {
public Positiver_I(Level level) { public Positiver_I(Level level) {
super(level); super(level);
this.Name="Positiveur I"; this.Name = "Positiveur I";
this.Desc="Positiveur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Positiveur de degré 1 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=new Positiver_II(level); this.Upgrade = new Positiver_II(level);
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul);
this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 104); this.Tilesid.put(new Vector2(0, 0), 104);
this.Tilesid.put(new Vector2(1,0), 105); this.Tilesid.put(new Vector2(1, 0), 105);
} }
public String getName() { public String getName() {
@ -88,27 +83,27 @@ public class Positiver_I extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -116,30 +111,30 @@ public class Positiver_I extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -148,15 +143,19 @@ public class Positiver_I extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> tiles = this.Tilesid.keys(); Iterator<Vector2> tiles = this.Tilesid.keys();
while(tiles.hasNext()){ while (tiles.hasNext()) {
Vector2 key = tiles.next(); Vector2 key = tiles.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -164,7 +163,7 @@ public class Positiver_I extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -176,7 +175,7 @@ public class Positiver_I extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -198,11 +197,11 @@ public class Positiver_I extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -210,63 +209,63 @@ public class Positiver_I extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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_II extends Transmuter { public class Positiver_II extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,37 +37,37 @@ public class Positiver_II extends Transmuter {
public Positiver_II(Level level) { public Positiver_II(Level level) {
super(level); super(level);
this.Name="Positiveur II"; this.Name = "Positiveur II";
this.Desc="Positiveur de degré 2222222 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Positiveur de degré 2222222 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=new Positiver_III(level); this.Upgrade = new Positiver_III(level);
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre);
this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 106); this.Tilesid.put(new Vector2(0, 0), 106);
this.Tilesid.put(new Vector2(1,0), 107); this.Tilesid.put(new Vector2(1, 0), 107);
} }
public String getName() { public String getName() {
@ -88,27 +83,27 @@ public class Positiver_II extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -116,30 +111,30 @@ public class Positiver_II extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -148,15 +143,19 @@ public class Positiver_II extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -164,7 +163,7 @@ public class Positiver_II extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -176,7 +175,7 @@ public class Positiver_II extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -198,11 +197,11 @@ public class Positiver_II extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -210,63 +209,63 @@ public class Positiver_II extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,18 +1,13 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values; 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_III extends Transmuter { public class Positiver_III extends Transmuter {
private static String Name,Desc; private static String Name, Desc;
private static Class theClass; private static Class theClass;
private static int Price; private static int Price;
private static int Technology; private static int Technology;
@ -42,35 +37,35 @@ public class Positiver_III extends Transmuter {
public Positiver_III(Level level) { public Positiver_III(Level level) {
super(level); super(level);
this.Name="Positiveur III"; this.Name = "Positiveur III";
this.Desc="Positiveur de degré 3 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec"; this.Desc = "Positiveur de degré 3 avec...blabla avec...blabla avec avecave aveca vecavec avec avec avec avecavecavecavec avec avecavecavec avec avecavecavecavec avec";
this.theClass=Class.Charge; this.theClass = Class.Charge;
this.Price=50; this.Price = 50;
this.Technology=2; this.Technology = 2;
this.Research=0; this.Research = 0;
this.Upgrade=null; this.Upgrade = null;
this.Unlock=null; this.Unlock = null;
this.showed=true; this.showed = true;
this.CanUpgradeTemp=true; this.CanUpgradeTemp = true;
this.CanUpgradeCycle=true; this.CanUpgradeCycle = true;
this.CanUpgradeRayon=false; this.CanUpgradeRayon = false;
this.CanUpgradeNrj=false; this.CanUpgradeNrj = false;
this.UpgradedTemp=1f; this.UpgradedTemp = 1f;
this.UpgradedCycle=1f; this.UpgradedCycle = 1f;
this.UpgradedRayon=1f; this.UpgradedRayon = 1f;
this.UpgradedNrj=1f; this.UpgradedNrj = 1f;
this.UsedTemp=0.5f; this.UsedTemp = 0.5f;
this.UsedRayon=0f; this.UsedRayon = 0f;
this.UsedNrj=0f; this.UsedNrj = 0f;
this.TurnTemp=0f; this.TurnTemp = 0f;
this.TurnRayon=0f; this.TurnRayon = 0f;
this.TurnNrj=0f; this.TurnNrj = 0f;
this.Activable=true; this.Activable = true;
this.ActivationLevel=0; this.ActivationLevel = 0;
this.Tilestype= new OrderedMap<Vector2, CaseType>(); this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Tout); this.Tilestype.put(new Vector2(0, 0), CaseType.Tout);
this.Tilesid= new OrderedMap<Vector2, Integer>(); this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 102); this.Tilesid.put(new Vector2(0, 0), 102);
} }
public String getName() { public String getName() {
@ -86,27 +81,27 @@ public class Positiver_III extends Transmuter {
} }
public void ProcessCycle() { public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp; this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon; this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj; this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable) if (this.Activable)
this.ActivationLevel-=1; this.ActivationLevel -= 1;
} }
public void Run() { public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp; this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon; this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj; this.level.Nrj += UsedNrj * UpgradedNrj;
} }
public void Unlock() { public void Unlock() {
if (this.Unlock==null) if (this.Unlock == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
} }
public void Upgrade() { public void Upgrade() {
if (this.Upgrade==null) if (this.Upgrade == null)
return; return;
this.Unlock.SetShowed(true); this.Unlock.SetShowed(true);
this.SetShowed(false); this.SetShowed(false);
@ -114,30 +109,30 @@ public class Positiver_III extends Transmuter {
public void Activate() { public void Activate() {
if (this.Activable) if (this.Activable)
ActivationLevel=this.getMaxActivationLevel(); ActivationLevel = this.getMaxActivationLevel();
} }
public void UpgradeTemp() { public void UpgradeTemp() {
if (isUpgradableTemp()) if (isUpgradableTemp())
UpgradedTemp+=-0.2f; UpgradedTemp += -0.2f;
} }
public void UpgradeNrj() { public void UpgradeNrj() {
if (isUpgradableNrj()) if (isUpgradableNrj())
UpgradedNrj+=-0.2f; UpgradedNrj += -0.2f;
} }
public void UpgradeRayon() { public void UpgradeRayon() {
if (isUpgradableRayon()) if (isUpgradableRayon())
UpgradedRayon+=-0.2f; UpgradedRayon += -0.2f;
} }
public void UpgradeCycle() { public void UpgradeCycle() {
if (isUpgradableCycle()) if (isUpgradableCycle())
UpgradedCycle+=0.2f; UpgradedCycle += 0.2f;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return Tilesid.values(); return Tilesid.values();
} }
@ -146,15 +141,19 @@ public class Positiver_III extends Transmuter {
} }
public OrderedMap<Vector2, Integer> getTilesidrotated() { public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>(); OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys(); Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){ while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
double delta=key.len(); double delta = key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2; double alpha = key.angleRad() + this.getRotation().ordinal()
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key)); * Math.PI / 2;
} newTiles.put(
return newTiles; new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
} }
public boolean isActivable() { public boolean isActivable() {
@ -162,7 +161,7 @@ public class Positiver_III extends Transmuter {
} }
public int getMaxActivationLevel() { public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle); return ActivationLevel = (int) (10 * this.UpgradedCycle);
} }
public int getActivationLevel() { public int getActivationLevel() {
@ -174,7 +173,7 @@ public class Positiver_III extends Transmuter {
public boolean getActivation() { public boolean getActivation() {
if (this.Activable) if (this.Activable)
return ActivationLevel>0; return ActivationLevel > 0;
else else
return true; return true;
} }
@ -196,11 +195,11 @@ public class Positiver_III extends Transmuter {
} }
public boolean isUpgradable() { public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed(); return this.Upgrade != null && this.Upgrade.isShowed();
} }
public boolean isUnlockable() { public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed(); return this.Unlock != null && this.Unlock.isShowed();
} }
public boolean isShowed() { public boolean isShowed() {
@ -208,63 +207,63 @@ public class Positiver_III extends Transmuter {
} }
public void SetShowed(boolean value) { public void SetShowed(boolean value) {
this.showed=value; this.showed = value;
} }
public boolean isUpgradableTemp() { public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3; return CanUpgradeTemp && getUpgradeTemp() < 3;
} }
public boolean isUpgradableCycle() { public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3; return CanUpgradeCycle && getUpgradeCycle() < 3;
} }
public boolean isUpgradableRayon() { public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3; return CanUpgradeRayon && getUpgradeRayon() < 3;
} }
public boolean isUpgradableNrj() { public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3; return CanUpgradeNrj && getUpgradeNrj() < 3;
} }
public int getUpgradeTemp() { public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f)); return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
} }
public int getUpgradeCycle() { public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f)); return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
} }
public int getUpgradeRayon() { public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f)); return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
} }
public int getUpgradeNrj() { public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f)); return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
} }
public float getUsedTemp() { public float getUsedTemp() {
return UsedTemp*UpgradedTemp; return UsedTemp * UpgradedTemp;
} }
public float getUsedRayon() { public float getUsedRayon() {
return UsedRayon*UpgradedRayon; return UsedRayon * UpgradedRayon;
} }
public float getUsedNrj() { public float getUsedNrj() {
return UsedNrj*UpgradedNrj; return UsedNrj * UpgradedNrj;
} }
public float getTurnTemp() { public float getTurnTemp() {
return TurnTemp*UpgradedTemp; return TurnTemp * UpgradedTemp;
} }
public float getTurnRayon() { public float getTurnRayon() {
return TurnRayon*UpgradedRayon; return TurnRayon * UpgradedRayon;
} }
public float getTurnNrj() { public float getTurnNrj() {
return TurnNrj*UpgradedNrj; return TurnNrj * UpgradedNrj;
} }
public Transmuter getUpgrade() { public Transmuter getUpgrade() {

View File

@ -1,26 +1,32 @@
package fr.evolving.automata; package fr.evolving.automata;
import java.io.Serializable; 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.math.Vector2;
import com.badlogic.gdx.utils.ObjectMap.Entries; import com.badlogic.gdx.utils.ObjectMap.Entries;
import com.badlogic.gdx.utils.ObjectMap.Entry; import com.badlogic.gdx.utils.ObjectMap.Entry;
import com.badlogic.gdx.utils.ObjectMap.Values; import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap; import com.badlogic.gdx.utils.OrderedMap;
public abstract class Transmuter implements Cloneable,Serializable { public abstract class Transmuter implements Cloneable, Serializable {
public enum CaseType{Rien,Cuivre_seul,Fibre_seul,Cuivre,Fibre,Tout,Nimporte}; public enum CaseType {
public enum Class{Structure,Charge,Direction,Filtrage,Synthese,Detection,Divers,Scenario}; Rien, Cuivre_seul, Fibre_seul, Cuivre, Fibre, Tout, Nimporte
public enum Angular{A00,A90,A180,A270}; };
public enum Class {
Structure, Charge, Direction, Filtrage, Synthese, Detection, Divers, Scenario
};
public enum Angular {
A00, A90, A180, A270
};
protected Level level; protected Level level;
protected Angular Rotation; protected Angular Rotation;
public Transmuter(Level level) { public Transmuter(Level level) {
this.level=level; this.level = level;
this.Rotation=Angular.A00; this.Rotation = Angular.A00;
} }
public String getName() { public String getName() {
@ -63,7 +69,7 @@ public abstract class Transmuter implements Cloneable,Serializable {
} }
public boolean isTransmuter(String Name) { public boolean isTransmuter(String Name) {
return Name.equals(this.getName()); return Name.equals(this.getName());
} }
public CaseType getTilestype(int order) { public CaseType getTilestype(int order) {
@ -74,7 +80,7 @@ public abstract class Transmuter implements Cloneable,Serializable {
return null; return null;
} }
public Values<Integer> getTilesid() { public Values<Integer> getTilesid() {
return null; return null;
} }
@ -190,18 +196,60 @@ public abstract class Transmuter implements Cloneable,Serializable {
} }
public String getInformations() { public String getInformations() {
OrderedMap<Vector2, Integer> tiles=this.getTilesidrotated(); OrderedMap<Vector2, Integer> tiles = this.getTilesidrotated();
Entries<Vector2, Integer> iterator=tiles.iterator(); Entries<Vector2, Integer> iterator = tiles.iterator();
String result; 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:"
Values<Integer> allTiles=this.getTilesid().iterator(); + this.getName()
while(allTiles.hasNext()) + "\nClass:"
result+=String.valueOf(allTiles.next())+" "; + this.getaClass()
while(iterator.hasNext()){ + " Rotation:"
Entry<Vector2, Integer> all = iterator.next(); + this.getRotation()
result+="\ncoords:" + all.key.x+","+all.key.y + " type: " + this.getTilestype(tiles.keys().toArray().indexOf(all.key, false)) +" id:"+all.value; + "\nPrice:"
} + this.getPrice()
result+="\n**********************************"; + " 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 += "\n**********************************";
return result; return result;
} }
@ -211,14 +259,14 @@ public abstract class Transmuter implements Cloneable,Serializable {
} }
public void setRotation(Angular rotation) { public void setRotation(Angular rotation) {
this.Rotation=rotation; this.Rotation = rotation;
} }
public Object clone() { public Object clone() {
Object o = null; Object o = null;
try { try {
o = super.clone(); o = super.clone();
} catch(CloneNotSupportedException cnse) { } catch (CloneNotSupportedException cnse) {
cnse.printStackTrace(System.err); cnse.printStackTrace(System.err);
} }
return o; return o;

View File

@ -7,25 +7,27 @@ import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter; import fr.evolving.automata.Transmuter;
public abstract class Base { public abstract class Base {
public enum datatype{statdata,userdata,gamedata} public enum datatype {
statdata, userdata, gamedata
}
public Base(datatype model,String param) { public Base(datatype model, String param) {
} }
public Base() { public Base() {
} }
public String getParam() { public String getParam() {
return null; return null;
} }
//Gestion type Gamebase // Gestion type Gamebase
public Array<String> getworlds() { public Array<String> getworlds() {
return null; return null;
} }
public Array<Level> getworld(String description) { public Array<Level> getworld(String description) {
return null; return null;
} }
@ -37,61 +39,60 @@ public abstract class Base {
return false; return false;
} }
//Gestion type Userbase // Gestion type Userbase
public boolean getlevellock(int user,int level){ public boolean getlevellock(int user, int level) {
return false; return false;
} }
public boolean setlevelunlock(int user,int level){ public boolean setlevelunlock(int user, int level) {
return false; return false;
} }
public Array<Transmuter> getTransmuters(int user){ public Array<Transmuter> getTransmuters(int user) {
return null; return null;
} }
public boolean setTransmuters(int user,Array<Transmuter> transmuters){ public boolean setTransmuters(int user, Array<Transmuter> transmuters) {
return false; return false;
} }
public int getResearchpoint(int user){ public int getResearchpoint(int user) {
return 0; return 0;
} }
public boolean setResearchpoint(int user, int point){ public boolean setResearchpoint(int user, int point) {
return false; return false;
} }
public Grid getGrid(int user,int level, int place){ public Grid getGrid(int user, int level, int place) {
return null; return null;
} }
public Grid getGrid(int user,int level, String tag){ public Grid getGrid(int user, int level, String tag) {
return null; return null;
} }
public boolean setGrid(int user,int level, String tag, Grid data){ public boolean setGrid(int user, int level, String tag, Grid data) {
return false; return false;
} }
public boolean setGrid(int user,int level, Grid data){ public boolean setGrid(int user, int level, Grid data) {
return false; return false;
} }
public Array<String> getGrids(int user, int level){ public Array<String> getGrids(int user, int level) {
return null; return null;
} }
//Gestion type Stat // Gestion type Stat
// Commun
//Commun public boolean Eraseall(datatype base) {
public boolean Eraseall(datatype base){
return false; return false;
} }
public static boolean isHandling(datatype base){ public static boolean isHandling(datatype base) {
return false; return false;
} }
@ -102,6 +103,4 @@ public abstract class Base {
return ""; return "";
} }
} }

View File

@ -13,33 +13,33 @@ public class DatabaseManager {
return bases[model.ordinal()]; return bases[model.ordinal()];
} }
public Base user(){ public Base user() {
return bases[Base.datatype.userdata.ordinal()]; return bases[Base.datatype.userdata.ordinal()];
} }
public Base stat(){ public Base stat() {
return bases[Base.datatype.statdata.ordinal()]; return bases[Base.datatype.statdata.ordinal()];
} }
public Base game(){ public Base game() {
return bases[Base.datatype.gamedata.ordinal()]; return bases[Base.datatype.gamedata.ordinal()];
} }
public boolean verifyall() { public boolean verifyall() {
return (bases[0]!=null && bases[1]!=null && bases[2]!=null); return (bases[0] != null && bases[1] != null && bases[2] != null);
} }
public DatabaseManager(){ public DatabaseManager() {
bases=new Base[3]; bases = new Base[3];
old=new String[3]; old = new String[3];
backends=new Array<Class<?>>(); backends = new Array<Class<?>>();
} }
public void CloseAll() { public void CloseAll() {
for(int i=0;i<3;i++) for (int i = 0; i < 3; i++)
if (bases[i]!=null) { if (bases[i] != null) {
bases[i].Close(); bases[i].Close();
bases[i]=null; bases[i] = null;
} }
} }
@ -48,58 +48,57 @@ public class DatabaseManager {
} }
public boolean Attach(Base.datatype model, String Url) { public boolean Attach(Base.datatype model, String Url) {
if (bases[model.ordinal()]!=null || model==null || Url==null) if (bases[model.ordinal()] != null || model == null || Url == null)
return false; return false;
Base backend=getBackend(model,Url); Base backend = getBackend(model, Url);
if (backend!=null) { if (backend != null) {
bases[model.ordinal()]=backend; bases[model.ordinal()] = backend;
old[model.ordinal()]=Url; old[model.ordinal()] = Url;
return true; return true;
} } else {
else bases[model.ordinal()] = null;
{ old[model.ordinal()] = null;
bases[model.ordinal()]=null;
old[model.ordinal()]=null;
return false; return false;
} }
} }
public Base getBackend(Base.datatype model, String Url) { public Base getBackend(Base.datatype model, String Url) {
String Type=Url.split(":")[0]; String Type = Url.split(":")[0];
Class[] cArg = new Class[2]; Class[] cArg = new Class[2];
cArg[0] = Base.datatype.class; cArg[0] = Base.datatype.class;
cArg[1] = String.class; cArg[1] = String.class;
for(Class<?> classe:backends) { for (Class<?> classe : backends) {
Base back; Base back;
try { try {
back = (Base) classe.newInstance(); back = (Base) classe.newInstance();
if (back.getprefix().equals(Type)) { if (back.getprefix().equals(Type)) {
back = (Base) classe.getDeclaredConstructor(cArg).newInstance(model,Url); back = (Base) classe.getDeclaredConstructor(cArg)
return back; .newInstance(model, Url);
} return back;
} catch (InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
} catch (InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
return null; return null;
} }
public boolean isBackend(Base.datatype model, String Url) { public boolean isBackend(Base.datatype model, String Url) {
String Type=Url.split(":")[0]; String Type = Url.split(":")[0];
for(Class<?> classe:backends) { for (Class<?> classe : backends) {
Base back; Base back;
try { try {
back = (Base) classe.newInstance(); back = (Base) classe.newInstance();
if (back.getprefix().equals(Type)) if (back.getprefix().equals(Type))
return true; return true;
} catch (InstantiationException | IllegalAccessException } catch (InstantiationException | IllegalAccessException
| IllegalArgumentException | SecurityException e) { | IllegalArgumentException | SecurityException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
return false; return false;
} }

View File

@ -2,17 +2,9 @@ package fr.evolving.database;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.ObjectOutputStream; 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.Gdx;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.sql.Database; 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.Array;
import com.badlogic.gdx.utils.Base64Coder; import com.badlogic.gdx.utils.Base64Coder;
import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Grid; import fr.evolving.automata.Grid;
import fr.evolving.automata.Level; import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter; import fr.evolving.automata.Transmuter;
import fr.evolving.database.Base.datatype;
public class LocalBase extends Base { public class LocalBase extends Base {
private static Database dbHandler; private static Database dbHandler;
@ -34,7 +24,7 @@ public class LocalBase extends Base {
private String creation; private String creation;
private String param; private String param;
//Contructeur de la base de donnée // Contructeur de la base de donnée
public String getParam() { public String getParam() {
return this.param; return this.param;
@ -43,111 +33,115 @@ public class LocalBase extends Base {
public LocalBase() { public LocalBase() {
} }
public LocalBase(datatype model,String param) { public LocalBase(datatype model, String param) {
super(model,param); super(model, param);
String[] params=param.split(":"); String[] params = param.split(":");
this.param=param; this.param = param;
if (params.length>1) if (params.length > 1)
databasename=params[1]; databasename = params[1];
switch(Gdx.app.getType()) { switch (Gdx.app.getType()) {
case Android: case Android:
try { 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);
Gdx.app.log("Base", "Copie de la base de donnee android"); if (!newbase.exists()) {
byte[] ByteSource = Gdx.files.internal("bases/"+databasename).readBytes(); Gdx.app.log("Base", "Copie de la base de donnee android");
FileOutputStream destination = new FileOutputStream("/data/data/fr.evolving.game.android/databases/"+databasename); Gdx.files.internal("bases/" + databasename).copyTo(newbase);
destination.write(ByteSource);
destination.close();
} }
} catch (IOException e1) { } catch (Exception e1) {
// TODO Auto-generated catch block Gdx.app.error("Base", "Erreur de copie");
e1.printStackTrace();
} }
break; break;
case Desktop: case Desktop:
Gdx.app.log("Base", "Copie de la base de donnee desktop"); Gdx.app.log("Base", "Copie de la base de donnee desktop");
FileHandle newbase=Gdx.files.local(databasename); FileHandle newbase = Gdx.files.local(databasename);
try { try {
if (!newbase.exists()) if (!newbase.exists())
Gdx.files.internal("bases/"+databasename).copyTo(newbase); Gdx.files.internal("bases/" + databasename).copyTo(newbase);
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); Gdx.app.error("Base", "Erreur de copie");
} }
break; break;
} }
if (dbHandler!=null) if (dbHandler != null)
Gdx.app.log("Local", "Reprise de la base '"+databasename+"', table:"+model.toString()); Gdx.app.log("Local", "Reprise de la base '" + databasename
else + "', table:" + model.toString());
{ else {
Gdx.app.log("Local", "Utilisation de la base '"+databasename+"', table:"+model.toString()); Gdx.app.log("Local", "Utilisation de la base '" + databasename
dbHandler = DatabaseFactory.getNewDatabase(databasename,1, null, null); + "', table:" + model.toString());
dbHandler = DatabaseFactory.getNewDatabase(databasename, 1, null,
null);
dbHandler.setupDatabase(); dbHandler.setupDatabase();
try { try {
dbHandler.openOrCreateDatabase(); dbHandler.openOrCreateDatabase();
} } catch (SQLiteGdxException e) {
catch (SQLiteGdxException e) {
e.printStackTrace(); e.printStackTrace();
Gdx.app.log("Local", "Erreur à l'ouverture de la base"); Gdx.app.log("Local", "Erreur à l'ouverture de la base");
} }
} }
try { try {
if (model==datatype.statdata) if (model == datatype.statdata)
creation = "create table if not exists stat (id integer)"; creation = "create table if not exists stat (id integer)";
else if (model==datatype.userdata) { 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
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));"); .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 transmuters(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, object TEXT, PRIMARY KEY(user));"); dbHandler
dbHandler.execSQL("CREATE TABLE if not exists research(date DATETIME DEFAULT CURRENT_TIMESTAMP, user INTEGER NOT NULL, value INT, PRIMARY KEY(user));"); .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
else .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 worlds(date DATETIME DEFAULT CURRENT_TIMESTAMP, desc TEXT NOT NULL, object TEXT, PRIMARY KEY(desc));"); 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) { } catch (SQLiteGdxException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
//Gestion model type gamedata // Gestion model type gamedata
public Array<String> getworlds() { public Array<String> getworlds() {
DatabaseCursor cursor=null; DatabaseCursor cursor = null;
try { try {
cursor = dbHandler.rawQuery("select desc,date from worlds;"); cursor = dbHandler.rawQuery("select desc,date from worlds;");
} catch (SQLiteGdxException e) { } catch (SQLiteGdxException e) {
return null; return null;
} }
Array<String> returnvalue=new Array<String>(); Array<String> returnvalue = new Array<String>();
while (cursor.next()) while (cursor.next())
returnvalue.add(cursor.getString(0)); returnvalue.add(cursor.getString(0));
return returnvalue; return returnvalue;
} }
public Array<Level> getworld(String description) { public Array<Level> getworld(String description) {
DatabaseCursor cursor=null; DatabaseCursor cursor = null;
try { try {
cursor = dbHandler.rawQuery("select object from worlds where desc='"+description+"';"); cursor = dbHandler
.rawQuery("select object from worlds where desc='"
+ description + "';");
} catch (SQLiteGdxException e) { } catch (SQLiteGdxException e) {
return null; return null;
} }
Level[] mc=null; Level[] mc = null;
if (cursor.next()) if (cursor.next())
try { try {
byte[] bytes = Base64Coder.decodeLines(cursor.getString(0)); byte[] bytes = Base64Coder.decodeLines(cursor.getString(0));
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ins = new ObjectInputStream(bais); ObjectInputStream ins = new ObjectInputStream(bais);
mc=(Level[]) ins.readObject(); mc = (Level[]) ins.readObject();
ins.close(); ins.close();
return new Array<Level>(mc); return new Array<Level>(mc);
} catch (Exception e) {
e.printStackTrace();
} }
catch (Exception e) {
e.printStackTrace();
}
return null; return null;
} }
public boolean deleteworld(String description) { public boolean deleteworld(String description) {
try { try {
dbHandler.rawQuery("delete from worlds where desc='"+description+"';"); dbHandler.rawQuery("delete from worlds where desc='" + description
+ "';");
} catch (SQLiteGdxException e) { } catch (SQLiteGdxException e) {
return false; return false;
} }
@ -165,60 +159,66 @@ public class LocalBase extends Base {
bos.close(); bos.close();
byte[] bytes = bos.toByteArray(); byte[] bytes = bos.toByteArray();
encoded = Base64Coder.encodeLines(bytes); 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) { } catch (Exception e) {
return false; return false;
} }
return true; return true;
} }
//Gestion de données type userdata // Gestion de données type userdata
public boolean getlevellock(int user,int level) { public boolean getlevellock(int user, int level) {
DatabaseCursor cursor=null; DatabaseCursor cursor = null;
try { 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) { } catch (SQLiteGdxException e) {
return false; return false;
} }
if (cursor.next()) if (cursor.next())
return true; return true;
else return false; else
return false;
} }
public boolean setlevelunlock(int user,int level){ public boolean setlevelunlock(int user, int level) {
try { try {
dbHandler.rawQuery("insert into locks (user,level) values ("+user+","+level+");"); dbHandler.rawQuery("insert into locks (user,level) values (" + user
+ "," + level + ");");
} catch (SQLiteGdxException e) { } catch (SQLiteGdxException e) {
return false; return false;
} }
return true; return true;
} }
public Array<Transmuter> getTransmuters(int user){ public Array<Transmuter> getTransmuters(int user) {
DatabaseCursor cursor=null; DatabaseCursor cursor = null;
try { try {
cursor = dbHandler.rawQuery("select object from transmuters where user="+user+";"); cursor = dbHandler
.rawQuery("select object from transmuters where user="
+ user + ";");
} catch (SQLiteGdxException e) { } catch (SQLiteGdxException e) {
return null; return null;
} }
Transmuter[] mc=null; Transmuter[] mc = null;
if (cursor.next()) if (cursor.next())
try { try {
byte[] bytes = DatatypeConverter.parseBase64Binary(cursor.getString(0)); byte[] bytes = Base64Coder.decodeLines(cursor
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); .getString(0));
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ins = new ObjectInputStream(bais); ObjectInputStream ins = new ObjectInputStream(bais);
mc=(Transmuter[]) ins.readObject(); mc = (Transmuter[]) ins.readObject();
ins.close(); ins.close();
return new Array<Transmuter>(mc); return new Array<Transmuter>(mc);
} catch (Exception e) {
e.printStackTrace();
} }
catch (Exception e) {
e.printStackTrace();
}
return null; return null;
} }
public boolean setTransmuters(int user,Array<Transmuter> transmuters){ public boolean setTransmuters(int user, Array<Transmuter> transmuters) {
String encoded = ""; String encoded = "";
try { try {
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
@ -228,84 +228,93 @@ public class LocalBase extends Base {
oos.close(); oos.close();
bos.close(); bos.close();
byte[] bytes = bos.toByteArray(); byte[] bytes = bos.toByteArray();
encoded = DatatypeConverter.printBase64Binary(bytes); encoded = Base64Coder.encodeLines(bytes);
dbHandler.rawQuery("replace into transmuters (user,object) values ("+user+",'"+encoded+"');"); dbHandler
.rawQuery("replace into transmuters (user,object) values ("
+ user + ",'" + encoded + "');");
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }
return true; return true;
} }
public int getResearchpoint(int user) {
public int getResearchpoint(int user){ DatabaseCursor cursor = null;
DatabaseCursor cursor=null;
try { try {
cursor = dbHandler.rawQuery("select value from research where user="+user+";"); cursor = dbHandler
.rawQuery("select value from research where user=" + user
+ ";");
} catch (SQLiteGdxException e) { } catch (SQLiteGdxException e) {
return 0; return 0;
} }
if (cursor.next()) if (cursor.next())
return cursor.getInt(0); return cursor.getInt(0);
else else
return 0; return 0;
} }
public boolean setResearchpoint(int user, int point){ public boolean setResearchpoint(int user, int point) {
try { try {
dbHandler.rawQuery("replace into research (user,value) values ("+user+","+point+");"); dbHandler.rawQuery("replace into research (user,value) values ("
+ user + "," + point + ");");
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }
return true; return true;
} }
public Grid getGrid(int user,int level,int place){ public Grid getGrid(int user, int level, int place) {
DatabaseCursor cursor=null; DatabaseCursor cursor = null;
try { 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) { } catch (SQLiteGdxException e) {
return null; return null;
} }
Grid mc=null; Grid mc = null;
if (cursor.next()) if (cursor.next())
try { try {
byte[] bytes = DatatypeConverter.parseBase64Binary(cursor.getString(0)); byte[] bytes = Base64Coder.decodeLines(cursor
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); .getString(0));
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ins = new ObjectInputStream(bais); ObjectInputStream ins = new ObjectInputStream(bais);
mc=(Grid) ins.readObject(); mc = (Grid) ins.readObject();
ins.close(); ins.close();
return mc; return mc;
} catch (Exception e) {
e.printStackTrace();
} }
catch (Exception e) {
e.printStackTrace();
}
return null; return null;
} }
public Grid getGrid(int user,int level,String tag){ public Grid getGrid(int user, int level, String tag) {
DatabaseCursor cursor=null; DatabaseCursor cursor = null;
try { 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) { } catch (SQLiteGdxException e) {
return null; return null;
} }
Grid mc=null; Grid mc = null;
if (cursor.next()) if (cursor.next())
try { try {
byte[] bytes = DatatypeConverter.parseBase64Binary(cursor.getString(0)); byte[] bytes = Base64Coder.decodeLines(cursor
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); .getString(0));
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream ins = new ObjectInputStream(bais); ObjectInputStream ins = new ObjectInputStream(bais);
mc=(Grid) ins.readObject(); mc = (Grid) ins.readObject();
ins.close(); ins.close();
return mc; return mc;
} catch (Exception e) {
e.printStackTrace();
} }
catch (Exception e) {
e.printStackTrace();
}
return null; return null;
} }
public boolean setGrid(int user,int level, Grid data){ public boolean setGrid(int user, int level, Grid data) {
String encoded = ""; String encoded = "";
try { try {
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
@ -315,15 +324,16 @@ public class LocalBase extends Base {
oos.close(); oos.close();
bos.close(); bos.close();
byte[] bytes = bos.toByteArray(); byte[] bytes = bos.toByteArray();
encoded = DatatypeConverter.printBase64Binary(bytes); encoded = Base64Coder.encodeLines(bytes);
dbHandler.rawQuery("insert into grids (user,level,object) values ("+user+","+level+",'"+encoded+"');"); dbHandler.rawQuery("insert into grids (user,level,object) values ("
+ user + "," + level + ",'" + encoded + "');");
} catch (Exception e) { } catch (Exception e) {
return false; return false;
} }
return true; return true;
} }
public boolean setGrid(int user,int level, String tag, Grid data){ public boolean setGrid(int user, int level, String tag, Grid data) {
String encoded = ""; String encoded = "";
try { try {
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
@ -333,37 +343,48 @@ public class LocalBase extends Base {
oos.close(); oos.close();
bos.close(); bos.close();
byte[] bytes = bos.toByteArray(); byte[] bytes = bos.toByteArray();
encoded = DatatypeConverter.printBase64Binary(bytes); encoded = Base64Coder.encodeLines(bytes);
try { try {
dbHandler.rawQuery("delete from grids where user="+user+" and level="+level+" and tag='"+tag+"';"); dbHandler.rawQuery("delete from grids where user=" + user
} catch (Exception e) {} + " and level=" + level + " and tag='" + tag + "';");
dbHandler.rawQuery("insert into grids (user,level,tag,object) values ("+user+","+level+",'"+tag+"','"+encoded+"');"); } catch (Exception e) {
}
dbHandler
.rawQuery("insert into grids (user,level,tag,object) values ("
+ user
+ ","
+ level
+ ",'"
+ tag
+ "','"
+ encoded
+ "');");
return true; return true;
} } catch (Exception e) {
catch (Exception e) {
return false; return false;
} }
} }
public Array<String> getGrids(int user, int level){ public Array<String> getGrids(int user, int level) {
DatabaseCursor cursor=null; DatabaseCursor cursor = null;
try { 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) { } catch (SQLiteGdxException e) {
return null; return null;
} }
Array<String> returnvalue=new Array<String>(); Array<String> returnvalue = new Array<String>();
while (cursor.next()) while (cursor.next())
returnvalue.add(cursor.getString(0)); returnvalue.add(cursor.getString(0));
return returnvalue; return returnvalue;
} }
//Gestion type Stat // Gestion type Stat
// Commun
//Commun public boolean Eraseall(datatype base) {
public boolean Eraseall(datatype base){
try { try {
dbHandler.execSQL("drop table if exists stat;"); dbHandler.execSQL("drop table if exists stat;");
dbHandler.execSQL("drop table if exists locks;"); dbHandler.execSQL("drop table if exists locks;");
@ -378,9 +399,9 @@ public class LocalBase extends Base {
public void Close() { public void Close() {
try { try {
if (dbHandler!=null) { if (dbHandler != null) {
dbHandler.closeDatabase(); dbHandler.closeDatabase();
dbHandler=null; dbHandler = null;
} }
} catch (SQLiteGdxException e) { } catch (SQLiteGdxException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@ -392,7 +413,7 @@ public class LocalBase extends Base {
return "local"; return "local";
} }
public static boolean isHandling(datatype base){ public static boolean isHandling(datatype base) {
return true; return true;
} }

View File

@ -1,15 +1,9 @@
package fr.evolving.database; package fr.evolving.database;
import com.badlogic.gdx.Gdx; public class SqlBase extends Base {
import com.badlogic.gdx.sql.DatabaseFactory;
import com.badlogic.gdx.sql.SQLiteGdxException;
import fr.evolving.database.Base.datatype; public SqlBase(datatype model, String param) {
super(model, param);
public class SqlBase extends Base{
public SqlBase(datatype model,String param) {
super(model,param);
} }
public SqlBase() { public SqlBase() {
@ -19,8 +13,8 @@ public class SqlBase extends Base{
return "mysql"; return "mysql";
} }
public static boolean isHandling(datatype base){ public static boolean isHandling(datatype base) {
if (base==datatype.statdata) if (base == datatype.statdata)
return false; return false;
else else
return true; return true;

View File

@ -3,123 +3,130 @@ package fr.evolving.effects;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20; 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.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.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import fr.evolving.assets.AssetLoader; import fr.evolving.assets.AssetLoader;
public class Laser { public class Laser {
public float i=0; public float i = 0;
TextureRegion overlaymiddle,middle,overlay; TextureRegion overlaymiddle, middle, overlay;
public Laser() { public Laser() {
i=0; i = 0;
overlaymiddle=AssetLoader.Skin_level.getAtlas().findRegion("overlay-middle"); overlaymiddle = AssetLoader.Skin_level.getAtlas().findRegion(
middle=AssetLoader.Skin_level.getAtlas().findRegion("middle"); "overlay-middle");
overlay=AssetLoader.Skin_level.getAtlas().findRegion("overlay"); 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 x1=xx1+26; float maxwidth, float power, boolean active, Color colorsrc,
float y1=yy1+20; Color colordst) {
float x2=xx2+26; float x1 = xx1 + 26;
float y2=yy2+20; float y1 = yy1 + 20;
Vector2 vector1=new Vector2(x1, y1); float x2 = xx2 + 26;
Vector2 vector2=new Vector2(x2, y2); float y2 = yy2 + 20;
Vector2 vector1 = new Vector2(x1, y1);
Vector2 vector2 = new Vector2(x2, y2);
Vector2 vectorall = vector2.sub(vector1); Vector2 vectorall = vector2.sub(vector1);
final int inc=16; final int inc = 16;
Vector2 vectoradd = vectorall.cpy().setLength(inc); Vector2 vectoradd = vectorall.cpy().setLength(inc);
Vector2 vectoraddit = vectorall.cpy().setLength(64); Vector2 vectoraddit = vectorall.cpy().setLength(64);
Laser.begin(); Laser.begin();
Laser.setColor(colorsrc); Laser.setColor(colorsrc);
Laser.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE); 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(overlaymiddle, x1, y1, 32, 0, 64, vectorall.len(), 1f, 1f,
Laser.draw(middle,x1,y1,32,0,64,vectorall.len(),1f,1f,vectorall.angle()+270); vectorall.angle() + 270);
Laser.setColor(new Color(1f,1f,1f,1f)); Laser.draw(middle, x1, y1, 32, 0, 64, vectorall.len(), 1f, 1f,
for(int j=0;j<(vectorall.len()-vectoradd.cpy().setLength(i*inc).len())/64-1;j++) vectorall.angle() + 270);
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.setColor(new Color(1f, 1f, 1f, 1f));
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(); 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 x1=xx1+58; float xx2, float yy2, float maxwidth, float power, boolean active,
float y1=yy1+20; Color colorsrc, Color colordst) {
float x2=xx2+58; float x1 = xx1 + 58;
float y2=yy2+20; float y1 = yy1 + 20;
float x2 = xx2 + 58;
float y2 = yy2 + 20;
Laser.begin(ShapeType.Filled); Laser.begin(ShapeType.Filled);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
if (active) { if (active) {
Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1)); Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1));
float length = vectorall.len(); float length = vectorall.len();
float size=20; float size = 20;
Vector2 vectoradd = vectorall.scl(size/length); Vector2 vectoradd = vectorall.scl(size / length);
float adding=0; 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);
float width=(float)(maxwidth-Math.random()*2); while (width >= 0) {
while(width >= 0) adding = (width * power / maxwidth);
{ Color Acolor = colorsrc.cpy().lerp(colordst.cpy(),
adding=(width*power/maxwidth); (i / (length / size)));
Color Acolor=colorsrc.cpy().lerp(colordst.cpy(), (i/(length/size))); Laser.setColor(Acolor.add(adding, adding, adding, 0.5f));
Laser.setColor(Acolor.add(adding,adding,adding,0.5f)); if (Math.random() > 0.4)
if (Math.random()>0.4) Laser.rectLine(x1 + i*vectoradd.x, y1 + i*vectoradd.y, x1+ (i+1)*vectoradd.x, y1+(i+1)* vectoradd.y, width); Laser.rectLine(x1 + i * vectoradd.x, y1 + i
width=width-1; * 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);
{
Color Acolor=new Color(0.5f,0.5f,0.5f,1f);
Laser.setColor(Acolor); Laser.setColor(Acolor);
Laser.rectLine(x1, y1 , x2, y2, 2); Laser.rectLine(x1, y1, x2, y2, 2);
} }
Laser.end(); Laser.end();
Gdx.gl.glDisable(GL20.GL_BLEND); Gdx.gl.glDisable(GL20.GL_BLEND);
} }
public void drawold(ShapeRenderer Laser, float xx1, float yy1, float xx2,
public void drawold(ShapeRenderer Laser,float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { float yy2, float maxwidth, float power, boolean active,
float x1=xx1+20; Color colorsrc, Color colordst) {
float y1=yy1+20; float x1 = xx1 + 20;
float x2=xx2+20; float y1 = yy1 + 20;
float y2=yy2+20; float x2 = xx2 + 20;
float adding=0; float y2 = yy2 + 20;
float adding = 0;
Laser.begin(ShapeType.Point); Laser.begin(ShapeType.Point);
Vector2 vec2 = new Vector2(x2, y2).sub(new Vector2(x1, y1)); Vector2 vec2 = new Vector2(x2, y2).sub(new Vector2(x1, y1));
float length = vec2.len(); float length = vec2.len();
float awidth=0,width = 0; float awidth = 0, width = 0;
float size = 0; float size = 0;
for(int i = 0; i < length; i += 1) { for (int i = 0; i < length; i += 1) {
if ((i % 5)==0) if ((i % 5) == 0)
awidth=(float)(Math.random()*maxwidth/2); awidth = (float) (Math.random() * maxwidth / 2);
width=awidth; width = awidth;
if (i % ((int)width*20+1)==0) if (i % ((int) width * 20 + 1) == 0)
size=(float)(Math.random()); size = (float) (Math.random());
vec2.clamp(length - i, length - i); vec2.clamp(length - i, length - i);
while(width >= 0) { while (width >= 0) {
adding=(width*power/maxwidth); adding = (width * power / maxwidth);
Color Acolor=colordst.cpy().lerp(colorsrc.cpy(), (i/length)); Color Acolor = colordst.cpy()
Laser.setColor(Acolor.add(adding,adding,adding,1f)); .lerp(colorsrc.cpy(), (i / length));
if (size>0.4f) { Laser.setColor(Acolor.add(adding, adding, adding, 1f));
Laser.point(x1 + vec2.x-width/2, y1 + vec2.y+width/2, 0); if (size > 0.4f) {
Laser.point(x1 + vec2.x+width/2, y1 + vec2.y-width/2, 0); Laser.point(x1 + vec2.x - width / 2, y1 + vec2.y + width
/ 2, 0);
Laser.point(x1 + vec2.x + width / 2, y1 + vec2.y - width
/ 2, 0);
} }
width=width-1; width = width - 1;
} }
} }
Laser.end(); Laser.end();
} }
} }

View File

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

View File

@ -1,12 +1,7 @@
package fr.evolving.renderers; package fr.evolving.renderers;
import java.util.List;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20; 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.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
@ -23,42 +18,49 @@ public class GameRenderer {
private float rotation; private float rotation;
public GameRenderer(GameScreen GameScreen) { public GameRenderer(GameScreen GameScreen) {
this.GameScreen=GameScreen; this.GameScreen = GameScreen;
batcher = new SpriteBatch(); batcher = new SpriteBatch();
batcher.setProjectionMatrix(AssetLoader.Camera.combined); batcher.setProjectionMatrix(AssetLoader.Camera.combined);
shapeRenderer = new ShapeRenderer(); shapeRenderer = new ShapeRenderer();
shapeRenderer.setProjectionMatrix(AssetLoader.Camera.combined); shapeRenderer.setProjectionMatrix(AssetLoader.Camera.combined);
oneselection= AssetLoader.Atlas_level.findRegion("circle"); oneselection = AssetLoader.Atlas_level.findRegion("circle");
rotation=0f; rotation = 0f;
} }
public void evolve() { public void evolve() {
rotation+=5; rotation += 5;
} }
public void render(float delta, float runTime,int layer) { public void render(float delta, float runTime, int layer) {
if (layer==0) { if (layer == 0) {
Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
} } else if (layer == 1) {
else if (layer==1) {
batcher.begin(); batcher.begin();
batcher.setColor(0.25f, 0.25f, 0.25f, 1f); 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("barrehaut"), 0.0f,
batcher.draw(AssetLoader.Atlas_level.findRegion("barrecentre"),1480f,AssetLoader.height-785.0f,590f,530.0f); AssetLoader.height - 198.0f, 1920.0f, 200.0f);
batcher.draw(AssetLoader.Atlas_level.findRegion("barrebas"),0.0f,0.0f,1920.0f,170.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) 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(); batcher.end();
} } else if (layer == 2) {
else if (layer==2) {
shapeRenderer.begin(ShapeType.Filled); shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.end(); shapeRenderer.end();
batcher.begin(); batcher.begin();
if (GameScreen.selected!=null) if (GameScreen.selected != null) {
{
batcher.setColor(1f, 0f, 0f, 1f); 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(); batcher.end();
} }

View File

@ -1,20 +1,14 @@
package fr.evolving.renderers; package fr.evolving.renderers;
import java.util.List;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20; 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.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import fr.evolving.UI.Objectives;
import fr.evolving.assets.AssetLoader; import fr.evolving.assets.AssetLoader;
import fr.evolving.effects.Laser; import fr.evolving.effects.Laser;
import fr.evolving.screens.LevelScreen; import fr.evolving.screens.LevelScreen;
@ -33,67 +27,71 @@ public class LevelRenderer {
BitmapFont font; BitmapFont font;
public LevelRenderer(LevelScreen LevelScreen) { public LevelRenderer(LevelScreen LevelScreen) {
this.LevelScreen=LevelScreen; this.LevelScreen = LevelScreen;
this.scrollx=0; this.scrollx = 0;
this.scrolly=0; this.scrolly = 0;
this.dirx=1; this.dirx = 1;
this.diry=1; this.diry = 1;
batcher = new SpriteBatch(); batcher = new SpriteBatch();
batcher2 = new SpriteBatch(); batcher2 = new SpriteBatch();
shapeRenderer = new ShapeRenderer(); shapeRenderer = new ShapeRenderer();
Laser=new Laser(); Laser = new Laser();
AssetLoader.viewport.apply(); AssetLoader.viewport.apply();
font=AssetLoader.Skin_level.getFont("OpenDyslexicAlta-22"); font = AssetLoader.Skin_level.getFont("OpenDyslexicAlta-22");
} }
public void evolve() { public void evolve() {
this.scrollx+=dirx; this.scrollx += dirx;
this.scrolly+=diry; this.scrolly += diry;
if (this.scrollx>1500) if (this.scrollx > 1500)
this.scrolly+=diry; this.scrolly += diry;
if (this.scrollx > 1024) if (this.scrollx > 1024)
this.dirx = -1; this.dirx = -1;
if (this.scrolly > 768) if (this.scrolly > 768)
this.diry = -1; this.diry = -1;
if (this.scrollx < 0) if (this.scrollx < 0)
this.dirx = 1; this.dirx = 1;
if (this.scrolly < 0) if (this.scrolly < 0)
this.diry = 1; this.diry = 1;
Laser.i+=0.3f; Laser.i += 0.3f;
if (Laser.i>10.0f) { if (Laser.i > 10.0f) {
Laser.i=0; Laser.i = 0;
} }
} }
public void render(float delta, float runTime) { public void render(float delta, float runTime) {
Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
if (LevelScreen.world>=0) if (LevelScreen.world >= 0)
font.setColor(AssetLoader.Levelcolors[LevelScreen.world]); font.setColor(AssetLoader.Levelcolors[LevelScreen.world]);
batcher.begin(); batcher.begin();
batcher.setProjectionMatrix(AssetLoader.Camera.combined); batcher.setProjectionMatrix(AssetLoader.Camera.combined);
batcher.setColor(0.25f,0.25f,0.25f,1f); 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,
batcher.setColor(0.7f,0.7f,0.7f,1); this.scrolly / 2, AssetLoader.width, AssetLoader.height);
batcher.draw(AssetLoader.Texture_fond, 0, 0, this.scrollx, this.scrolly, 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.end(); batcher.end();
batcher2.begin(); batcher2.begin();
batcher2.setProjectionMatrix(AssetLoader.Camera.combined); batcher2.setProjectionMatrix(AssetLoader.Camera.combined);
batcher2.setColor(Color.WHITE); batcher2.setColor(Color.WHITE);
Texture_logobig=AssetLoader.Skin_level.getRegion("logo3"); 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) { if (LevelScreen.selected != null) {
font.draw(batcher2, LevelScreen.selected.level.Name, 15, 145); font.draw(batcher2, LevelScreen.selected.level.Name, 15, 145);
if (LevelScreen.selected.level.Tech>0) if (LevelScreen.selected.level.Tech > 0)
font.draw(batcher2, "Recompenses", 1215, AssetLoader.height-15); font.draw(batcher2, "Recompenses", 1215,
if (LevelScreen.selected.level.Cout>0) { AssetLoader.height - 15);
if (LevelScreen.selected.level.Cout > 0) {
font.draw(batcher2, "Ressources", 1215, 145); font.draw(batcher2, "Ressources", 1215, 145);
font.draw(batcher2, "Objectifs", 1215, 295); font.draw(batcher2, "Objectifs", 1215, 295);
} }
if (LevelScreen.selected.level.aWorld>0) if (LevelScreen.selected.level.aWorld > 0)
font.draw(batcher2, "Handicaps", 1215, 605); font.draw(batcher2, "Handicaps", 1215, 605);
font.draw(batcher2, "", 1215, 145); font.draw(batcher2, "", 1215, 145);
} }
@ -103,43 +101,71 @@ public class LevelRenderer {
shapeRenderer.begin(ShapeType.Filled); shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.setProjectionMatrix(AssetLoader.Camera.combined); shapeRenderer.setProjectionMatrix(AssetLoader.Camera.combined);
shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f); shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f);
if (LevelScreen.selected!=null) { if (LevelScreen.selected != null) {
shapeRenderer.rect(10, 10, 1190, 140); shapeRenderer.rect(10, 10, 1190, 140);
if (LevelScreen.selected.level.Cout>0) { if (LevelScreen.selected.level.Cout > 0) {
shapeRenderer.rect(1210, 10, 250, 140); shapeRenderer.rect(1210, 10, 250, 140);
shapeRenderer.rect(1210, 160,250, 140); shapeRenderer.rect(1210, 160, 250, 140);
} }
if (LevelScreen.selected.level.aWorld>0) if (LevelScreen.selected.level.aWorld > 0)
shapeRenderer.rect(1210, 310,250, 300); shapeRenderer.rect(1210, 310, 250, 300);
if (LevelScreen.selected.level.Tech>0) if (LevelScreen.selected.level.Tech > 0)
shapeRenderer.rect(1210, 620,250, AssetLoader.height-630); shapeRenderer.rect(1210, 620, 250, AssetLoader.height - 630);
} }
if (!LevelScreen.MenuSolo.isVisible()) if (!LevelScreen.MenuSolo.isVisible())
shapeRenderer.rect(1470, 10, 440, AssetLoader.height-20); shapeRenderer.rect(1470, 10, 440, AssetLoader.height - 20);
shapeRenderer.end(); shapeRenderer.end();
if (LevelScreen.buttonLevels!=null) if (LevelScreen.buttonLevels != null)
for (int i=0;i<LevelScreen.buttonLevels.length;i++) { for (int i = 0; i < LevelScreen.buttonLevels.length; i++) {
if (LevelScreen.buttonLevels[i]!=null) { if (LevelScreen.buttonLevels[i] != null) {
for (int[] item : LevelScreen.buttonLevels[i].level.Link) for (int[] item : LevelScreen.buttonLevels[i].level.Link) {
{ int found = -1;
int found=-1; for (int j = 0; j < LevelScreen.buttonLevels.length; j++) {
for (int j=0;j<LevelScreen.buttonLevels.length;j++) if ((item.length == 2)
{ && (LevelScreen.buttonLevels[j] != null)
if ((item.length==2) && (LevelScreen.buttonLevels[j]!=null) && (LevelScreen.buttonLevels[j].level.aWorld==item[0]) && (LevelScreen.buttonLevels[j].level.aLevel==item[1])) { && (LevelScreen.buttonLevels[j].level.aWorld == item[0])
found=j; && (LevelScreen.buttonLevels[j].level.aLevel == item[1])) {
break; found = j;
} break;
} }
if (found!=-1) }
{ if (found != -1) {
if (!LevelScreen.logosmall.isChecked()) 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(
else batcher,
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()); 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());
}
}
}
} }
}
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,55 +1,35 @@
package fr.evolving.screens; package fr.evolving.screens;
import java.util.Timer;
import java.util.TimerTask;
import com.badlogic.gdx.Game; import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen; import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage; 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.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.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; 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.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextArea; import com.badlogic.gdx.scenes.scene2d.ui.TextArea;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; 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.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Array; 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.ButtonLevel;
import fr.evolving.UI.Objectives; import fr.evolving.UI.Objectives;
import fr.evolving.UI.ServerList; import fr.evolving.UI.ServerList;
import fr.evolving.UI.WarnDialog; import fr.evolving.UI.WarnDialog;
import fr.evolving.UI.Worldlist; 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.AssetLoader;
import fr.evolving.assets.InitWorlds;
import fr.evolving.assets.Preference; import fr.evolving.assets.Preference;
import fr.evolving.automata.Level; import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
import fr.evolving.database.Base; import fr.evolving.database.Base;
import fr.evolving.database.Base.datatype; import fr.evolving.renderers.LevelRenderer;
import fr.evolving.database.DatabaseManager;
import fr.evolving.database.LocalBase;
import fr.evolving.database.SqlBase;
import fr.evolving.effects.Laser;
public class LevelScreen implements Screen { public class LevelScreen implements Screen {
public ButtonLevel[] buttonLevels; public ButtonLevel[] buttonLevels;
@ -57,51 +37,55 @@ public class LevelScreen implements Screen {
private float runTime; private float runTime;
private Timer ScrollTimer; private Timer ScrollTimer;
private TimerTask ScrollTask; private TimerTask ScrollTask;
private Stage stage; private Stage stage;
private Table table; private Table table;
private WarnDialog dialog; private WarnDialog dialog;
private ImageButton Previous,Next,Exit; private ImageButton Previous, Next, Exit;
public ImageButton logosmall; public ImageButton logosmall;
public Image MenuSolo,MenuMulti,MenuScenario; public Image MenuSolo, MenuMulti, MenuScenario;
private ImageTextButton cout,tech,cycle,temp,rayon,nrj; private ImageTextButton cout, tech, cycle, temp, rayon, nrj;
private TextButton buttonConnect,buttonPlay,buttonStat,buttonSave, buttonApply, buttonPlaythis; private TextButton buttonConnect, buttonPlay, buttonStat, buttonSave,
private ServerList Statdata,Userdata,Gamedata; buttonApply, buttonPlaythis;
private ServerList Statdata, Userdata, Gamedata;
private Worldlist Worlddata; private Worldlist Worlddata;
private Label Statdatalabel, Userdatalabel, Gamedatalabel,Worlddatalabel; private Label Statdatalabel, Userdatalabel, Gamedatalabel, Worlddatalabel;
private Array<Level> thelevels; private Array<Level> thelevels;
private TextArea TextDescriptive; private TextArea TextDescriptive;
public int world; public int world;
private Objectives Victory; private Objectives Victory;
public ButtonLevel selected; public ButtonLevel selected;
public int getMaxWorld() { public int getMaxWorld() {
int max=0; int max = 0;
for (Level level :thelevels) for (Level level : thelevels)
if (level!=null && level.aWorld>max) if (level != null && level.aWorld > max)
max=level.aWorld; max = level.aWorld;
return max; return max;
} }
public void play() { public void play() {
if (!AssetLoader.Datahandler.verifyall()) if (!AssetLoader.Datahandler.verifyall())
Gdx.app.debug(getClass().getSimpleName(),"Pilotes de bases de donnée défaillant."); Gdx.app.debug(getClass().getSimpleName(),
else "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(),
"Chargement des mondes depuis la base.");
try { try {
if (world<0) if (world < 0)
world=0; world = 0;
thelevels=AssetLoader.Datahandler.game().getworld(Preference.prefs.getString("world")); thelevels = AssetLoader.Datahandler.game().getworld(
/*thelevels= InitWorlds.go(); Preference.prefs.getString("world"));
AssetLoader.Datahandler.game().setworld(thelevels,Preference.prefs.getString("world")); */ /*
* thelevels= InitWorlds.go();
* AssetLoader.Datahandler.game().setworld
* (thelevels,Preference.prefs.getString("world"));
*/
loadWorld(world); loadWorld(world);
Previous.setVisible(true); Previous.setVisible(true);
Next.setVisible(true); Next.setVisible(true);
buttonPlay.setVisible(true); buttonPlay.setVisible(true);
TextDescriptive.setVisible(true); TextDescriptive.setVisible(true);
} } catch (Exception e) {
catch (Exception e) {
Previous.setVisible(false); Previous.setVisible(false);
Next.setVisible(false); Next.setVisible(false);
buttonPlay.setVisible(false); buttonPlay.setVisible(false);
@ -111,7 +95,7 @@ public class LevelScreen implements Screen {
} }
public void menu() { public void menu() {
selected=null; selected = null;
cout.setVisible(false); cout.setVisible(false);
tech.setVisible(false); tech.setVisible(false);
cycle.setVisible(false); cycle.setVisible(false);
@ -121,7 +105,7 @@ public class LevelScreen implements Screen {
Previous.setVisible(false); Previous.setVisible(false);
Next.setVisible(false); Next.setVisible(false);
Victory.setVisible(false); Victory.setVisible(false);
Exit.setPosition(1820,AssetLoader.height-100); Exit.setPosition(1820, AssetLoader.height - 100);
buttonPlay.setVisible(false); buttonPlay.setVisible(false);
TextDescriptive.setVisible(false); TextDescriptive.setVisible(false);
MenuSolo.setVisible(true); MenuSolo.setVisible(true);
@ -144,23 +128,29 @@ public class LevelScreen implements Screen {
MenuSolo.setRotation(0); MenuSolo.setRotation(0);
MenuSolo.setScale(1f); MenuSolo.setScale(1f);
MenuSolo.setColor(1f, 1f, 1f, 1f); MenuSolo.setColor(1f, 1f, 1f, 1f);
MenuSolo.setPosition(0, AssetLoader.height*17/20-300); MenuSolo.setPosition(0, AssetLoader.height * 17 / 20 - 300);
MenuMulti.setRotation(0); MenuMulti.setRotation(0);
MenuMulti.setScale(1f); MenuMulti.setScale(1f);
MenuMulti.setColor(1f, 1f, 1f, 1f); MenuMulti.setColor(1f, 1f, 1f, 1f);
MenuMulti.setPosition(0, AssetLoader.height*12/20-300); MenuMulti.setPosition(0, AssetLoader.height * 12 / 20 - 300);
MenuScenario.setRotation(0); MenuScenario.setRotation(0);
MenuScenario.setScale(1f); MenuScenario.setScale(1f);
MenuScenario.setColor(1f, 1f, 1f, 1f); MenuScenario.setColor(1f, 1f, 1f, 1f);
MenuScenario.setPosition(0, AssetLoader.height*7/20-300); 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))); MenuSolo.addAction(Actions.sequence(Actions.moveTo(
MenuMulti.addAction(Actions.sequence(Actions.fadeIn(0.1f),Actions.moveTo((AssetLoader.width-MenuMulti.getWidth())/2, AssetLoader.height*12/20-300, 0.25f))); (AssetLoader.width - MenuSolo.getWidth()) / 2,
MenuScenario.addAction(Actions.sequence(Actions.fadeIn(0.2f),Actions.moveTo((AssetLoader.width-MenuScenario.getWidth())/2, AssetLoader.height*7/20-300, 0.25f))); 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)));
} }
public void initlevel() { public void initlevel() {
selected=null; selected = null;
buttonPlay.setVisible(false); buttonPlay.setVisible(false);
TextDescriptive.setVisible(false); TextDescriptive.setVisible(false);
cout.setVisible(false); cout.setVisible(false);
@ -172,16 +162,16 @@ public class LevelScreen implements Screen {
Previous.setVisible(false); Previous.setVisible(false);
Next.setVisible(false); Next.setVisible(false);
Victory.setVisible(false); Victory.setVisible(false);
if (buttonLevels!=null) if (buttonLevels != null)
for (int j=0;j<10;j++) for (int j = 0; j < 10; j++)
if (buttonLevels[j]!=null) { if (buttonLevels[j] != null) {
buttonLevels[j].remove(); buttonLevels[j].remove();
buttonLevels[j]=null; buttonLevels[j] = null;
} }
} }
public void level() { public void level() {
Exit.setPosition(1110, AssetLoader.height-Exit.getHeight()-5); Exit.setPosition(1110, AssetLoader.height - Exit.getHeight() - 5);
MenuSolo.setVisible(false); MenuSolo.setVisible(false);
MenuMulti.setVisible(false); MenuMulti.setVisible(false);
MenuScenario.setVisible(false); MenuScenario.setVisible(false);
@ -193,8 +183,8 @@ public class LevelScreen implements Screen {
} }
public void SetButtonConnect() { public void SetButtonConnect() {
buttonStat.setColor(1f,1f,1f,1f); buttonStat.setColor(1f, 1f, 1f, 1f);
buttonConnect.setColor(1f,0,0,1f); buttonConnect.setColor(1f, 0, 0, 1f);
Statdata.setVisible(true); Statdata.setVisible(true);
Userdata.setVisible(true); Userdata.setVisible(true);
Gamedata.setVisible(true); Gamedata.setVisible(true);
@ -209,9 +199,9 @@ public class LevelScreen implements Screen {
} }
public void SetButtonStat() { public void SetButtonStat() {
buttonConnect.setColor(1f,1f,1f,1f); buttonConnect.setColor(1f, 1f, 1f, 1f);
buttonStat.setColor(1f,0,0,1f); buttonStat.setColor(1f, 0, 0, 1f);
buttonStat.setColor(1f,0,0,1f); buttonStat.setColor(1f, 0, 0, 1f);
Statdata.setVisible(false); Statdata.setVisible(false);
Userdata.setVisible(false); Userdata.setVisible(false);
Gamedata.setVisible(false); Gamedata.setVisible(false);
@ -226,146 +216,172 @@ public class LevelScreen implements Screen {
} }
public void loadWorld(int aworld) { public void loadWorld(int aworld) {
int i=0; int i = 0;
if (buttonLevels!=null) if (buttonLevels != null)
for (int j=0;j<10;j++) { for (int j = 0; j < 10; j++) {
if (buttonLevels[j]!=null) { if (buttonLevels[j] != null) {
buttonLevels[j].remove(); buttonLevels[j].remove();
buttonLevels[j]=null; buttonLevels[j] = null;
}
} }
}
buttonLevels = null; buttonLevels = null;
buttonLevels = new ButtonLevel[10]; buttonLevels = new ButtonLevel[10];
for (Level level :thelevels) { for (Level level : thelevels) {
if (level!=null && level.aWorld==aworld) { if (level != null && level.aWorld == aworld) {
buttonLevels[i]=new ButtonLevel(level,true,AssetLoader.ratio); buttonLevels[i] = new ButtonLevel(level, true,
Gdx.app.debug(getClass().getSimpleName(),"Ajout du niveau :"+level.Name+""+String.valueOf(level.aLevel)); AssetLoader.ratio);
buttonLevels[i++].addListener(new ClickListener(){ Gdx.app.debug(getClass().getSimpleName(), "Ajout du niveau :"
@Override + level.Name + "" + String.valueOf(level.aLevel));
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { buttonLevels[i++].addListener(new ClickListener() {
ButtonLevel abutton = (ButtonLevel)event.getListenerActor(); @Override
Gdx.app.debug(event.getListenerActor().toString(), "Enter button "); public void enter(InputEvent event, float x, float y,
if (!abutton.isChecked()) int pointer, Actor fromActor) {
showlevel(abutton); ButtonLevel abutton = (ButtonLevel) event
} .getListenerActor();
public void exit(InputEvent event, float x, float y, int pointer, Actor fromActor) { Gdx.app.debug(event.getListenerActor().toString(),
ButtonLevel abutton = (ButtonLevel)event.getListenerActor(); "Enter button ");
Gdx.app.debug(event.getListenerActor().toString(), "Enter button "); if (!abutton.isChecked())
if (!abutton.isChecked()) showlevel(abutton);
showlevel(abutton); }
}
public void touchDragged(InputEvent event,float x,float y,int pointer) { public void exit(InputEvent event, float x, float y,
ButtonLevel abutton = (ButtonLevel)event.getListenerActor(); int pointer, Actor fromActor) {
if (logosmall.isChecked()) { ButtonLevel abutton = (ButtonLevel) event
abutton.setPosition(event.getStageX()-56, event.getStageY()-20); .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();
if (logosmall.isChecked()) {
abutton.setPosition(event.getStageX() - 56,
event.getStageY() - 20);
} }
} }
}); });
} }
} }
for (int j=0;j<10;j++) { for (int j = 0; j < 10; j++) {
if (buttonLevels[j]!=null) { if (buttonLevels[j] != null) {
stage.addActor(buttonLevels[j]); stage.addActor(buttonLevels[j]);
} }
} }
Gdx.app.debug(getClass().getSimpleName(),"Mise en place du level 0."); Gdx.app.debug(getClass().getSimpleName(), "Mise en place du level 0.");
world=world; world = world;
buttonLevels[0].setChecked(true); buttonLevels[0].setChecked(true);
showlevel(buttonLevels[0]); showlevel(buttonLevels[0]);
} }
public LevelScreen(int aworld) { public LevelScreen(int aworld) {
this.world=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); stage = new Stage(AssetLoader.viewport);
table = new Table(); table = new Table();
Renderer=new LevelRenderer(this); Renderer = new LevelRenderer(this);
dialog=new WarnDialog(AssetLoader.Skin_ui); dialog = new WarnDialog(AssetLoader.Skin_ui);
Gdx.app.debug(getClass().getSimpleName(),"Mise en place du timer."); Gdx.app.debug(getClass().getSimpleName(), "Mise en place du timer.");
ScrollTimer=new Timer(); ScrollTimer = new Timer();
ScrollTask = new TimerTask() ScrollTask = new TimerTask() {
{
@Override @Override
public void run() public void run() {
{
Renderer.evolve(); Renderer.evolve();
} }
}; };
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30); ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
Gdx.app.debug(getClass().getSimpleName(),"Création du menu."); Gdx.app.debug(getClass().getSimpleName(), "Création du menu.");
MenuSolo=new Image(AssetLoader.Skin_level,"menu1"); MenuSolo = new Image(AssetLoader.Skin_level, "menu1");
MenuSolo.setOrigin(MenuSolo.getWidth()/2, MenuSolo.getHeight()/2); MenuSolo.setOrigin(MenuSolo.getWidth() / 2, MenuSolo.getHeight() / 2);
MenuSolo.addListener(new ClickListener() { MenuSolo.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
MenuMulti.addAction(Actions.fadeOut(0.5f)); MenuMulti.addAction(Actions.fadeOut(0.5f));
MenuScenario.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(
public void run() { Actions.parallel(Actions.rotateBy(640, 0.5f),
level(); Actions.scaleTo(0.05f, 0.05f, 0.5f)),
} Actions.run(new Runnable() {
}))); public void run() {
level();
}
})));
} }
}); });
MenuMulti=new Image(AssetLoader.Skin_level,"menu2"); 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() { MenuMulti.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
MenuSolo.addAction(Actions.fadeOut(0.5f)); MenuSolo.addAction(Actions.fadeOut(0.5f));
MenuScenario.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(
public void run() { Actions.parallel(Actions.rotateBy(640, 0.5f),
level(); Actions.scaleTo(0.05f, 0.05f, 0.5f)),
} Actions.run(new Runnable() {
}))); public void run() {
level();
}
})));
} }
}); });
MenuScenario=new Image(AssetLoader.Skin_level,"menu3"); 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() { MenuScenario.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
MenuMulti.addAction(Actions.fadeOut(0.5f)); MenuMulti.addAction(Actions.fadeOut(0.5f));
MenuSolo.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(
public void run() { Actions.parallel(Actions.rotateBy(640, 0.5f),
level(); 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."); Gdx.app.debug(getClass().getSimpleName(), "Création des boutons.");
logosmall=new ImageButton(AssetLoader.Skin_level,"logosmall"); logosmall = new ImageButton(AssetLoader.Skin_level, "logosmall");
logosmall.setPosition(20, AssetLoader.height-175+logosmall.getHeight()/2); logosmall.setPosition(20,
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,"Descriptif"); AssetLoader.height - 175 + logosmall.getHeight() / 2);
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,
"Descriptif");
TextDescriptive.setBounds(15, 15, 1185, 100); TextDescriptive.setBounds(15, 15, 1185, 100);
buttonApply = new TextButton("Appliquer", AssetLoader.Skin_ui); buttonApply = new TextButton("Appliquer", AssetLoader.Skin_ui);
buttonApply.setBounds(1680, 350, 190, 40); buttonApply.setBounds(1680, 350, 190, 40);
buttonApply.addListener(new ClickListener() { buttonApply.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
AssetLoader.Datahandler.CloseAll(); AssetLoader.Datahandler.CloseAll();
AssetLoader.Datahandler.Attach(Userdata.getModel(),Userdata.getUrl()); AssetLoader.Datahandler.Attach(Userdata.getModel(),
AssetLoader.Datahandler.Attach(Statdata.getModel(),Statdata.getUrl()); Userdata.getUrl());
AssetLoader.Datahandler.Attach(Gamedata.getModel(),Gamedata.getUrl()); AssetLoader.Datahandler.Attach(Statdata.getModel(),
Statdata.getUrl());
AssetLoader.Datahandler.Attach(Gamedata.getModel(),
Gamedata.getUrl());
if (!AssetLoader.Datahandler.verifyall()) { 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(); initlevel();
} } else
else
menu(); menu();
if (AssetLoader.Datahandler.stat()==null) if (AssetLoader.Datahandler.stat() == null)
Statdata.setColor(1f,0,0,1f); Statdata.setColor(1f, 0, 0, 1f);
else else
Statdata.setColor(1f,1f,1f,1f); Statdata.setColor(1f, 1f, 1f, 1f);
if (AssetLoader.Datahandler.game()==null) if (AssetLoader.Datahandler.game() == null)
Gamedata.setColor(1f,0,0,1f); Gamedata.setColor(1f, 0, 0, 1f);
else else
Gamedata.setColor(1f,1f,1f,1f); Gamedata.setColor(1f, 1f, 1f, 1f);
if (AssetLoader.Datahandler.user()==null) if (AssetLoader.Datahandler.user() == null)
Userdata.setColor(1f,0,0,1f); Userdata.setColor(1f, 0, 0, 1f);
else else
Userdata.setColor(1f,1f,1f,1f); Userdata.setColor(1f, 1f, 1f, 1f);
Worlddata.Refresh(); Worlddata.Refresh();
} }
}); });
@ -377,11 +393,13 @@ public class LevelScreen implements Screen {
Preference.prefs.putString("userdata", Userdata.getUrl()); Preference.prefs.putString("userdata", Userdata.getUrl());
Preference.prefs.putString("gamedata", Gamedata.getUrl()); Preference.prefs.putString("gamedata", Gamedata.getUrl());
Preference.prefs.putString("statdata", Statdata.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); buttonConnect = new TextButton("Connexions", AssetLoader.Skin_ui);
buttonConnect.setBounds(1480, AssetLoader.height-60, 190, 40); buttonConnect.setBounds(1480, AssetLoader.height - 60, 190, 40);
buttonConnect.addListener(new ClickListener() { buttonConnect.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if (!Statdata.isVisible()) if (!Statdata.isVisible())
@ -390,14 +408,15 @@ public class LevelScreen implements Screen {
}); });
buttonPlay = new TextButton("Jouer", AssetLoader.Skin_ui); buttonPlay = new TextButton("Jouer", AssetLoader.Skin_ui);
buttonPlay.setBounds(1040, 20, 150, 40); buttonPlay.setBounds(1040, 20, 150, 40);
buttonPlay.addListener(new ClickListener(){ buttonPlay.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { 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); buttonStat = new TextButton("Statistiques", AssetLoader.Skin_ui);
buttonStat.setBounds(1710, AssetLoader.height-60, 190, 40); buttonStat.setBounds(1710, AssetLoader.height - 60, 190, 40);
buttonStat.addListener(new ClickListener() { buttonStat.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if (Statdata.isVisible()) if (Statdata.isVisible())
@ -409,94 +428,106 @@ public class LevelScreen implements Screen {
buttonPlaythis.addListener(new ClickListener() { buttonPlaythis.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if (!AssetLoader.Datahandler.verifyall()) 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); dialog.Show(
else "Impossible de jouer sans bases de données correctement configurée, cliquer sur RAZ si vous ne savez pas revenir à une situation jouable.",
{ stage);
if (Worlddata.getSelected()==null) else {
if (Worlddata.getSelected() == null)
dialog.Show("Aucun monde n'a été sélectionné", stage); dialog.Show("Aucun monde n'a été sélectionné", stage);
else else {
{ Preference.prefs.putString("world",
Preference.prefs.putString("world", (String)Worlddata.getSelected()); (String) Worlddata.getSelected());
Preference.prefs.flush(); Preference.prefs.flush();
play(); play();
} }
} }
} }
}); });
Exit=new ImageButton(AssetLoader.Skin_level,"Exit"); Exit = new ImageButton(AssetLoader.Skin_level, "Exit");
Exit.setPosition(1110, AssetLoader.height-Exit.getHeight()-5); Exit.setPosition(1110, AssetLoader.height - Exit.getHeight() - 5);
Exit.addListener(new ClickListener(){ Exit.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if (Exit.getX()<1210) if (Exit.getX() < 1210)
menu(); menu();
else else
Gdx.app.exit(); Gdx.app.exit();
} }
}); });
Next=new ImageButton(AssetLoader.Skin_level,"Next"); Next = new ImageButton(AssetLoader.Skin_level, "Next");
Next.setPosition(1030, 170); Next.setPosition(1030, 170);
Next.addListener(new ClickListener(){ Next.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if (world<getMaxWorld()) { if (world < getMaxWorld()) {
world++; world++;
loadWorld(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"); }
});
Previous = new ImageButton(AssetLoader.Skin_level, "Previous");
Previous.setPosition(1110, 170); Previous.setPosition(1110, 170);
Previous.addListener(new ClickListener(){ Previous.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
if (world>0) { if (world > 0) {
world--; world--;
loadWorld(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"); }
});
cout = new ImageTextButton("5", AssetLoader.Skin_level, "cout");
cout.setPosition(1250, 48); cout.setPosition(1250, 48);
tech=new ImageTextButton("10",AssetLoader.Skin_level,"tech"); tech = new ImageTextButton("10", AssetLoader.Skin_level, "tech");
tech.setPosition(1365, 48); tech.setPosition(1365, 48);
temp=new ImageTextButton("10",AssetLoader.Skin_level,"temp"); temp = new ImageTextButton("10", AssetLoader.Skin_level, "temp");
temp.setPosition(1365, 360); temp.setPosition(1365, 360);
cycle=new ImageTextButton("10",AssetLoader.Skin_level,"cycle"); cycle = new ImageTextButton("10", AssetLoader.Skin_level, "cycle");
cycle.setPosition(1250, 360); cycle.setPosition(1250, 360);
nrj=new ImageTextButton("10",AssetLoader.Skin_level,"nrj"); nrj = new ImageTextButton("10", AssetLoader.Skin_level, "nrj");
nrj.setPosition(1365, 490); nrj.setPosition(1365, 490);
rayon=new ImageTextButton("10",AssetLoader.Skin_level,"rayon"); rayon = new ImageTextButton("10", AssetLoader.Skin_level, "rayon");
rayon.setPosition(1250, 490); rayon.setPosition(1250, 490);
Gdx.app.debug(getClass().getSimpleName(),"Conditions de victoire."); Gdx.app.debug(getClass().getSimpleName(), "Conditions de victoire.");
Victory=new Objectives(); Victory = new Objectives();
Victory.setVictory(new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); Victory.setVictory(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
Victory.setPosition(1216, 185); Victory.setPosition(1216, 185);
String url="http://evolving.fr/servers/list.xml"; String url = "http://evolving.fr/servers/list.xml";
Statdata=new ServerList(url,Base.datatype.statdata,AssetLoader.Skin_ui); Statdata = new ServerList(url, Base.datatype.statdata,
Statdatalabel=new Label("Stockage des statistiques:", AssetLoader.Skin_ui, "grey"); AssetLoader.Skin_ui);
Statdata.setBounds(1480, AssetLoader.height-250, 420, 150); Statdatalabel = new Label("Stockage des statistiques:",
Statdatalabel.setPosition(1480, AssetLoader.height-100); AssetLoader.Skin_ui, "grey");
Userdata=new ServerList(url,Base.datatype.userdata,AssetLoader.Skin_ui); Statdata.setBounds(1480, AssetLoader.height - 250, 420, 150);
Userdatalabel=new Label("Stockage des données du joueur:", AssetLoader.Skin_ui, "grey"); Statdatalabel.setPosition(1480, AssetLoader.height - 100);
Userdata.setBounds(1480, AssetLoader.height-450, 420, 150); Userdata = new ServerList(url, Base.datatype.userdata,
Userdatalabel.setPosition(1480, AssetLoader.height-300); AssetLoader.Skin_ui);
Gamedata=new ServerList(url,Base.datatype.gamedata,AssetLoader.Skin_ui); Userdatalabel = new Label("Stockage des données du joueur:",
Gamedatalabel=new Label("Stockage des données du jeu:", AssetLoader.Skin_ui, "grey"); AssetLoader.Skin_ui, "grey");
Gamedata.setBounds(1480, AssetLoader.height-650, 420, 150); Userdata.setBounds(1480, AssetLoader.height - 450, 420, 150);
Gamedatalabel.setPosition(1480, AssetLoader.height-500); Userdatalabel.setPosition(1480, AssetLoader.height - 300);
Worlddata=new Worldlist(AssetLoader.Skin_ui); Gamedata = new ServerList(url, Base.datatype.gamedata,
Worlddatalabel=new Label("Mondes disponibles:", AssetLoader.Skin_ui, "grey"); 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");
Worlddata.setBounds(1480, 100, 420, 200); Worlddata.setBounds(1480, 100, 420, 200);
Worlddatalabel.setPosition(1480, 300); Worlddatalabel.setPosition(1480, 300);
Gamedata.setWorldlist(Worlddata); Gamedata.setWorldlist(Worlddata);
Statdata.Refresh(); Statdata.Refresh();
Userdata.Refresh(); Userdata.Refresh();
Gamedata.Refresh(); Gamedata.Refresh();
Gdx.app.debug(getClass().getSimpleName(),"Affichage du menu."); Gdx.app.debug(getClass().getSimpleName(), "Affichage du menu.");
if (aworld!=-1) if (aworld != -1)
level(); level();
else else
menu(); menu();
@ -506,52 +537,52 @@ public class LevelScreen implements Screen {
public void render(float delta) { public void render(float delta) {
runTime += delta; runTime += delta;
Renderer.render(delta, runTime); Renderer.render(delta, runTime);
stage.act(); stage.act();
stage.draw(); stage.draw();
} }
@Override @Override
public void resize(int width, int height) { public void resize(int width, int height) {
AssetLoader.viewport.update(width,height); AssetLoader.viewport.update(width, height);
} }
@Override @Override
public void show() { public void show() {
Gdx.app.log("*****","Affichage du choix des mondes & niveaux."); Gdx.app.log("*****", "Affichage du choix des mondes & niveaux.");
table.setFillParent(true); table.setFillParent(true);
stage.addActor(MenuSolo); stage.addActor(MenuSolo);
stage.addActor(MenuMulti); stage.addActor(MenuMulti);
stage.addActor(MenuScenario); stage.addActor(MenuScenario);
stage.addActor(TextDescriptive); stage.addActor(TextDescriptive);
stage.addActor(buttonPlaythis); stage.addActor(buttonPlaythis);
stage.addActor(Exit); stage.addActor(Exit);
stage.addActor(Next); stage.addActor(Next);
stage.addActor(buttonApply); stage.addActor(buttonApply);
stage.addActor(buttonSave); stage.addActor(buttonSave);
stage.addActor(buttonPlay); stage.addActor(buttonPlay);
stage.addActor(buttonConnect); stage.addActor(buttonConnect);
stage.addActor(buttonStat); stage.addActor(buttonStat);
stage.addActor(Previous); stage.addActor(Previous);
stage.addActor(cout); stage.addActor(cout);
stage.addActor(tech); stage.addActor(tech);
stage.addActor(cycle); stage.addActor(cycle);
stage.addActor(nrj); stage.addActor(nrj);
stage.addActor(temp); stage.addActor(temp);
stage.addActor(rayon); stage.addActor(rayon);
stage.addActor(Victory); stage.addActor(Victory);
stage.addActor(logosmall); stage.addActor(logosmall);
stage.addActor(Statdata); stage.addActor(Statdata);
stage.addActor(Statdatalabel); stage.addActor(Statdatalabel);
stage.addActor(Userdata); stage.addActor(Userdata);
stage.addActor(Userdatalabel); stage.addActor(Userdatalabel);
stage.addActor(Gamedata); stage.addActor(Gamedata);
stage.addActor(Gamedatalabel); stage.addActor(Gamedatalabel);
stage.addActor(Worlddata); stage.addActor(Worlddata);
stage.addActor(Worlddatalabel); stage.addActor(Worlddatalabel);
Gdx.input.setInputProcessor(stage); Gdx.input.setInputProcessor(stage);
Gdx.app.debug("AssetLoader","Début dans la bande son \'intro\'"); Gdx.app.debug("AssetLoader", "Début dans la bande son \'intro\'");
AssetLoader.intro.setLooping(true); AssetLoader.intro.setLooping(true);
AssetLoader.intro.play(); AssetLoader.intro.play();
} }
@Override @Override
@ -568,57 +599,49 @@ public class LevelScreen implements Screen {
@Override @Override
public void dispose() { public void dispose() {
stage.dispose(); stage.dispose();
} }
public void showlevel(ButtonLevel button) { 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); TextDescriptive.setText(button.level.Description);
if (button.level.Maxcycle<99999 && button.level.Maxcycle>0) { if (button.level.Maxcycle < 99999 && button.level.Maxcycle > 0) {
cycle.setText(String.valueOf(button.level.Maxcycle)); cycle.setText(String.valueOf(button.level.Maxcycle));
cycle.setVisible(true); cycle.setVisible(true);
} } else
else
cycle.setVisible(false); cycle.setVisible(false);
if (button.level.Maxtemp<99999 && button.level.Maxtemp>0) { if (button.level.Maxtemp < 99999 && button.level.Maxtemp > 0) {
temp.setText(String.valueOf(button.level.Maxtemp)); temp.setText(String.valueOf(button.level.Maxtemp));
temp.setVisible(true); temp.setVisible(true);
} } else
else
temp.setVisible(false); temp.setVisible(false);
if (button.level.Maxnrj<99999 && button.level.Maxnrj>0) { if (button.level.Maxnrj < 99999 && button.level.Maxnrj > 0) {
nrj.setText(String.valueOf(button.level.Maxnrj)); nrj.setText(String.valueOf(button.level.Maxnrj));
nrj.setVisible(true); nrj.setVisible(true);
} } else
else
nrj.setVisible(false); nrj.setVisible(false);
if (button.level.Maxrayon<99999 && button.level.Maxrayon>0) { if (button.level.Maxrayon < 99999 && button.level.Maxrayon > 0) {
rayon.setText(String.valueOf(button.level.Maxrayon)); rayon.setText(String.valueOf(button.level.Maxrayon));
rayon.setVisible(true); rayon.setVisible(true);
} } else
else
rayon.setVisible(false); rayon.setVisible(false);
if (button.level.Cout>0) { if (button.level.Cout > 0) {
cout.setText(String.valueOf(button.level.Cout)); cout.setText(String.valueOf(button.level.Cout));
cout.setVisible(true); cout.setVisible(true);
} } else
else
cout.setVisible(false); cout.setVisible(false);
if (button.level.Tech>=1) { if (button.level.Tech >= 1) {
tech.setText(String.valueOf(button.level.Tech)); tech.setText(String.valueOf(button.level.Tech));
tech.setVisible(true); tech.setVisible(true);
} } else
else
tech.setVisible(false); tech.setVisible(false);
Victory.setVisible(button.level.Cout>0); Victory.setVisible(button.level.Cout > 0);
Victory.setVictory(button.level.Victory); Victory.setVictory(button.level.Victory);
//for (int i = 0;i<thelevels.length;i++) { if (selected != null)
// if (thelevels[i] != null && buttonLevels[i]!=button)
// buttonLevels[i].setChecked(false);
if (selected!=null)
selected.setChecked(false); selected.setChecked(false);
selected=button; selected = button;
button.setChecked(true); button.setChecked(true);
} }
} }

View File

@ -1,12 +1,10 @@
package fr.evolving.screens; package fr.evolving.screens;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen; import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; 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.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Image;
@ -25,7 +23,7 @@ public class SplashScreen implements Screen {
public SplashScreen(main game) { public SplashScreen(main game) {
AssetLoader.load(); AssetLoader.load();
this.game = game; this.game = game;
batcher= new SpriteBatch(); batcher = new SpriteBatch();
stage = new Stage(AssetLoader.viewport); stage = new Stage(AssetLoader.viewport);
splashImage = new Image(AssetLoader.Texture_logo); splashImage = new Image(AssetLoader.Texture_logo);
AssetLoader.loadall(); AssetLoader.loadall();
@ -33,22 +31,27 @@ public class SplashScreen implements Screen {
@Override @Override
public void show() { public void show() {
Gdx.app.log("****","Affichage du SplashScreen"); Gdx.app.log("****", "Affichage du SplashScreen");
scale=2; scale = 2;
splashImage.setScale(scale); 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); stage.addActor(splashImage);
splashImage.addAction(Actions.sequence(Actions.alpha(0),Actions.fadeIn(3f),Actions.run(new Runnable() { splashImage.addAction(Actions.sequence(Actions.alpha(0),
@Override Actions.fadeIn(3f), Actions.run(new Runnable() {
public void run() { @Override
AssetLoader.finishall(); public void run() {
} AssetLoader.finishall();
}),Actions.run(new Runnable() { }
@Override }), Actions.run(new Runnable() {
public void run() { @Override
((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen(-1)); public void run() {
} ((Game) Gdx.app.getApplicationListener())
}))); .setScreen(new LevelScreen(-1));
}
})));
} }
@Override @Override
@ -56,20 +59,22 @@ public class SplashScreen implements Screen {
Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(); stage.act();
stage.draw(); stage.draw();
if (AssetLoader.manager!=null) { if (AssetLoader.manager != null) {
batcher.begin(); batcher.begin();
batcher.setProjectionMatrix(AssetLoader.Camera.combined); batcher.setProjectionMatrix(AssetLoader.Camera.combined);
AssetLoader.empty.draw(batcher, (AssetLoader.width / 2) - 400f, 150f, 800f, 50f); AssetLoader.empty.draw(batcher, (AssetLoader.width / 2) - 400f,
AssetLoader.full.draw(batcher, (AssetLoader.width / 2) - 400f, 150f, AssetLoader.manager.getProgress()*800f, 50f); 150f, 800f, 50f);
AssetLoader.full.draw(batcher, (AssetLoader.width / 2) - 400f,
150f, AssetLoader.manager.getProgress() * 800f, 50f);
AssetLoader.manager.update(); AssetLoader.manager.update();
batcher.end(); batcher.end();
} }
} }
@Override @Override
public void resize(int width, int height) { public void resize(int width, int height) {
AssetLoader.viewport.update(width,height); AssetLoader.viewport.update(width, height);
} }
@Override @Override