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

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

View File

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

View File

@ -1,6 +1,5 @@
package fr.evolving.UI;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
@ -19,158 +18,162 @@ import com.badlogic.gdx.utils.ObjectMap.Entry;
import com.badlogic.gdx.utils.OrderedMap;
import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
import fr.evolving.automata.Transmuter.Angular;
import fr.evolving.automata.Transmuter.CaseType;
public class Menu extends Actor{
public class Menu extends Actor {
private TiledMap map;
private OrthogonalTiledMapRenderer MapRenderer;
private OrthographicCamera camera;
private int tilesizex;
private int tilesizey;
private float decx;
private float decy;
private int size=32;
public Menu(int tilesizex,int tilesizey) {
this.tilesizex=tilesizex;
this.tilesizey=tilesizey;
map=new TiledMap();
map.getTileSets().addTileSet(AssetLoader.tileSet);
MapLayers layers = map.getLayers();
for (int i = 0; i < 3; i++) {
TiledMapTileLayer layer = new TiledMapTileLayer(tilesizex, tilesizey, 128, 128);
for (int x = 0; x < layer.getWidth(); x++) {
for (int y = 0; y < layer.getHeight(); y++) {
Cell cell = new Cell();
if (i==0)
cell.setTile(AssetLoader.tileSet.getTile(54));
layer.setCell(x, y, cell);
}
}
layers.add(layer);
}
map.getLayers().get(1).setOpacity(0.5f);
MapRenderer = new OrthogonalTiledMapRenderer(map,1/(float)size);
camera = new OrthographicCamera();
camera.setToOrtho(false, tilesizex*32,tilesizex*32*AssetLoader.height/AssetLoader.width);
Gdx.app.debug(getClass().getSimpleName(),"Caméra pour tilemap:"+(tilesizex*size)+"x"+(tilesizey*size));
decx=-102f;
decy=-20f;
if (AssetLoader.ratio==1.44f)
decy-=24;
camera.translate(decx,decy);
Gdx.app.debug(getClass().getSimpleName(),"Décalage:"+decx+"x"+decy);
}
private float decy;
private int size = 32;
public void clear()
{
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
for (int x = 0; x < layer.getWidth(); x++)
for (int y = 0; y < layer.getHeight(); y++)
layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(54));
}
public void setMenuTile(int x,int y,int tile,String title)
{
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 Menu(int tilesizex, int tilesizey) {
this.tilesizex = tilesizex;
this.tilesizey = tilesizey;
map = new TiledMap();
map.getTileSets().addTileSet(AssetLoader.tileSet);
MapLayers layers = map.getLayers();
for (int i = 0; i < 3; i++) {
TiledMapTileLayer layer = new TiledMapTileLayer(tilesizex,
tilesizey, 128, 128);
for (int x = 0; x < layer.getWidth(); x++) {
for (int y = 0; y < layer.getHeight(); y++) {
Cell cell = new Cell();
if (i == 0)
cell.setTile(AssetLoader.tileSet.getTile(54));
layer.setCell(x, y, cell);
}
}
layers.add(layer);
}
map.getLayers().get(1).setOpacity(0.5f);
MapRenderer = new OrthogonalTiledMapRenderer(map, 1 / (float) size);
camera = new OrthographicCamera();
camera.setToOrtho(false, tilesizex * 32, tilesizex * 32
* AssetLoader.height / AssetLoader.width);
Gdx.app.debug(getClass().getSimpleName(), "Caméra pour tilemap:"
+ (tilesizex * size) + "x" + (tilesizey * size));
decx = -102f;
decy = -20f;
if (AssetLoader.ratio == 1.44f)
decy -= 24;
camera.translate(decx, decy);
Gdx.app.debug(getClass().getSimpleName(), "Décalage:" + decx + "x"
+ decy);
}
}
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()){
public void clear() {
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
for (int x = 0; x < layer.getWidth(); x++)
for (int y = 0; y < layer.getHeight(); y++)
layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(54));
}
public void setMenuTile(int x, int y, int tile, String title) {
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();
Cell subcell=((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)(x+all.key.x),(int)(y+all.key.y));
subcell.setTile(AssetLoader.tileSet.getTile(transmuter.getTilestype(tiles.keys().toArray().indexOf(all.key, false)).ordinal()+80));
Cell subcell = ((TiledMapTileLayer) map.getLayers().get(1))
.getCell((int) (x + all.key.x), (int) (y + all.key.y));
subcell.setTile(AssetLoader.tileSet.getTile(transmuter
.getTilestype(
tiles.keys().toArray().indexOf(all.key, false))
.ordinal() + 80));
}
}
}
public void EraseMenuTransmuterSurtile()
{
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)
{
Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y);
if (cell!=null)
return cell.getTile().getProperties();
else
return null;
}
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 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 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 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();
}
public MapProperties getMenubyTile(int x, int y) {
Cell cell = ((TiledMapTileLayer) map.getLayers().get(0)).getCell(x, y);
if (cell != null)
return cell.getTile().getProperties();
else
return null;
}
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;
import java.util.Arrays;
import java.util.Collections;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
@ -17,41 +14,44 @@ public class Objectives extends Actor {
public int[] Victory;
BitmapFont font;
BitmapFont font2;
public Objectives() {
shaperenderer = new ShapeRenderer();
font=AssetLoader.Skin_level.getFont("Vademecum-18");
font2=AssetLoader.Skin_level.getFont("OpenDyslexicAlta-28");
font = AssetLoader.Skin_level.getFont("Vademecum-18");
font2 = AssetLoader.Skin_level.getFont("OpenDyslexicAlta-28");
}
public void setVictory(int[] Victory) {
this.Victory=Victory;
this.Victory = Victory;
}
@Override
public final void draw(Batch batch, float parentAlpha) {
shaperenderer.setProjectionMatrix(batch.getProjectionMatrix());
int element=0;
int type=0;
for(int vict: Victory) {
if (vict!=0) {
int element = 0;
int type = 0;
for (int vict : Victory) {
if (vict != 0) {
batch.end();
shaperenderer.begin(ShapeType.Filled);
shaperenderer.setColor(AssetLoader.Typecolors[type]);
shaperenderer.rect(this.getX()+element*40, this.getY(), 40, 68);
shaperenderer.rect(this.getX() + element * 40, this.getY(), 40,
68);
shaperenderer.end();
shaperenderer.begin(ShapeType.Line);
shaperenderer.setColor(1, 1, 1, 1);
shaperenderer.rect(this.getX()+element*40, this.getY(), 40, 68);
shaperenderer.rect(this.getX() + element * 40, this.getY(), 40,
68);
shaperenderer.end();
batch.begin();
font.draw(batch, AssetLoader.Typenames[type], this.getX()+element*40+2,this.getY()+69);
font2.draw(batch, String.valueOf(vict), this.getX()+element*40+11,this.getY()+35);
element+=1;
font.draw(batch, AssetLoader.Typenames[type], this.getX()
+ element * 40 + 2, this.getY() + 69);
font2.draw(batch, String.valueOf(vict), this.getX() + element
* 40 + 11, this.getY() + 35);
element += 1;
}
type+=1;
type += 1;
}
}
}
}

View File

@ -1,7 +1,6 @@
package fr.evolving.UI;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Net.HttpMethods;
@ -18,83 +17,88 @@ import com.badlogic.gdx.utils.XmlReader.Element;
import fr.evolving.assets.AssetLoader;
import fr.evolving.database.Base;
import fr.evolving.database.Base.datatype;
import fr.evolving.database.LocalBase;
import fr.evolving.database.SqlBase;
public class ServerList extends List {
HashMap parameters;
String url;
Base.datatype model;
Worldlist list;
public ServerList(String url,Base.datatype model,Skin skin) {
public ServerList(String url, Base.datatype model, Skin skin) {
super(skin);
this.url=url;
this.model=model;
this.url = url;
this.model = model;
parameters = new HashMap();
parameters.put("version", "last");
}
public String getUrl() {
return (String)this.getSelected();
return (String) this.getSelected();
}
public Base.datatype getModel() {
return model;
}
public void setWorldlist(Worldlist list) {
this.list=list;
this.list = list;
}
public void Refresh() {
HttpRequest httpGet = new HttpRequest(HttpMethods.GET);
httpGet.setUrl(url);
httpGet.setContent(HttpParametersUtils.convertHttpParameters(parameters));
//If you want basic authentication, add this header
String authHeader = "Basic " + Base64Coder.encodeString("evolving:--evolvE2016__");
httpGet.setHeader("Authorization", authHeader);
httpGet.setHeader("Content-Type", "text/xml");
httpGet.setHeader("Accept", "text/xml");
HttpRequest httpGet = new HttpRequest(HttpMethods.GET);
httpGet.setUrl(url);
httpGet.setContent(HttpParametersUtils
.convertHttpParameters(parameters));
// If you want basic authentication, add this header
String authHeader = "Basic "
+ Base64Coder.encodeString("evolving:--evolvE2016__");
httpGet.setHeader("Authorization", authHeader);
httpGet.setHeader("Content-Type", "text/xml");
httpGet.setHeader("Accept", "text/xml");
Gdx.net.sendHttpRequest(httpGet, new HttpResponseListener() {
public void handleHttpResponse(HttpResponse httpResponse) {
if (httpResponse.getStatus().getStatusCode() == 200) {
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() {
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();
}
}
@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() {
}
});
@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() {
}
});
}
}

View File

@ -1,7 +1,6 @@
package fr.evolving.UI;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.maps.MapLayers;
@ -14,166 +13,199 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
import fr.evolving.assets.AssetLoader;
import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
import fr.evolving.automata.Transmuter.Angular;
public class TouchMaptiles extends Actor{
public class TouchMaptiles extends Actor {
private TiledMap map;
private OrthogonalTiledMapRenderer MapRenderer;
private OrthographicCamera camera;
private Level level;
private int sizex;
private int sizey;
private float viewwidth,viewheight,decx,decy;
public TouchMaptiles(Level level,int sizex,int sizey) {
this.level=level;
this.sizex=sizex;
this.sizey=sizey;
map=new TiledMap();
map.getTileSets().addTileSet(AssetLoader.tileSet);
MapLayers layers = map.getLayers();
for (int i = 0; i < 5; i++) {
TiledMapTileLayer layer = new TiledMapTileLayer(level.Grid.sizeX, level.Grid.sizeY, sizex, sizey);
for (int x = 0; x < layer.getWidth();x++) {
for (int y = 0; y < layer.getHeight(); y++) {
Cell cell = new Cell();
if (i==0)
cell.setTile(AssetLoader.tileSet.getTile(53));
layer.setCell(x, y, cell);
}
}
layers.add(layer);
}
layers.get(3).setOpacity(0.9f);
MapRenderer = new OrthogonalTiledMapRenderer(map,1/128.0f);
camera = new OrthographicCamera();
initzoom();
}
private float viewwidth, viewheight, decx, decy;
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 TouchMaptiles(Level level, int sizex, int sizey) {
this.level = level;
this.sizex = sizex;
this.sizey = sizey;
map = new TiledMap();
map.getTileSets().addTileSet(AssetLoader.tileSet);
MapLayers layers = map.getLayers();
for (int i = 0; i < 5; i++) {
TiledMapTileLayer layer = new TiledMapTileLayer(level.Grid.sizeX,
level.Grid.sizeY, sizex, sizey);
for (int x = 0; x < layer.getWidth(); x++) {
for (int y = 0; y < layer.getHeight(); y++) {
Cell cell = new Cell();
if (i == 0)
cell.setTile(AssetLoader.tileSet.getTile(53));
layer.setCell(x, y, cell);
}
}
layers.add(layer);
}
layers.get(3).setOpacity(0.9f);
MapRenderer = new OrthogonalTiledMapRenderer(map, 1 / 128.0f);
camera = new OrthographicCamera();
initzoom();
}
}
public void tempclear()
{
for (int x=0;x<level.Grid.sizeX;x++)
for (int y=0;y<level.Grid.sizeY;y++) {
((TiledMapTileLayer)map.getLayers().get(3)).getCell((int)x, (int)y).setTile(null);
((TiledMapTileLayer)map.getLayers().get(4)).getCell((int)x, (int)y).setTile(null);
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 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));
public void tempclear() {
for (int x = 0; x < level.Grid.sizeX; x++)
for (int y = 0; y < level.Grid.sizeY; y++) {
((TiledMapTileLayer) map.getLayers().get(3)).getCell((int) x,
(int) y).setTile(null);
((TiledMapTileLayer) map.getLayers().get(4)).getCell((int) x,
(int) y).setTile(null);
}
}
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++)
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));
}
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 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);
}
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) {
TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(0);
for (int x = 0; x < layer.getWidth(); x++)
for (int y = 0; y < layer.getHeight(); y++)
if (layer.getCell(x, y).getTile().getId() == 53
|| layer.getCell(x, y).getTile().getId() == 60)
layer.getCell(x, y).setTile(
AssetLoader.tileSet.getTile(tile));
}
public void fillempty(int tile)
{
TiledMapTileLayer layer = (TiledMapTileLayer)map.getLayers().get(0);
for (int x = 0; x < layer.getWidth(); x++)
for (int y = 0; y < layer.getHeight(); y++)
if (layer.getCell(x, y).getTile().getId()==53 || layer.getCell(x, y).getTile().getId()==60) layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(tile));
}
public void setZoom(float factor) {
viewwidth *= factor;
viewheight *= factor;
camera.setToOrtho(false, viewwidth, viewheight);
camera.translate(decx, decy);
Gdx.app.debug(getClass().getSimpleName(), "Caméra pour tilemap:"
+ camera.viewportWidth + "x" + camera.viewportHeight + " zoom:"
+ factor);
}
public void setZoom(float factor) {
viewwidth*=factor;
viewheight*=factor;
camera.setToOrtho(false, viewwidth, viewheight);
camera.translate(decx,decy);
Gdx.app.debug(getClass().getSimpleName(),"Caméra pour tilemap:"+camera.viewportWidth+"x"+camera.viewportHeight+" zoom:"+factor);
}
public float getDecx() {
return decx;
}
public float getDecx() {
return decx;
}
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 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();
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,8 @@
package fr.evolving.automata;
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 boolean Copper;
public transient int Copper_calc;
@ -12,15 +11,15 @@ public class Cell implements Serializable{
public transient int Transmuter_calc;
public transient int Transmuter_movex;
public transient int Transmuter_movey;
public Cell() {
this.Fiber=0;
this.Copper=false;
this.Fiber_old=0;
this.Transmuter=null;
this.Transmuter_calc=0;
this.Transmuter_movex=0;
this.Transmuter_movey=0;
this.Fiber = 0;
this.Copper = false;
this.Fiber_old = 0;
this.Transmuter = null;
this.Transmuter_calc = 0;
this.Transmuter_movex = 0;
this.Transmuter_movey = 0;
}
}

View File

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

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Inverter_I extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,150 +34,154 @@ public class Inverter_I extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Inverter_I(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=new Inverter_II(level);
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 112);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = new Inverter_II(level);
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 112);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -194,83 +193,83 @@ public class Inverter_I extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Inverter_II extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,150 +34,154 @@ public class Inverter_II extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Inverter_II(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=null;
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 113);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = null;
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 113);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -194,83 +193,83 @@ public class Inverter_II extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -2,7 +2,7 @@ package fr.evolving.automata;
import java.io.Serializable;
public class Level implements Serializable{
public class Level implements Serializable {
public String Name;
public String Description;
public String Element;
@ -28,32 +28,36 @@ public class Level implements Serializable{
public boolean Special;
public String Tuto;
public int[][] Link;
public Level(int aWorld, int aLevel,int id,String Name,String Description,String Element,int[] Current,int[] Victory,float X,float Y,int Tech,int Cout,Grid World,int Cycle,int Temp,int Rayon,int Nrj,int Maxcycle,int Maxtemp,int Maxrayon,int Maxnrj,String Tuto,boolean Special, int[][] Link){
this.aWorld=aWorld;
this.aLevel=aLevel;
this.id=id;
this.Name=Name;
this.Description=Description;
this.Element=Element;
this.Current=Current;
this.Victory=Victory;
this.X=X;
this.Y=Y;
this.Tech=Tech;
this.Cout=Cout;
this.Grid=World;
this.Grid_orig=World;
this.Cycle=Cycle;
this.Temp=Temp;
this.Rayon=Rayon;
this.Nrj=Nrj;
this.Maxcycle=Maxcycle;
this.Maxtemp=Maxtemp;
this.Maxrayon=Maxrayon;
this.Maxnrj=Maxnrj;
this.Special=Special;
this.Tuto=Tuto;
this.Link=Link;
}
public Level(int aWorld, int aLevel, int id, String Name,
String Description, String Element, int[] Current, int[] Victory,
float X, float Y, int Tech, int Cout, Grid World, int Cycle,
int Temp, int Rayon, int Nrj, int Maxcycle, int Maxtemp,
int Maxrayon, int Maxnrj, String Tuto, boolean Special, int[][] Link) {
this.aWorld = aWorld;
this.aLevel = aLevel;
this.id = id;
this.Name = Name;
this.Description = Description;
this.Element = Element;
this.Current = Current;
this.Victory = Victory;
this.X = X;
this.Y = Y;
this.Tech = Tech;
this.Cout = Cout;
this.Grid = World;
this.Grid_orig = World;
this.Cycle = Cycle;
this.Temp = Temp;
this.Rayon = Rayon;
this.Nrj = Nrj;
this.Maxcycle = Maxcycle;
this.Maxtemp = Maxtemp;
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;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Negativer extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,150 +34,154 @@ public class Negativer extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Negativer(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=null;
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Nimporte);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 101);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = null;
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Nimporte);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 101);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -194,83 +193,83 @@ public class Negativer extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Negativer_I extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,152 +34,156 @@ public class Negativer_I extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Negativer_I(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=new Negativer_II(level);
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul);
this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 108);
this.Tilesid.put(new Vector2(1,0), 105);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = new Negativer_II(level);
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul);
this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 108);
this.Tilesid.put(new Vector2(1, 0), 105);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -196,83 +195,83 @@ public class Negativer_I extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Negativer_II extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,152 +34,156 @@ public class Negativer_II extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Negativer_II(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=new Negativer_III(level);
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre);
this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 109);
this.Tilesid.put(new Vector2(1,0), 107);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = new Negativer_III(level);
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre);
this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 109);
this.Tilesid.put(new Vector2(1, 0), 107);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -196,83 +195,83 @@ public class Negativer_II extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Negativer_III extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,151 +34,155 @@ public class Negativer_III extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Negativer_III(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=null;
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
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.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 103);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = null;
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
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.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 103);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -195,83 +194,83 @@ public class Negativer_III extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Neutraliser_I extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,150 +34,154 @@ public class Neutraliser_I extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Neutraliser_I(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=new Neutraliser_II(level);
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 110);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = new Neutraliser_II(level);
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 110);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -194,83 +193,83 @@ public class Neutraliser_I extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Neutraliser_II extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,150 +34,154 @@ public class Neutraliser_II extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Neutraliser_II(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=null;
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 111);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = null;
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 111);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -194,83 +193,83 @@ public class Neutraliser_II extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Positiver extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,150 +34,154 @@ public class Positiver extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Positiver(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=null;
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Nimporte);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 100);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = null;
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Nimporte);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 100);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -194,83 +193,83 @@ public class Positiver extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
public class Positiver_I extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,152 +34,156 @@ public class Positiver_I extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Positiver_I(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=new Positiver_II(level);
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul);
this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 104);
this.Tilesid.put(new Vector2(1,0), 105);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = new Positiver_II(level);
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul);
this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 104);
this.Tilesid.put(new Vector2(1, 0), 105);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> tiles = this.Tilesid.keys();
while(tiles.hasNext()){
Vector2 key = tiles.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> tiles = this.Tilesid.keys();
while (tiles.hasNext()) {
Vector2 key = tiles.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -196,83 +195,83 @@ public class Positiver_I extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Positiver_II extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,152 +34,156 @@ public class Positiver_II extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Positiver_II(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=new Positiver_III(level);
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre);
this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 106);
this.Tilesid.put(new Vector2(1,0), 107);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = new Positiver_III(level);
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre);
this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 106);
this.Tilesid.put(new Vector2(1, 0), 107);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -196,83 +195,83 @@ public class Positiver_II extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,18 +1,13 @@
package fr.evolving.automata;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.OrderedMap;
import com.badlogic.gdx.utils.ObjectMap.Values;
import fr.evolving.automata.Transmuter.CaseType;
import fr.evolving.automata.Transmuter.Class;
import com.badlogic.gdx.utils.OrderedMap;
public class Positiver_III extends Transmuter {
private static String Name,Desc;
private static String Name, Desc;
private static Class theClass;
private static int Price;
private static int Technology;
@ -39,150 +34,154 @@ public class Positiver_III extends Transmuter {
private int Rotation;
private static OrderedMap<Vector2, CaseType> Tilestype;
private static OrderedMap<Vector2, Integer> Tilesid;
public Positiver_III(Level level) {
super(level);
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.theClass=Class.Charge;
this.Price=50;
this.Technology=2;
this.Research=0;
this.Upgrade=null;
this.Unlock=null;
this.showed=true;
this.CanUpgradeTemp=true;
this.CanUpgradeCycle=true;
this.CanUpgradeRayon=false;
this.CanUpgradeNrj=false;
this.UpgradedTemp=1f;
this.UpgradedCycle=1f;
this.UpgradedRayon=1f;
this.UpgradedNrj=1f;
this.UsedTemp=0.5f;
this.UsedRayon=0f;
this.UsedNrj=0f;
this.TurnTemp=0f;
this.TurnRayon=0f;
this.TurnNrj=0f;
this.Activable=true;
this.ActivationLevel=0;
this.Tilestype= new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0,0), CaseType.Tout);
this.Tilesid= new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0,0), 102);
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.theClass = Class.Charge;
this.Price = 50;
this.Technology = 2;
this.Research = 0;
this.Upgrade = null;
this.Unlock = null;
this.showed = true;
this.CanUpgradeTemp = true;
this.CanUpgradeCycle = true;
this.CanUpgradeRayon = false;
this.CanUpgradeNrj = false;
this.UpgradedTemp = 1f;
this.UpgradedCycle = 1f;
this.UpgradedRayon = 1f;
this.UpgradedNrj = 1f;
this.UsedTemp = 0.5f;
this.UsedRayon = 0f;
this.UsedNrj = 0f;
this.TurnTemp = 0f;
this.TurnRayon = 0f;
this.TurnNrj = 0f;
this.Activable = true;
this.ActivationLevel = 0;
this.Tilestype = new OrderedMap<Vector2, CaseType>();
this.Tilestype.put(new Vector2(0, 0), CaseType.Tout);
this.Tilesid = new OrderedMap<Vector2, Integer>();
this.Tilesid.put(new Vector2(0, 0), 102);
}
public String getName() {
return this.Name;
}
public String getDesc() {
return this.Desc;
}
public String getaClass() {
return this.theClass.toString();
}
public void ProcessCycle() {
this.level.Temp+=TurnTemp*UpgradedTemp;
this.level.Rayon+=TurnRayon*UpgradedRayon;
this.level.Nrj+=TurnNrj*UpgradedNrj;
this.level.Temp += TurnTemp * UpgradedTemp;
this.level.Rayon += TurnRayon * UpgradedRayon;
this.level.Nrj += TurnNrj * UpgradedNrj;
if (this.Activable)
this.ActivationLevel-=1;
this.ActivationLevel -= 1;
}
public void Run() {
this.level.Temp+=UsedTemp*UpgradedTemp;
this.level.Rayon+=UsedRayon*UpgradedRayon;
this.level.Nrj+=UsedNrj*UpgradedNrj;
this.level.Temp += UsedTemp * UpgradedTemp;
this.level.Rayon += UsedRayon * UpgradedRayon;
this.level.Nrj += UsedNrj * UpgradedNrj;
}
public void Unlock() {
if (this.Unlock==null)
if (this.Unlock == null)
return;
this.Unlock.SetShowed(true);
}
public void Upgrade() {
if (this.Upgrade==null)
if (this.Upgrade == null)
return;
this.Unlock.SetShowed(true);
this.SetShowed(false);
}
}
public void Activate() {
if (this.Activable)
ActivationLevel=this.getMaxActivationLevel();
ActivationLevel = this.getMaxActivationLevel();
}
public void UpgradeTemp() {
if (isUpgradableTemp())
UpgradedTemp+=-0.2f;
UpgradedTemp += -0.2f;
}
public void UpgradeNrj() {
if (isUpgradableNrj())
UpgradedNrj+=-0.2f;
}
UpgradedNrj += -0.2f;
}
public void UpgradeRayon() {
if (isUpgradableRayon())
UpgradedRayon+=-0.2f;
}
UpgradedRayon += -0.2f;
}
public void UpgradeCycle() {
if (isUpgradableCycle())
UpgradedCycle+=0.2f;
UpgradedCycle += 0.2f;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return Tilesid.values();
}
}
public CaseType getTilestype(int order) {
return Tilestype.values().toArray().get(order);
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2,Integer> newTiles= new OrderedMap<Vector2,Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next();
double delta=key.len();
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
newTiles.put(new Vector2((float)Math.round(delta*Math.cos(alpha)),(float)Math.round(delta*Math.sin(alpha))), this.Tilesid.get(key));
}
return newTiles;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
OrderedMap<Vector2, Integer> newTiles = new OrderedMap<Vector2, Integer>();
Iterator<Vector2> keySetIterator = this.Tilesid.keys();
while (keySetIterator.hasNext()) {
Vector2 key = keySetIterator.next();
double delta = key.len();
double alpha = key.angleRad() + this.getRotation().ordinal()
* Math.PI / 2;
newTiles.put(
new Vector2((float) Math.round(delta * Math.cos(alpha)),
(float) Math.round(delta * Math.sin(alpha))),
this.Tilesid.get(key));
}
return newTiles;
}
public boolean isActivable() {
return this.Activable;
}
public int getMaxActivationLevel() {
return ActivationLevel=(int)(10*this.UpgradedCycle);
return ActivationLevel = (int) (10 * this.UpgradedCycle);
}
public int getActivationLevel() {
if (this.Activable)
return ActivationLevel;
else
return -1;
}
public boolean getActivation() {
if (this.Activable)
return ActivationLevel>0;
return ActivationLevel > 0;
else
return true;
}
public int getPrice() {
return Price;
}
public int getSize() {
return (Tilesid.size);
}
@ -194,83 +193,83 @@ public class Positiver_III extends Transmuter {
public int getResearch() {
return Research;
}
public boolean isUpgradable() {
return this.Upgrade!=null && this.Upgrade.isShowed();
return this.Upgrade != null && this.Upgrade.isShowed();
}
public boolean isUnlockable() {
return this.Unlock!=null && this.Unlock.isShowed();
return this.Unlock != null && this.Unlock.isShowed();
}
public boolean isShowed() {
return this.showed;
}
public void SetShowed(boolean value) {
this.showed=value;
this.showed = value;
}
public boolean isUpgradableTemp() {
return CanUpgradeTemp && getUpgradeTemp()<3;
return CanUpgradeTemp && getUpgradeTemp() < 3;
}
public boolean isUpgradableCycle() {
return CanUpgradeCycle && getUpgradeCycle()<3;
return CanUpgradeCycle && getUpgradeCycle() < 3;
}
public boolean isUpgradableRayon() {
return CanUpgradeRayon && getUpgradeRayon()<3;
return CanUpgradeRayon && getUpgradeRayon() < 3;
}
public boolean isUpgradableNrj() {
return CanUpgradeNrj && getUpgradeNrj()<3;
return CanUpgradeNrj && getUpgradeNrj() < 3;
}
public int getUpgradeTemp() {
return Math.abs((int)((10*UpgradedTemp-10)/2f));
return Math.abs((int) ((10 * UpgradedTemp - 10) / 2f));
}
public int getUpgradeCycle() {
return Math.abs((int)((10*UpgradedCycle-10)/2f));
return Math.abs((int) ((10 * UpgradedCycle - 10) / 2f));
}
public int getUpgradeRayon() {
return Math.abs((int)((10*UpgradedRayon-10)/2f));
return Math.abs((int) ((10 * UpgradedRayon - 10) / 2f));
}
public int getUpgradeNrj() {
return Math.abs((int)((10*UpgradedNrj-10)/2f));
return Math.abs((int) ((10 * UpgradedNrj - 10) / 2f));
}
public float getUsedTemp() {
return UsedTemp*UpgradedTemp;
return UsedTemp * UpgradedTemp;
}
public float getUsedRayon() {
return UsedRayon*UpgradedRayon;
return UsedRayon * UpgradedRayon;
}
public float getUsedNrj() {
return UsedNrj*UpgradedNrj;
return UsedNrj * UpgradedNrj;
}
public float getTurnTemp() {
return TurnTemp*UpgradedTemp;
return TurnTemp * UpgradedTemp;
}
public float getTurnRayon() {
return TurnRayon*UpgradedRayon;
return TurnRayon * UpgradedRayon;
}
public float getTurnNrj() {
return TurnNrj*UpgradedNrj;
return TurnNrj * UpgradedNrj;
}
public Transmuter getUpgrade() {
return this.Upgrade;
}
public Transmuter getUnlock() {
return this.Unlock;
}

View File

@ -1,99 +1,105 @@
package fr.evolving.automata;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.ObjectMap.Entries;
import com.badlogic.gdx.utils.ObjectMap.Entry;
import com.badlogic.gdx.utils.ObjectMap.Values;
import com.badlogic.gdx.utils.OrderedMap;
public abstract class Transmuter implements Cloneable,Serializable {
public enum CaseType{Rien,Cuivre_seul,Fibre_seul,Cuivre,Fibre,Tout,Nimporte};
public enum Class{Structure,Charge,Direction,Filtrage,Synthese,Detection,Divers,Scenario};
public enum Angular{A00,A90,A180,A270};
public abstract class Transmuter implements Cloneable, Serializable {
public enum CaseType {
Rien, Cuivre_seul, Fibre_seul, Cuivre, Fibre, Tout, Nimporte
};
public enum Class {
Structure, Charge, Direction, Filtrage, Synthese, Detection, Divers, Scenario
};
public enum Angular {
A00, A90, A180, A270
};
protected Level level;
protected Angular Rotation;
public Transmuter(Level level) {
this.level=level;
this.Rotation=Angular.A00;
this.level = level;
this.Rotation = Angular.A00;
}
public String getName() {
return "";
}
public String getDesc() {
return "";
}
public String getaClass() {
return "";
}
public void ProcessCycle() {
}
public void Run() {
}
public void Unlock() {
}
public void Upgrade() {
}
}
public void Activate() {
}
public void UpgradeTemp() {
}
public void UpgradeNrj() {
}
}
public void UpgradeRayon() {
}
}
public void UpgradeCycle() {
}
public boolean isTransmuter(String Name) {
return Name.equals(this.getName());
return Name.equals(this.getName());
}
public CaseType getTilestype(int order) {
return null;
}
public OrderedMap<Vector2, Integer> getTilesidrotated() {
return null;
}
public Values<Integer> getTilesid() {
public Values<Integer> getTilesid() {
return null;
}
public int getMaxActivationLevel() {
return 0;
}
public int getActivationLevel() {
return 0;
}
public boolean getActivation() {
return false;
}
public int getPrice() {
return 0;
}
public int getSize() {
return 0;
}
@ -105,120 +111,162 @@ public abstract class Transmuter implements Cloneable,Serializable {
public int getResearch() {
return 0;
}
public boolean isUpgradable() {
return false;
}
public boolean isUnlockable() {
return false;
}
public boolean isShowed() {
return false;
}
public void SetShowed(boolean value) {
}
public boolean isActivable() {
return false;
}
public boolean isUpgradableTemp() {
return false;
}
public boolean isUpgradableCycle() {
return false;
}
public boolean isUpgradableRayon() {
return false;
}
public boolean isUpgradableNrj() {
return false;
}
public Transmuter getUpgrade() {
return null;
}
public Transmuter getUnlock() {
return null;
}
public int getUpgradeCycle() {
return 0;
}
public int getUpgradeTemp() {
return 0;
}
public int getUpgradeRayon() {
return 0;
}
public int getUpgradeNrj() {
return 0;
}
public float getUsedTemp() {
return 0;
}
public float getUsedRayon() {
return 0;
}
public float getUsedNrj() {
return 0;
}
public float getTurnTemp() {
return 0;
}
public float getTurnRayon() {
return 0;
}
public float getTurnNrj() {
return 0;
}
public String getInformations() {
OrderedMap<Vector2, Integer> tiles=this.getTilesidrotated();
Entries<Vector2, Integer> iterator=tiles.iterator();
OrderedMap<Vector2, Integer> tiles = this.getTilesidrotated();
Entries<Vector2, Integer> iterator = tiles.iterator();
String result;
result="**********************************\n"+"Name:"+this.getName()+"\nClass:"+this.getaClass()+" Rotation:"+this.getRotation()+"\nPrice:"+this.getPrice()+" Tech:"+this.getTechnology()+"\nResearch:"+this.getResearch()+" Size:"+this.getSize()+"\nActivable:"+this.isActivable()+" Activation:"+this.getActivationLevel()+" Visible:"+this.isShowed()+"\nUpgradable:"+((this.isUpgradable())?this.getUpgrade().getName():this.isUpgradable())+" Unlockable:"+((this.isUnlockable())?this.getUnlock().getName():this.isUnlockable())+"\nUpgrade Cycle:"+this.getUpgradeCycle()+" upgrade:"+this.isUpgradableCycle()+"\nUpgrade Temperature:"+this.getUpgradeTemp()+" upgrade:"+this.isUpgradableTemp()+"\nUpgrade Nrj:"+this.getUpgradeNrj()+" upgrade:"+this.isUpgradableNrj()+"\nUpgrade Rayon:"+this.getUpgradeRayon()+" upgrade:"+this.isUpgradableRayon()+"\nTemperature /turn:"+this.getTurnTemp()+" Rayon /turn:"+this.getTurnRayon()+" Nrj /turn:"+this.getTurnNrj()+"\nTemperature /use:"+this.getUsedTemp()+" Rayon /use:"+this.getUsedRayon()+" Nrj /use:"+this.getUsedNrj()+"\nTiles:";
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**********************************";
result = "**********************************\n" + "Name:"
+ this.getName()
+ "\nClass:"
+ this.getaClass()
+ " Rotation:"
+ this.getRotation()
+ "\nPrice:"
+ this.getPrice()
+ " Tech:"
+ this.getTechnology()
+ "\nResearch:"
+ this.getResearch()
+ " Size:"
+ this.getSize()
+ "\nActivable:"
+ this.isActivable()
+ " Activation:"
+ this.getActivationLevel()
+ " Visible:"
+ this.isShowed()
+ "\nUpgradable:"
+ ((this.isUpgradable()) ? this.getUpgrade().getName() : this
.isUpgradable())
+ " Unlockable:"
+ ((this.isUnlockable()) ? this.getUnlock().getName() : this
.isUnlockable()) + "\nUpgrade Cycle:"
+ this.getUpgradeCycle() + " upgrade:"
+ this.isUpgradableCycle() + "\nUpgrade Temperature:"
+ this.getUpgradeTemp() + " upgrade:" + this.isUpgradableTemp()
+ "\nUpgrade Nrj:" + this.getUpgradeNrj() + " upgrade:"
+ this.isUpgradableNrj() + "\nUpgrade Rayon:"
+ this.getUpgradeRayon() + " upgrade:"
+ this.isUpgradableRayon() + "\nTemperature /turn:"
+ this.getTurnTemp() + " Rayon /turn:" + this.getTurnRayon()
+ " Nrj /turn:" + this.getTurnNrj() + "\nTemperature /use:"
+ this.getUsedTemp() + " Rayon /use:" + this.getUsedRayon()
+ " Nrj /use:" + this.getUsedNrj() + "\nTiles:";
Values<Integer> allTiles = this.getTilesid().iterator();
while (allTiles.hasNext())
result += String.valueOf(allTiles.next()) + " ";
while (iterator.hasNext()) {
Entry<Vector2, Integer> all = iterator.next();
result += "\ncoords:"
+ all.key.x
+ ","
+ all.key.y
+ " type: "
+ this.getTilestype(tiles.keys().toArray()
.indexOf(all.key, false)) + " id:" + all.value;
}
result += "\n**********************************";
return result;
}
public Angular getRotation() {
return this.Rotation;
}
public void setRotation(Angular rotation) {
this.Rotation=rotation;
this.Rotation = rotation;
}
public Object clone() {
Object o = null;
try {
o = super.clone();
} catch(CloneNotSupportedException cnse) {
} catch (CloneNotSupportedException cnse) {
cnse.printStackTrace(System.err);
}
return o;

View File

@ -7,101 +7,100 @@ import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
public abstract class Base {
public enum datatype{statdata,userdata,gamedata}
public Base(datatype model,String param) {
}
public Base() {
}
public String getParam() {
return null;
}
//Gestion type Gamebase
public enum datatype {
statdata, userdata, gamedata
}
public Base(datatype model, String param) {
}
public Base() {
}
public String getParam() {
return null;
}
// Gestion type Gamebase
public Array<String> getworlds() {
return null;
}
public Array<Level> getworld(String description) {
public Array<Level> getworld(String description) {
return null;
}
public boolean setworld(Array<Level> world, String description) {
return false;
}
public boolean deleteworld(String description) {
return false;
}
}
//Gestion type Userbase
public boolean getlevellock(int user,int level){
// Gestion type Userbase
public boolean getlevellock(int user, int level) {
return false;
}
public boolean setlevelunlock(int user,int level){
public boolean setlevelunlock(int user, int level) {
return false;
}
public Array<Transmuter> getTransmuters(int user){
public Array<Transmuter> getTransmuters(int user) {
return null;
}
public boolean setTransmuters(int user,Array<Transmuter> transmuters){
public boolean setTransmuters(int user, Array<Transmuter> transmuters) {
return false;
}
public int getResearchpoint(int user){
public int getResearchpoint(int user) {
return 0;
}
public boolean setResearchpoint(int user, int point){
public boolean setResearchpoint(int user, int point) {
return false;
}
public Grid getGrid(int user,int level, int place){
public Grid getGrid(int user, int level, int place) {
return null;
}
public Grid getGrid(int user,int level, String tag){
public Grid getGrid(int user, int level, String tag) {
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;
}
public boolean setGrid(int user,int level, Grid data){
public boolean setGrid(int user, int level, Grid data) {
return false;
}
public Array<String> getGrids(int user, int level){
public Array<String> getGrids(int user, int level) {
return null;
}
//Gestion type Stat
//Commun
public boolean Eraseall(datatype base){
// Gestion type Stat
// Commun
public boolean Eraseall(datatype base) {
return false;
}
public static boolean isHandling(datatype base){
public static boolean isHandling(datatype base) {
return false;
}
public void Close() {
}
public String getprefix() {
return "";
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,20 +1,14 @@
package fr.evolving.renderers;
import java.util.List;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import fr.evolving.UI.Objectives;
import fr.evolving.assets.AssetLoader;
import fr.evolving.effects.Laser;
import fr.evolving.screens.LevelScreen;
@ -31,115 +25,147 @@ public class LevelRenderer {
Laser Laser;
public TextureRegion Texture_logobig;
BitmapFont font;
public LevelRenderer(LevelScreen LevelScreen) {
this.LevelScreen=LevelScreen;
this.scrollx=0;
this.scrolly=0;
this.dirx=1;
this.diry=1;
this.LevelScreen = LevelScreen;
this.scrollx = 0;
this.scrolly = 0;
this.dirx = 1;
this.diry = 1;
batcher = new SpriteBatch();
batcher2 = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
Laser=new Laser();
Laser = new Laser();
AssetLoader.viewport.apply();
font=AssetLoader.Skin_level.getFont("OpenDyslexicAlta-22");
font = AssetLoader.Skin_level.getFont("OpenDyslexicAlta-22");
}
public void evolve() {
this.scrollx+=dirx;
this.scrolly+=diry;
if (this.scrollx>1500)
this.scrolly+=diry;
if (this.scrollx > 1024)
this.dirx = -1;
if (this.scrolly > 768)
this.diry = -1;
if (this.scrollx < 0)
this.dirx = 1;
if (this.scrolly < 0)
this.diry = 1;
Laser.i+=0.3f;
if (Laser.i>10.0f) {
Laser.i=0;
this.scrollx += dirx;
this.scrolly += diry;
if (this.scrollx > 1500)
this.scrolly += diry;
if (this.scrollx > 1024)
this.dirx = -1;
if (this.scrolly > 768)
this.diry = -1;
if (this.scrollx < 0)
this.dirx = 1;
if (this.scrolly < 0)
this.diry = 1;
Laser.i += 0.3f;
if (Laser.i > 10.0f) {
Laser.i = 0;
}
}
public void render(float delta, float runTime) {
Gdx.gl.glClearColor(0, 0, 0, 1);
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]);
batcher.begin();
batcher.setProjectionMatrix(AssetLoader.Camera.combined);
batcher.setColor(0.25f,0.25f,0.25f,1f);
batcher.draw(AssetLoader.Texture_fond2, 0, 0, this.scrollx/2, this.scrolly/2, AssetLoader.width, AssetLoader.height);
batcher.setColor(0.7f,0.7f,0.7f,1);
batcher.draw(AssetLoader.Texture_fond, 0, 0, this.scrollx, this.scrolly, AssetLoader.width, AssetLoader.height);
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.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();
batcher2.begin();
batcher2.setProjectionMatrix(AssetLoader.Camera.combined);
batcher2.setColor(Color.WHITE);
Texture_logobig=AssetLoader.Skin_level.getRegion("logo3");
batcher2.draw(Texture_logobig,120, AssetLoader.height-Texture_logobig.getRegionHeight());
Texture_logobig = AssetLoader.Skin_level.getRegion("logo3");
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);
if (LevelScreen.selected.level.Tech>0)
font.draw(batcher2, "Recompenses", 1215, AssetLoader.height-15);
if (LevelScreen.selected.level.Cout>0) {
if (LevelScreen.selected.level.Tech > 0)
font.draw(batcher2, "Recompenses", 1215,
AssetLoader.height - 15);
if (LevelScreen.selected.level.Cout > 0) {
font.draw(batcher2, "Ressources", 1215, 145);
font.draw(batcher2, "Objectifs", 1215, 295);
}
if (LevelScreen.selected.level.aWorld>0)
if (LevelScreen.selected.level.aWorld > 0)
font.draw(batcher2, "Handicaps", 1215, 605);
font.draw(batcher2, "", 1215, 145);
}
batcher2.end();
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glEnable(GL20.GL_BLEND);
shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.setProjectionMatrix(AssetLoader.Camera.combined);
shapeRenderer.setColor(0.5f, 0.5f, 0.5f, 0.5f);
if (LevelScreen.selected!=null) {
if (LevelScreen.selected != null) {
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, 160,250, 140);
shapeRenderer.rect(1210, 160, 250, 140);
}
if (LevelScreen.selected.level.aWorld>0)
shapeRenderer.rect(1210, 310,250, 300);
if (LevelScreen.selected.level.Tech>0)
shapeRenderer.rect(1210, 620,250, AssetLoader.height-630);
if (LevelScreen.selected.level.aWorld > 0)
shapeRenderer.rect(1210, 310, 250, 300);
if (LevelScreen.selected.level.Tech > 0)
shapeRenderer.rect(1210, 620, 250, AssetLoader.height - 630);
}
if (!LevelScreen.MenuSolo.isVisible())
shapeRenderer.rect(1470, 10, 440, AssetLoader.height-20);
shapeRenderer.rect(1470, 10, 440, AssetLoader.height - 20);
shapeRenderer.end();
if (LevelScreen.buttonLevels!=null)
for (int i=0;i<LevelScreen.buttonLevels.length;i++) {
if (LevelScreen.buttonLevels[i]!=null) {
for (int[] item : LevelScreen.buttonLevels[i].level.Link)
{
int found=-1;
for (int j=0;j<LevelScreen.buttonLevels.length;j++)
{
if ((item.length==2) && (LevelScreen.buttonLevels[j]!=null) && (LevelScreen.buttonLevels[j].level.aWorld==item[0]) && (LevelScreen.buttonLevels[j].level.aLevel==item[1])) {
found=j;
break;
}
}
if (found!=-1)
{
if (!LevelScreen.logosmall.isChecked())
Laser.draw(batcher,LevelScreen.buttonLevels[i].level.X,LevelScreen.buttonLevels[i].level.Y*AssetLoader.ratio,LevelScreen.buttonLevels[found].level.X,LevelScreen.buttonLevels[found].level.Y*AssetLoader.ratio,10,0.5f,LevelScreen.buttonLevels[found].Activated,LevelScreen.buttonLevels[i].getLevelcolor(),LevelScreen.buttonLevels[found].getLevelcolor());
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());
}
}
if (LevelScreen.buttonLevels != null)
for (int i = 0; i < LevelScreen.buttonLevels.length; i++) {
if (LevelScreen.buttonLevels[i] != null) {
for (int[] item : LevelScreen.buttonLevels[i].level.Link) {
int found = -1;
for (int j = 0; j < LevelScreen.buttonLevels.length; j++) {
if ((item.length == 2)
&& (LevelScreen.buttonLevels[j] != null)
&& (LevelScreen.buttonLevels[j].level.aWorld == item[0])
&& (LevelScreen.buttonLevels[j].level.aLevel == item[1])) {
found = j;
break;
}
}
if (found != -1) {
if (!LevelScreen.logosmall.isChecked())
Laser.draw(
batcher,
LevelScreen.buttonLevels[i].level.X,
LevelScreen.buttonLevels[i].level.Y
* AssetLoader.ratio,
LevelScreen.buttonLevels[found].level.X,
LevelScreen.buttonLevels[found].level.Y
* AssetLoader.ratio,
10,
0.5f,
LevelScreen.buttonLevels[found].Activated,
LevelScreen.buttonLevels[i]
.getLevelcolor(),
LevelScreen.buttonLevels[found]
.getLevelcolor());
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;
import java.util.Timer;
import java.util.TimerTask;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.List;
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextArea;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.viewport.FillViewport;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.ScalingViewport;
import com.badlogic.gdx.utils.viewport.StretchViewport;
import fr.evolving.renderers.LevelRenderer;
import fr.evolving.UI.ButtonLevel;
import fr.evolving.UI.Objectives;
import fr.evolving.UI.ServerList;
import fr.evolving.UI.WarnDialog;
import fr.evolving.UI.Worldlist;
import fr.evolving.game.main;
import java.util.Timer;
import java.util.TimerTask;
import fr.evolving.assets.AssetLoader;
import fr.evolving.assets.InitWorlds;
import fr.evolving.assets.Preference;
import fr.evolving.automata.Level;
import fr.evolving.automata.Transmuter;
import fr.evolving.database.Base;
import fr.evolving.database.Base.datatype;
import fr.evolving.database.DatabaseManager;
import fr.evolving.database.LocalBase;
import fr.evolving.database.SqlBase;
import fr.evolving.effects.Laser;
import fr.evolving.renderers.LevelRenderer;
public class LevelScreen implements Screen {
public ButtonLevel[] buttonLevels;
@ -57,61 +37,65 @@ public class LevelScreen implements Screen {
private float runTime;
private Timer ScrollTimer;
private TimerTask ScrollTask;
private Stage stage;
private Table table;
private WarnDialog dialog;
private ImageButton Previous,Next,Exit;
public ImageButton logosmall;
public Image MenuSolo,MenuMulti,MenuScenario;
private ImageTextButton cout,tech,cycle,temp,rayon,nrj;
private TextButton buttonConnect,buttonPlay,buttonStat,buttonSave, buttonApply, buttonPlaythis;
private ServerList Statdata,Userdata,Gamedata;
private Stage stage;
private Table table;
private WarnDialog dialog;
private ImageButton Previous, Next, Exit;
public ImageButton logosmall;
public Image MenuSolo, MenuMulti, MenuScenario;
private ImageTextButton cout, tech, cycle, temp, rayon, nrj;
private TextButton buttonConnect, buttonPlay, buttonStat, buttonSave,
buttonApply, buttonPlaythis;
private ServerList Statdata, Userdata, Gamedata;
private Worldlist Worlddata;
private Label Statdatalabel, Userdatalabel, Gamedatalabel,Worlddatalabel;
private Label Statdatalabel, Userdatalabel, Gamedatalabel, Worlddatalabel;
private Array<Level> thelevels;
private TextArea TextDescriptive;
public int world;
private Objectives Victory;
public ButtonLevel selected;
public int getMaxWorld() {
int max=0;
for (Level level :thelevels)
if (level!=null && level.aWorld>max)
max=level.aWorld;
return max;
int max = 0;
for (Level level : thelevels)
if (level != null && level.aWorld > max)
max = level.aWorld;
return max;
}
public void play() {
if (!AssetLoader.Datahandler.verifyall())
Gdx.app.debug(getClass().getSimpleName(),"Pilotes de bases de donnée défaillant.");
else
{
Gdx.app.debug(getClass().getSimpleName(),"Chargement des mondes depuis la base.");
Gdx.app.debug(getClass().getSimpleName(),
"Pilotes de bases de donnée défaillant.");
else {
Gdx.app.debug(getClass().getSimpleName(),
"Chargement des mondes depuis la base.");
try {
if (world<0)
world=0;
thelevels=AssetLoader.Datahandler.game().getworld(Preference.prefs.getString("world"));
/*thelevels= InitWorlds.go();
AssetLoader.Datahandler.game().setworld(thelevels,Preference.prefs.getString("world")); */
if (world < 0)
world = 0;
thelevels = AssetLoader.Datahandler.game().getworld(
Preference.prefs.getString("world"));
/*
* thelevels= InitWorlds.go();
* AssetLoader.Datahandler.game().setworld
* (thelevels,Preference.prefs.getString("world"));
*/
loadWorld(world);
Previous.setVisible(true);
Next.setVisible(true);
buttonPlay.setVisible(true);
TextDescriptive.setVisible(true);
}
catch (Exception e) {
TextDescriptive.setVisible(true);
} catch (Exception e) {
Previous.setVisible(false);
Next.setVisible(false);
buttonPlay.setVisible(false);
TextDescriptive.setVisible(false);
TextDescriptive.setVisible(false);
}
}
}
public void menu() {
selected=null;
selected = null;
cout.setVisible(false);
tech.setVisible(false);
cycle.setVisible(false);
@ -121,7 +105,7 @@ public class LevelScreen implements Screen {
Previous.setVisible(false);
Next.setVisible(false);
Victory.setVisible(false);
Exit.setPosition(1820,AssetLoader.height-100);
Exit.setPosition(1820, AssetLoader.height - 100);
buttonPlay.setVisible(false);
TextDescriptive.setVisible(false);
MenuSolo.setVisible(true);
@ -144,23 +128,29 @@ public class LevelScreen implements Screen {
MenuSolo.setRotation(0);
MenuSolo.setScale(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.setScale(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.setScale(1f);
MenuScenario.setColor(1f, 1f, 1f, 1f);
MenuScenario.setPosition(0, AssetLoader.height*7/20-300);
MenuSolo.addAction(Actions.sequence(Actions.moveTo((AssetLoader.width-MenuSolo.getWidth())/2, AssetLoader.height*17/20-300, 0.25f)));
MenuMulti.addAction(Actions.sequence(Actions.fadeIn(0.1f),Actions.moveTo((AssetLoader.width-MenuMulti.getWidth())/2, AssetLoader.height*12/20-300, 0.25f)));
MenuScenario.addAction(Actions.sequence(Actions.fadeIn(0.2f),Actions.moveTo((AssetLoader.width-MenuScenario.getWidth())/2, AssetLoader.height*7/20-300, 0.25f)));
MenuScenario.setPosition(0, AssetLoader.height * 7 / 20 - 300);
MenuSolo.addAction(Actions.sequence(Actions.moveTo(
(AssetLoader.width - MenuSolo.getWidth()) / 2,
AssetLoader.height * 17 / 20 - 300, 0.25f)));
MenuMulti.addAction(Actions.sequence(Actions.fadeIn(0.1f), Actions
.moveTo((AssetLoader.width - MenuMulti.getWidth()) / 2,
AssetLoader.height * 12 / 20 - 300, 0.25f)));
MenuScenario.addAction(Actions.sequence(Actions.fadeIn(0.2f), Actions
.moveTo((AssetLoader.width - MenuScenario.getWidth()) / 2,
AssetLoader.height * 7 / 20 - 300, 0.25f)));
}
public void initlevel() {
selected=null;
selected = null;
buttonPlay.setVisible(false);
TextDescriptive.setVisible(false);
cout.setVisible(false);
@ -172,46 +162,46 @@ public class LevelScreen implements Screen {
Previous.setVisible(false);
Next.setVisible(false);
Victory.setVisible(false);
if (buttonLevels!=null)
for (int j=0;j<10;j++)
if (buttonLevels[j]!=null) {
if (buttonLevels != null)
for (int j = 0; j < 10; j++)
if (buttonLevels[j] != null) {
buttonLevels[j].remove();
buttonLevels[j]=null;
buttonLevels[j] = null;
}
}
public void level() {
Exit.setPosition(1110, AssetLoader.height-Exit.getHeight()-5);
Exit.setPosition(1110, AssetLoader.height - Exit.getHeight() - 5);
MenuSolo.setVisible(false);
MenuMulti.setVisible(false);
MenuScenario.setVisible(false);
buttonConnect.setVisible(true);
buttonStat.setVisible(true);
buttonStat.setVisible(true);
SetButtonStat();
if (Preference.prefs.contains("world"))
play();
}
public void SetButtonConnect() {
buttonStat.setColor(1f,1f,1f,1f);
buttonConnect.setColor(1f,0,0,1f);
buttonStat.setColor(1f, 1f, 1f, 1f);
buttonConnect.setColor(1f, 0, 0, 1f);
Statdata.setVisible(true);
Userdata.setVisible(true);
Gamedata.setVisible(true);
Statdatalabel.setVisible(true);
Userdatalabel.setVisible(true);
Gamedatalabel.setVisible(true);
Gamedatalabel.setVisible(true);
buttonSave.setVisible(true);
buttonApply.setVisible(true);
Worlddatalabel.setVisible(true);
Worlddata.setVisible(true);
buttonPlaythis.setVisible(true);
buttonPlaythis.setVisible(true);
}
public void SetButtonStat() {
buttonConnect.setColor(1f,1f,1f,1f);
buttonStat.setColor(1f,0,0,1f);
buttonStat.setColor(1f,0,0,1f);
buttonConnect.setColor(1f, 1f, 1f, 1f);
buttonStat.setColor(1f, 0, 0, 1f);
buttonStat.setColor(1f, 0, 0, 1f);
Statdata.setVisible(false);
Userdata.setVisible(false);
Gamedata.setVisible(false);
@ -224,148 +214,174 @@ public class LevelScreen implements Screen {
Worlddata.setVisible(false);
buttonPlaythis.setVisible(false);
}
public void loadWorld(int aworld) {
int i=0;
if (buttonLevels!=null)
for (int j=0;j<10;j++) {
if (buttonLevels[j]!=null) {
buttonLevels[j].remove();
buttonLevels[j]=null;
int i = 0;
if (buttonLevels != null)
for (int j = 0; j < 10; j++) {
if (buttonLevels[j] != null) {
buttonLevels[j].remove();
buttonLevels[j] = null;
}
}
}
buttonLevels = null;
buttonLevels = new ButtonLevel[10];
for (Level level :thelevels) {
if (level!=null && level.aWorld==aworld) {
buttonLevels[i]=new ButtonLevel(level,true,AssetLoader.ratio);
Gdx.app.debug(getClass().getSimpleName(),"Ajout du niveau :"+level.Name+""+String.valueOf(level.aLevel));
buttonLevels[i++].addListener(new ClickListener(){
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ButtonLevel abutton = (ButtonLevel)event.getListenerActor();
Gdx.app.debug(event.getListenerActor().toString(), "Enter button ");
if (!abutton.isChecked())
showlevel(abutton);
}
public void exit(InputEvent event, float x, float y, int pointer, Actor fromActor) {
ButtonLevel abutton = (ButtonLevel)event.getListenerActor();
Gdx.app.debug(event.getListenerActor().toString(), "Enter button ");
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 (Level level : thelevels) {
if (level != null && level.aWorld == aworld) {
buttonLevels[i] = new ButtonLevel(level, true,
AssetLoader.ratio);
Gdx.app.debug(getClass().getSimpleName(), "Ajout du niveau :"
+ level.Name + "" + String.valueOf(level.aLevel));
buttonLevels[i++].addListener(new ClickListener() {
@Override
public void enter(InputEvent event, float x, float y,
int pointer, Actor fromActor) {
ButtonLevel abutton = (ButtonLevel) event
.getListenerActor();
Gdx.app.debug(event.getListenerActor().toString(),
"Enter button ");
if (!abutton.isChecked())
showlevel(abutton);
}
public void exit(InputEvent event, float x, float y,
int pointer, Actor fromActor) {
ButtonLevel abutton = (ButtonLevel) event
.getListenerActor();
Gdx.app.debug(event.getListenerActor().toString(),
"Enter button ");
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++) {
if (buttonLevels[j]!=null) {
for (int j = 0; j < 10; j++) {
if (buttonLevels[j] != null) {
stage.addActor(buttonLevels[j]);
}
}
Gdx.app.debug(getClass().getSimpleName(),"Mise en place du level 0.");
world=world;
Gdx.app.debug(getClass().getSimpleName(), "Mise en place du level 0.");
world = world;
buttonLevels[0].setChecked(true);
showlevel(buttonLevels[0]);
}
public LevelScreen(int aworld) {
this.world=aworld;
Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table)");
this.world = aworld;
Gdx.app.debug(getClass().getSimpleName(),
"Création des elements primordiaux du screen (stage, renderer, table)");
stage = new Stage(AssetLoader.viewport);
table = new Table();
Renderer=new LevelRenderer(this);
dialog=new WarnDialog(AssetLoader.Skin_ui);
Gdx.app.debug(getClass().getSimpleName(),"Mise en place du timer.");
ScrollTimer=new Timer();
ScrollTask = new TimerTask()
{
Renderer = new LevelRenderer(this);
dialog = new WarnDialog(AssetLoader.Skin_ui);
Gdx.app.debug(getClass().getSimpleName(), "Mise en place du timer.");
ScrollTimer = new Timer();
ScrollTask = new TimerTask() {
@Override
public void run()
{
public void run() {
Renderer.evolve();
}
}
};
ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30);
Gdx.app.debug(getClass().getSimpleName(),"Création du menu.");
MenuSolo=new Image(AssetLoader.Skin_level,"menu1");
MenuSolo.setOrigin(MenuSolo.getWidth()/2, MenuSolo.getHeight()/2);
Gdx.app.debug(getClass().getSimpleName(), "Création du menu.");
MenuSolo = new Image(AssetLoader.Skin_level, "menu1");
MenuSolo.setOrigin(MenuSolo.getWidth() / 2, MenuSolo.getHeight() / 2);
MenuSolo.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
MenuMulti.addAction(Actions.fadeOut(0.5f));
MenuScenario.addAction(Actions.fadeOut(0.5f));
MenuSolo.addAction(Actions.sequence(Actions.parallel(Actions.rotateBy(640, 0.5f),Actions.scaleTo(0.05f, 0.05f, 0.5f)),Actions.run(new Runnable() {
public void run() {
level();
}
})));
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() {
public void run() {
level();
}
})));
}
});
MenuMulti=new Image(AssetLoader.Skin_level,"menu2");
MenuMulti.setOrigin(MenuMulti.getWidth()/2, MenuMulti.getHeight()/2);
MenuMulti = new Image(AssetLoader.Skin_level, "menu2");
MenuMulti
.setOrigin(MenuMulti.getWidth() / 2, MenuMulti.getHeight() / 2);
MenuMulti.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
MenuSolo.addAction(Actions.fadeOut(0.5f));
MenuScenario.addAction(Actions.fadeOut(0.5f));
MenuMulti.addAction(Actions.sequence(Actions.parallel(Actions.rotateBy(640, 0.5f),Actions.scaleTo(0.05f, 0.05f, 0.5f)),Actions.run(new Runnable() {
public void run() {
level();
}
})));
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() {
public void run() {
level();
}
})));
}
});
MenuScenario=new Image(AssetLoader.Skin_level,"menu3");
MenuScenario.setOrigin(MenuScenario.getWidth()/2, MenuScenario.getHeight()/2);
MenuScenario = new Image(AssetLoader.Skin_level, "menu3");
MenuScenario.setOrigin(MenuScenario.getWidth() / 2,
MenuScenario.getHeight() / 2);
MenuScenario.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
MenuMulti.addAction(Actions.fadeOut(0.5f));
MenuSolo.addAction(Actions.fadeOut(0.5f));
MenuScenario.addAction(Actions.sequence(Actions.parallel(Actions.rotateBy(640, 0.5f),Actions.scaleTo(0.05f, 0.05f, 0.5f)),Actions.run(new Runnable() {
public void run() {
level();
}
})));
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() {
public void run() {
level();
}
})));
}
});
Gdx.app.debug(getClass().getSimpleName(),"Création des boutons.");
logosmall=new ImageButton(AssetLoader.Skin_level,"logosmall");
logosmall.setPosition(20, AssetLoader.height-175+logosmall.getHeight()/2);
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,"Descriptif");
Gdx.app.debug(getClass().getSimpleName(), "Création des boutons.");
logosmall = new ImageButton(AssetLoader.Skin_level, "logosmall");
logosmall.setPosition(20,
AssetLoader.height - 175 + logosmall.getHeight() / 2);
TextDescriptive = new TextArea("Descriptif", AssetLoader.Skin_level,
"Descriptif");
TextDescriptive.setBounds(15, 15, 1185, 100);
buttonApply = new TextButton("Appliquer", AssetLoader.Skin_ui);
buttonApply.setBounds(1680, 350, 190, 40);
buttonApply.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
AssetLoader.Datahandler.CloseAll();
AssetLoader.Datahandler.Attach(Userdata.getModel(),Userdata.getUrl());
AssetLoader.Datahandler.Attach(Statdata.getModel(),Statdata.getUrl());
AssetLoader.Datahandler.Attach(Gamedata.getModel(),Gamedata.getUrl());
AssetLoader.Datahandler.Attach(Userdata.getModel(),
Userdata.getUrl());
AssetLoader.Datahandler.Attach(Statdata.getModel(),
Statdata.getUrl());
AssetLoader.Datahandler.Attach(Gamedata.getModel(),
Gamedata.getUrl());
if (!AssetLoader.Datahandler.verifyall()) {
dialog.Show("Un problème est survenu lors du changement de base de donnée.",stage);
dialog.Show(
"Un problème est survenu lors du changement de base de donnée.",
stage);
initlevel();
}
else
} else
menu();
if (AssetLoader.Datahandler.stat()==null)
Statdata.setColor(1f,0,0,1f);
if (AssetLoader.Datahandler.stat() == null)
Statdata.setColor(1f, 0, 0, 1f);
else
Statdata.setColor(1f,1f,1f,1f);
if (AssetLoader.Datahandler.game()==null)
Gamedata.setColor(1f,0,0,1f);
Statdata.setColor(1f, 1f, 1f, 1f);
if (AssetLoader.Datahandler.game() == null)
Gamedata.setColor(1f, 0, 0, 1f);
else
Gamedata.setColor(1f,1f,1f,1f);
if (AssetLoader.Datahandler.user()==null)
Userdata.setColor(1f,0,0,1f);
Gamedata.setColor(1f, 1f, 1f, 1f);
if (AssetLoader.Datahandler.user() == null)
Userdata.setColor(1f, 0, 0, 1f);
else
Userdata.setColor(1f,1f,1f,1f);
Userdata.setColor(1f, 1f, 1f, 1f);
Worlddata.Refresh();
}
});
@ -377,126 +393,141 @@ public class LevelScreen implements Screen {
Preference.prefs.putString("userdata", Userdata.getUrl());
Preference.prefs.putString("gamedata", Gamedata.getUrl());
Preference.prefs.putString("statdata", Statdata.getUrl());
dialog.Show("Vous devez redemarrer pour bénéfier des changements.",stage);
dialog.Show(
"Vous devez redemarrer pour bénéfier des changements.",
stage);
}
});
buttonConnect = new TextButton("Connexions", AssetLoader.Skin_ui);
buttonConnect.setBounds(1480, AssetLoader.height-60, 190, 40);
buttonConnect.setBounds(1480, AssetLoader.height - 60, 190, 40);
buttonConnect.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
if (!Statdata.isVisible())
SetButtonConnect();
}
}
});
buttonPlay = new TextButton("Jouer", AssetLoader.Skin_ui);
buttonPlay.setBounds(1040, 20, 150, 40);
buttonPlay.addListener(new ClickListener(){
@Override
buttonPlay.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
((Game)Gdx.app.getApplicationListener()).setScreen(new GameScreen(selected.level));
}
});
((Game) Gdx.app.getApplicationListener())
.setScreen(new GameScreen(selected.level));
}
});
buttonStat = new TextButton("Statistiques", AssetLoader.Skin_ui);
buttonStat.setBounds(1710, AssetLoader.height-60, 190, 40);
buttonStat.setBounds(1710, AssetLoader.height - 60, 190, 40);
buttonStat.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
if (Statdata.isVisible())
SetButtonStat();
}
}
});
buttonPlaythis = new TextButton("Jouer ce monde", AssetLoader.Skin_ui);
buttonPlaythis.setBounds(1480, 50, 190, 40);
buttonPlaythis.addListener(new ClickListener() {
public void clicked(InputEvent event, float x, float y) {
if (!AssetLoader.Datahandler.verifyall())
dialog.Show("Impossible de jouer sans bases de données correctement configurée, cliquer sur RAZ si vous ne savez pas revenir à une situation jouable.", stage);
else
{
if (Worlddata.getSelected()==null)
dialog.Show(
"Impossible de jouer sans bases de données correctement configurée, cliquer sur RAZ si vous ne savez pas revenir à une situation jouable.",
stage);
else {
if (Worlddata.getSelected() == null)
dialog.Show("Aucun monde n'a été sélectionné", stage);
else
{
Preference.prefs.putString("world", (String)Worlddata.getSelected());
else {
Preference.prefs.putString("world",
(String) Worlddata.getSelected());
Preference.prefs.flush();
play();
}
}
}
});
Exit=new ImageButton(AssetLoader.Skin_level,"Exit");
Exit.setPosition(1110, AssetLoader.height-Exit.getHeight()-5);
Exit.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if (Exit.getX()<1210)
menu();
else
Gdx.app.exit();
}
Exit = new ImageButton(AssetLoader.Skin_level, "Exit");
Exit.setPosition(1110, AssetLoader.height - Exit.getHeight() - 5);
Exit.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (Exit.getX() < 1210)
menu();
else
Gdx.app.exit();
}
});
Next=new ImageButton(AssetLoader.Skin_level,"Next");
Next = new ImageButton(AssetLoader.Skin_level, "Next");
Next.setPosition(1030, 170);
Next.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if (world<getMaxWorld()) {
world++;
loadWorld(world);
}
Gdx.app.debug(event.getListenerActor().toString(),"World:"+String.valueOf(world)+" Maxworld:"+String.valueOf(getMaxWorld()));
}
});
Previous=new ImageButton(AssetLoader.Skin_level,"Previous");
Next.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (world < getMaxWorld()) {
world++;
loadWorld(world);
}
Gdx.app.debug(event.getListenerActor().toString(),
"World:" + String.valueOf(world) + " Maxworld:"
+ String.valueOf(getMaxWorld()));
}
});
Previous = new ImageButton(AssetLoader.Skin_level, "Previous");
Previous.setPosition(1110, 170);
Previous.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if (world>0) {
world--;
loadWorld(world);
}
Gdx.app.debug(event.getListenerActor().toString(),"World:"+String.valueOf(world)+" Maxworld:"+String.valueOf(getMaxWorld()));
}
});
cout=new ImageTextButton("5",AssetLoader.Skin_level,"cout");
Previous.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (world > 0) {
world--;
loadWorld(world);
}
Gdx.app.debug(event.getListenerActor().toString(),
"World:" + String.valueOf(world) + " Maxworld:"
+ String.valueOf(getMaxWorld()));
}
});
cout = new ImageTextButton("5", AssetLoader.Skin_level, "cout");
cout.setPosition(1250, 48);
tech=new ImageTextButton("10",AssetLoader.Skin_level,"tech");
tech = new ImageTextButton("10", AssetLoader.Skin_level, "tech");
tech.setPosition(1365, 48);
temp=new ImageTextButton("10",AssetLoader.Skin_level,"temp");
temp = new ImageTextButton("10", AssetLoader.Skin_level, "temp");
temp.setPosition(1365, 360);
cycle=new ImageTextButton("10",AssetLoader.Skin_level,"cycle");
cycle = new ImageTextButton("10", AssetLoader.Skin_level, "cycle");
cycle.setPosition(1250, 360);
nrj=new ImageTextButton("10",AssetLoader.Skin_level,"nrj");
nrj = new ImageTextButton("10", AssetLoader.Skin_level, "nrj");
nrj.setPosition(1365, 490);
rayon=new ImageTextButton("10",AssetLoader.Skin_level,"rayon");
rayon = new ImageTextButton("10", AssetLoader.Skin_level, "rayon");
rayon.setPosition(1250, 490);
Gdx.app.debug(getClass().getSimpleName(),"Conditions de victoire.");
Victory=new Objectives();
Victory.setVictory(new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
Gdx.app.debug(getClass().getSimpleName(), "Conditions de victoire.");
Victory = new Objectives();
Victory.setVictory(new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
Victory.setPosition(1216, 185);
String url="http://evolving.fr/servers/list.xml";
Statdata=new ServerList(url,Base.datatype.statdata,AssetLoader.Skin_ui);
Statdatalabel=new Label("Stockage des statistiques:", AssetLoader.Skin_ui, "grey");
Statdata.setBounds(1480, AssetLoader.height-250, 420, 150);
Statdatalabel.setPosition(1480, AssetLoader.height-100);
Userdata=new ServerList(url,Base.datatype.userdata,AssetLoader.Skin_ui);
Userdatalabel=new Label("Stockage des données du joueur:", AssetLoader.Skin_ui, "grey");
Userdata.setBounds(1480, AssetLoader.height-450, 420, 150);
Userdatalabel.setPosition(1480, AssetLoader.height-300);
Gamedata=new ServerList(url,Base.datatype.gamedata,AssetLoader.Skin_ui);
Gamedatalabel=new Label("Stockage des données du jeu:", AssetLoader.Skin_ui, "grey");
Gamedata.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");
String url = "http://evolving.fr/servers/list.xml";
Statdata = new ServerList(url, Base.datatype.statdata,
AssetLoader.Skin_ui);
Statdatalabel = new Label("Stockage des statistiques:",
AssetLoader.Skin_ui, "grey");
Statdata.setBounds(1480, AssetLoader.height - 250, 420, 150);
Statdatalabel.setPosition(1480, AssetLoader.height - 100);
Userdata = new ServerList(url, Base.datatype.userdata,
AssetLoader.Skin_ui);
Userdatalabel = new Label("Stockage des données du joueur:",
AssetLoader.Skin_ui, "grey");
Userdata.setBounds(1480, AssetLoader.height - 450, 420, 150);
Userdatalabel.setPosition(1480, AssetLoader.height - 300);
Gamedata = new ServerList(url, Base.datatype.gamedata,
AssetLoader.Skin_ui);
Gamedatalabel = new Label("Stockage des données du jeu:",
AssetLoader.Skin_ui, "grey");
Gamedata.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);
Worlddatalabel.setPosition(1480, 300);
Gamedata.setWorldlist(Worlddata);
Statdata.Refresh();
Userdata.Refresh();
Gamedata.Refresh();
Gdx.app.debug(getClass().getSimpleName(),"Affichage du menu.");
if (aworld!=-1)
Gdx.app.debug(getClass().getSimpleName(), "Affichage du menu.");
if (aworld != -1)
level();
else
menu();
@ -506,52 +537,52 @@ public class LevelScreen implements Screen {
public void render(float delta) {
runTime += delta;
Renderer.render(delta, runTime);
stage.act();
stage.draw();
stage.act();
stage.draw();
}
@Override
public void resize(int width, int height) {
AssetLoader.viewport.update(width,height);
AssetLoader.viewport.update(width, height);
}
@Override
public void show() {
Gdx.app.log("*****","Affichage du choix des mondes & niveaux.");
table.setFillParent(true);
stage.addActor(MenuSolo);
stage.addActor(MenuMulti);
stage.addActor(MenuScenario);
stage.addActor(TextDescriptive);
stage.addActor(buttonPlaythis);
stage.addActor(Exit);
stage.addActor(Next);
stage.addActor(buttonApply);
stage.addActor(buttonSave);
stage.addActor(buttonPlay);
stage.addActor(buttonConnect);
stage.addActor(buttonStat);
stage.addActor(Previous);
stage.addActor(cout);
stage.addActor(tech);
stage.addActor(cycle);
stage.addActor(nrj);
stage.addActor(temp);
stage.addActor(rayon);
stage.addActor(Victory);
stage.addActor(logosmall);
stage.addActor(Statdata);
stage.addActor(Statdatalabel);
stage.addActor(Userdata);
stage.addActor(Userdatalabel);
stage.addActor(Gamedata);
stage.addActor(Gamedatalabel);
stage.addActor(Worlddata);
stage.addActor(Worlddatalabel);
Gdx.input.setInputProcessor(stage);
Gdx.app.debug("AssetLoader","Début dans la bande son \'intro\'");
Gdx.app.log("*****", "Affichage du choix des mondes & niveaux.");
table.setFillParent(true);
stage.addActor(MenuSolo);
stage.addActor(MenuMulti);
stage.addActor(MenuScenario);
stage.addActor(TextDescriptive);
stage.addActor(buttonPlaythis);
stage.addActor(Exit);
stage.addActor(Next);
stage.addActor(buttonApply);
stage.addActor(buttonSave);
stage.addActor(buttonPlay);
stage.addActor(buttonConnect);
stage.addActor(buttonStat);
stage.addActor(Previous);
stage.addActor(cout);
stage.addActor(tech);
stage.addActor(cycle);
stage.addActor(nrj);
stage.addActor(temp);
stage.addActor(rayon);
stage.addActor(Victory);
stage.addActor(logosmall);
stage.addActor(Statdata);
stage.addActor(Statdatalabel);
stage.addActor(Userdata);
stage.addActor(Userdatalabel);
stage.addActor(Gamedata);
stage.addActor(Gamedatalabel);
stage.addActor(Worlddata);
stage.addActor(Worlddatalabel);
Gdx.input.setInputProcessor(stage);
Gdx.app.debug("AssetLoader", "Début dans la bande son \'intro\'");
AssetLoader.intro.setLooping(true);
AssetLoader.intro.play();
AssetLoader.intro.play();
}
@Override
@ -568,57 +599,49 @@ public class LevelScreen implements Screen {
@Override
public void dispose() {
stage.dispose();
stage.dispose();
}
public void showlevel(ButtonLevel button) {
Gdx.app.debug(getClass().getSimpleName(), "Reading button "+button.level.Name);
Gdx.app.debug(getClass().getSimpleName(), "Reading button "
+ button.level.Name);
TextDescriptive.setText(button.level.Description);
if (button.level.Maxcycle<99999 && button.level.Maxcycle>0) {
if (button.level.Maxcycle < 99999 && button.level.Maxcycle > 0) {
cycle.setText(String.valueOf(button.level.Maxcycle));
cycle.setVisible(true);
}
else
} else
cycle.setVisible(false);
if (button.level.Maxtemp<99999 && button.level.Maxtemp>0) {
if (button.level.Maxtemp < 99999 && button.level.Maxtemp > 0) {
temp.setText(String.valueOf(button.level.Maxtemp));
temp.setVisible(true);
}
else
} else
temp.setVisible(false);
if (button.level.Maxnrj<99999 && button.level.Maxnrj>0) {
if (button.level.Maxnrj < 99999 && button.level.Maxnrj > 0) {
nrj.setText(String.valueOf(button.level.Maxnrj));
nrj.setVisible(true);
}
else
} else
nrj.setVisible(false);
if (button.level.Maxrayon<99999 && button.level.Maxrayon>0) {
if (button.level.Maxrayon < 99999 && button.level.Maxrayon > 0) {
rayon.setText(String.valueOf(button.level.Maxrayon));
rayon.setVisible(true);
}
else
} else
rayon.setVisible(false);
if (button.level.Cout>0) {
if (button.level.Cout > 0) {
cout.setText(String.valueOf(button.level.Cout));
cout.setVisible(true);
}
else
} else
cout.setVisible(false);
if (button.level.Tech>=1) {
if (button.level.Tech >= 1) {
tech.setText(String.valueOf(button.level.Tech));
tech.setVisible(true);
}
else
} else
tech.setVisible(false);
Victory.setVisible(button.level.Cout>0);
Victory.setVisible(button.level.Cout > 0);
Victory.setVictory(button.level.Victory);
//for (int i = 0;i<thelevels.length;i++) {
// if (thelevels[i] != null && buttonLevels[i]!=button)
// buttonLevels[i].setChecked(false);
if (selected!=null)
if (selected != null)
selected.setChecked(false);
selected=button;
selected = button;
button.setChecked(true);
}
}
}

View File

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