diff --git a/core/src/fr/evolving/UI/ButtonLevel.java b/core/src/fr/evolving/UI/ButtonLevel.java index 6bc4aac..07e30df 100644 --- a/core/src/fr/evolving/UI/ButtonLevel.java +++ b/core/src/fr/evolving/UI/ButtonLevel.java @@ -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); } - + } diff --git a/core/src/fr/evolving/UI/Menu.java b/core/src/fr/evolving/UI/Menu.java index 8a6271c..98928f7 100644 --- a/core/src/fr/evolving/UI/Menu.java +++ b/core/src/fr/evolving/UI/Menu.java @@ -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 tiles=transmuter.getTilesidrotated(); - Entries 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 tiles = transmuter.getTilesidrotated(); + Entries iterator = tiles.iterator(); + while (iterator.hasNext()) { Entry 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> keySetIterator = transmuter.getTilesidrotated().iterator(); - while(keySetIterator.hasNext()){ - Entry 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> keySetIterator = transmuter + .getTilesidrotated().iterator(); + while (keySetIterator.hasNext()) { + Entry 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(); + } } diff --git a/core/src/fr/evolving/UI/Objectives.java b/core/src/fr/evolving/UI/Objectives.java index 3a1ad9e..fd6d423 100644 --- a/core/src/fr/evolving/UI/Objectives.java +++ b/core/src/fr/evolving/UI/Objectives.java @@ -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; } - } - + } } diff --git a/core/src/fr/evolving/UI/ServerList.java b/core/src/fr/evolving/UI/ServerList.java index 6fc52f6..a0773d5 100644 --- a/core/src/fr/evolving/UI/ServerList.java +++ b/core/src/fr/evolving/UI/ServerList.java @@ -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 resultxml; + Array resultstring = new Array(); + 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 resultxml; - Array resultstring=new Array(); - 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 resultstring=new Array(); - 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 resultstring = new Array(); + 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() { + } + }); } } diff --git a/core/src/fr/evolving/UI/TouchMaptiles.java b/core/src/fr/evolving/UI/TouchMaptiles.java index 67cdcf5..f775df6 100644 --- a/core/src/fr/evolving/UI/TouchMaptiles.java +++ b/core/src/fr/evolving/UI/TouchMaptiles.java @@ -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 (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(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(); + } } diff --git a/core/src/fr/evolving/UI/WarnDialog.java b/core/src/fr/evolving/UI/WarnDialog.java index 6d8f28e..d031272 100644 --- a/core/src/fr/evolving/UI/WarnDialog.java +++ b/core/src/fr/evolving/UI/WarnDialog.java @@ -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); } diff --git a/core/src/fr/evolving/UI/Worldlist.java b/core/src/fr/evolving/UI/Worldlist.java index 6edbc47..e790db2 100644 --- a/core/src/fr/evolving/UI/Worldlist.java +++ b/core/src/fr/evolving/UI/Worldlist.java @@ -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 worlds=null; - if (AssetLoader.Datahandler.game()!=null) - worlds=AssetLoader.Datahandler.game().getworlds(); - if (worlds==null) - worlds=new Array(); + Array worlds = null; + if (AssetLoader.Datahandler.game() != null) + worlds = AssetLoader.Datahandler.game().getworlds(); + if (worlds == null) + worlds = new Array(); this.setItems(worlds); } } diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index 51bd247..45e57f4 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -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 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 allregions=Atlas_level.getRegions(); - Gdx.app.debug("AssetLoader",allregions.size+" régions disponibles"); - for (int i=0;i frameTiles=new Array(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(); - 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 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 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 frameTiles = new Array( + 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(); + 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 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() { diff --git a/core/src/fr/evolving/assets/InitWorlds.java b/core/src/fr/evolving/assets/InitWorlds.java index 7648b07..ece06ce 100644 --- a/core/src/fr/evolving/assets/InitWorlds.java +++ b/core/src/fr/evolving/assets/InitWorlds.java @@ -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 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 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(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(thelevels); + } } diff --git a/core/src/fr/evolving/assets/Preference.java b/core/src/fr/evolving/assets/Preference.java index db8c629..7125618 100644 --- a/core/src/fr/evolving/assets/Preference.java +++ b/core/src/fr/evolving/assets/Preference.java @@ -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(); - } - } - - - - diff --git a/core/src/fr/evolving/automata/Cell.java b/core/src/fr/evolving/automata/Cell.java index 19aefa2..c43ec82 100644 --- a/core/src/fr/evolving/automata/Cell.java +++ b/core/src/fr/evolving/automata/Cell.java @@ -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; } - + } diff --git a/core/src/fr/evolving/automata/Grid.java b/core/src/fr/evolving/automata/Grid.java index 8d4a185..b9aa84f 100644 --- a/core/src/fr/evolving/automata/Grid.java +++ b/core/src/fr/evolving/automata/Grid.java @@ -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> tiles = transmuter.getTilesidrotated().iterator(); - while(tiles.hasNext()){ - Entry 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> tiles = transmuter + .getTilesidrotated().iterator(); + while (tiles.hasNext()) { + Entry 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;x0) - 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=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;x0) - 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; } - - + } diff --git a/core/src/fr/evolving/automata/Inverter_I.java b/core/src/fr/evolving/automata/Inverter_I.java index ab84f48..0b760f6 100644 --- a/core/src/fr/evolving/automata/Inverter_I.java +++ b/core/src/fr/evolving/automata/Inverter_I.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Inverter_II.java b/core/src/fr/evolving/automata/Inverter_II.java index e304c72..051b1bd 100644 --- a/core/src/fr/evolving/automata/Inverter_II.java +++ b/core/src/fr/evolving/automata/Inverter_II.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Level.java b/core/src/fr/evolving/automata/Level.java index d4bc604..b937d86 100644 --- a/core/src/fr/evolving/automata/Level.java +++ b/core/src/fr/evolving/automata/Level.java @@ -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; + } } diff --git a/core/src/fr/evolving/automata/Negativer.java b/core/src/fr/evolving/automata/Negativer.java index a576bb8..4a86d5c 100644 --- a/core/src/fr/evolving/automata/Negativer.java +++ b/core/src/fr/evolving/automata/Negativer.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Nimporte); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Nimporte); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Negativer_I.java b/core/src/fr/evolving/automata/Negativer_I.java index a6e01ce..b63002d 100644 --- a/core/src/fr/evolving/automata/Negativer_I.java +++ b/core/src/fr/evolving/automata/Negativer_I.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); - this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul); + this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Negativer_II.java b/core/src/fr/evolving/automata/Negativer_II.java index dcab9c3..92d867b 100644 --- a/core/src/fr/evolving/automata/Negativer_II.java +++ b/core/src/fr/evolving/automata/Negativer_II.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); - this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre); + this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Negativer_III.java b/core/src/fr/evolving/automata/Negativer_III.java index 8756ada..dfdd0af 100644 --- a/core/src/fr/evolving/automata/Negativer_III.java +++ b/core/src/fr/evolving/automata/Negativer_III.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype= new OrderedMap(); - this.Tilestype.put(new Vector2(0,0), CaseType.Tout); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype = new OrderedMap(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Tout); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Neutraliser_I.java b/core/src/fr/evolving/automata/Neutraliser_I.java index b15bd9d..f3ee390 100644 --- a/core/src/fr/evolving/automata/Neutraliser_I.java +++ b/core/src/fr/evolving/automata/Neutraliser_I.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Neutraliser_II.java b/core/src/fr/evolving/automata/Neutraliser_II.java index e7bf8cb..8066d0c 100644 --- a/core/src/fr/evolving/automata/Neutraliser_II.java +++ b/core/src/fr/evolving/automata/Neutraliser_II.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Positiver.java b/core/src/fr/evolving/automata/Positiver.java index ce31e49..bd906bd 100644 --- a/core/src/fr/evolving/automata/Positiver.java +++ b/core/src/fr/evolving/automata/Positiver.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Nimporte); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Nimporte); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Positiver_I.java b/core/src/fr/evolving/automata/Positiver_I.java index e032927..52ffe87 100644 --- a/core/src/fr/evolving/automata/Positiver_I.java +++ b/core/src/fr/evolving/automata/Positiver_I.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre_seul); - this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre_seul); + this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Positiver_II.java b/core/src/fr/evolving/automata/Positiver_II.java index 7c0ccdb..c930dc4 100644 --- a/core/src/fr/evolving/automata/Positiver_II.java +++ b/core/src/fr/evolving/automata/Positiver_II.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Cuivre); - this.Tilestype.put(new Vector2(1,0), CaseType.Fibre_seul); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Cuivre); + this.Tilestype.put(new Vector2(1, 0), CaseType.Fibre_seul); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Positiver_III.java b/core/src/fr/evolving/automata/Positiver_III.java index 3dc782b..23f384f 100644 --- a/core/src/fr/evolving/automata/Positiver_III.java +++ b/core/src/fr/evolving/automata/Positiver_III.java @@ -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 Tilestype; private static OrderedMap 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(); - this.Tilestype.put(new Vector2(0,0), CaseType.Tout); - this.Tilesid= new OrderedMap(); - 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(); + this.Tilestype.put(new Vector2(0, 0), CaseType.Tout); + this.Tilesid = new OrderedMap(); + 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 getTilesid() { + + public Values getTilesid() { return Tilesid.values(); - } - + } + public CaseType getTilestype(int order) { return Tilestype.values().toArray().get(order); - } - - public OrderedMap getTilesidrotated() { - OrderedMap newTiles= new OrderedMap(); - Iterator 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 getTilesidrotated() { + OrderedMap newTiles = new OrderedMap(); + Iterator 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; } diff --git a/core/src/fr/evolving/automata/Transmuter.java b/core/src/fr/evolving/automata/Transmuter.java index 5aade6c..76869e8 100644 --- a/core/src/fr/evolving/automata/Transmuter.java +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -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 getTilesidrotated() { return null; } - - public Values getTilesid() { + + public Values 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 tiles=this.getTilesidrotated(); - Entries iterator=tiles.iterator(); + OrderedMap tiles = this.getTilesidrotated(); + Entries 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 allTiles=this.getTilesid().iterator(); - while(allTiles.hasNext()) - result+=String.valueOf(allTiles.next())+" "; - while(iterator.hasNext()){ - Entry 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 allTiles = this.getTilesid().iterator(); + while (allTiles.hasNext()) + result += String.valueOf(allTiles.next()) + " "; + while (iterator.hasNext()) { + Entry 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; diff --git a/core/src/fr/evolving/database/Base.java b/core/src/fr/evolving/database/Base.java index 909ccef..97270d7 100644 --- a/core/src/fr/evolving/database/Base.java +++ b/core/src/fr/evolving/database/Base.java @@ -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 getworlds() { return null; } - - public Array getworld(String description) { + + public Array getworld(String description) { return null; } - + public boolean setworld(Array 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 getTransmuters(int user){ + + public Array getTransmuters(int user) { return null; } - - public boolean setTransmuters(int user,Array transmuters){ + + public boolean setTransmuters(int user, Array 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 getGrids(int user, int level){ + + public Array 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 ""; } - - } diff --git a/core/src/fr/evolving/database/DatabaseManager.java b/core/src/fr/evolving/database/DatabaseManager.java index 1fe561a..1245617 100644 --- a/core/src/fr/evolving/database/DatabaseManager.java +++ b/core/src/fr/evolving/database/DatabaseManager.java @@ -8,102 +8,101 @@ public class DatabaseManager { private static Base[] bases; private static String[] old; private static Array> 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>(); + + public DatabaseManager() { + bases = new Base[3]; + old = new String[3]; + backends = new Array>(); } - + 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); } diff --git a/core/src/fr/evolving/database/LocalBase.java b/core/src/fr/evolving/database/LocalBase.java index a87a23d..1b85ab1 100644 --- a/core/src/fr/evolving/database/LocalBase.java +++ b/core/src/fr/evolving/database/LocalBase.java @@ -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 getworlds() { - DatabaseCursor cursor=null; + DatabaseCursor cursor = null; try { cursor = dbHandler.rawQuery("select desc,date from worlds;"); } catch (SQLiteGdxException e) { return null; } - Array returnvalue=new Array(); + Array returnvalue = new Array(); while (cursor.next()) returnvalue.add(cursor.getString(0)); return returnvalue; } public Array 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(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 getTransmuters(int user){ - DatabaseCursor cursor=null; + public Array 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(mc); + } catch (Exception e) { + e.printStackTrace(); } - catch (Exception e) { - e.printStackTrace(); - } return null; } - public boolean setTransmuters(int user,Array transmuters){ + public boolean setTransmuters(int user, Array 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 getGrids(int user, int level){ - DatabaseCursor cursor=null; + public Array 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 returnvalue=new Array(); + Array returnvalue = new Array(); 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; } diff --git a/core/src/fr/evolving/database/SqlBase.java b/core/src/fr/evolving/database/SqlBase.java index 472db2c..cb1aabb 100644 --- a/core/src/fr/evolving/database/SqlBase.java +++ b/core/src/fr/evolving/database/SqlBase.java @@ -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; diff --git a/core/src/fr/evolving/effects/Laser.java b/core/src/fr/evolving/effects/Laser.java index 2b851be..f3f302d 100644 --- a/core/src/fr/evolving/effects/Laser.java +++ b/core/src/fr/evolving/effects/Laser.java @@ -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(); } } - - diff --git a/core/src/fr/evolving/game/main.java b/core/src/fr/evolving/game/main.java index c2fa716..23280d1 100644 --- a/core/src/fr/evolving/game/main.java +++ b/core/src/fr/evolving/game/main.java @@ -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(); diff --git a/core/src/fr/evolving/renderers/GameRenderer.java b/core/src/fr/evolving/renderers/GameRenderer.java index 40339f0..c5d3321 100644 --- a/core/src/fr/evolving/renderers/GameRenderer.java +++ b/core/src/fr/evolving/renderers/GameRenderer.java @@ -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(); } diff --git a/core/src/fr/evolving/renderers/LevelRenderer.java b/core/src/fr/evolving/renderers/LevelRenderer.java index 084717a..9d9ff88 100644 --- a/core/src/fr/evolving/renderers/LevelRenderer.java +++ b/core/src/fr/evolving/renderers/LevelRenderer.java @@ -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 processors; private Timer ScrollTimer; - private WarnDialog dialog; + private WarnDialog dialog; private TimerTask ScrollTask; - private Stage stage,stage_menu,stage_info,stage_tooltip; + private Stage stage, stage_menu, stage_info, stage_tooltip; private HorizontalGroup table; private VerticalGroup table2; private GameRenderer Renderer; private float runTime; public Level level; - private Window winOptions,winSave; + private Window winOptions, winSave; private ImageButton[] Barre; - private CheckBox SetSound,SetVsynch,SetFullscreen,SetAnimation,Settuto,Setdebog,Setrefresh; - private Slider SetEffectvolume,SetMusicvolume; - private TextButton Setcancel,Setsave; + private CheckBox SetSound, SetVsynch, SetFullscreen, SetAnimation, Settuto, + Setdebog, Setrefresh; + private Slider SetEffectvolume, SetMusicvolume; + private TextButton Setcancel, Setsave; private SelectBox selResolution; private SelectBox selTexturequal; private SelectBox selAdaptscreen; private List selSaved; - private ImageButton Setflag,info_up_nrj,info_up_temp,info_up_rayon,info_up_cycle,info_up_nrjval,info_up_tempval,info_up_rayonval,info_up_cycleval,SetFlag; - private ImageTextButton cycle,temp,nrj,rayon,cout,tech,research,info_cout,info_tech,info_research,info_activation; - private ImageTextButton[] Barre2; - String[] tocreate={"run","stop","speed","separator","move","zoomp","zoomm","infos","separator","raz","save","levels","tree","exits","separator","screen","sound","tuto","settings","separator","stat"}; + private ImageButton Setflag, info_up_nrj, info_up_temp, info_up_rayon, + info_up_cycle, info_up_nrjval, info_up_tempval, info_up_rayonval, + info_up_cycleval, SetFlag; + private ImageTextButton cycle, temp, nrj, rayon, cout, tech, research, + info_cout, info_tech, info_research, info_activation; + private ImageTextButton[] Barre2; + String[] tocreate = { "run", "stop", "speed", "separator", "move", "zoomp", + "zoomm", "infos", "separator", "raz", "save", "levels", "tree", + "exits", "separator", "screen", "sound", "tuto", "settings", + "separator", "stat" }; public Actor selected; public Transmuter selected_transmuter; private ButtonLevel buttonlevel; @@ -110,362 +99,435 @@ public class GameScreen implements Screen { private TouchMaptiles map; private Menu menu; private Actor menuactor; - private float oldx,oldy; - private Label fpsLabel,info_nom; - private TextArea info_desc,tooltip; - public boolean unroll,mapexit; - public enum calling{mouseover,mouseclick,mousedrag,longpress,tap,taptap,zoom,fling,pan,pinch}; - public enum quality{ - Bas("Bas", TextureFilter.Nearest ), - Moyen("Moyen", TextureFilter.MipMap), - Eleve("Eleve", TextureFilter.Linear) - ; - private final String text; - private final TextureFilter aquality; - private quality(final String text, TextureFilter aquality) { - this.text = text; - this.aquality=aquality; - } - @Override - public String toString() { - return text; - } - public TextureFilter getQuality() { - return this.aquality; - } + private float oldx, oldy; + private Label fpsLabel, info_nom; + private TextArea info_desc, tooltip; + public boolean unroll, mapexit; + + public enum calling { + mouseover, mouseclick, mousedrag, longpress, tap, taptap, zoom, fling, pan, pinch }; - public enum adaptation { - fit("Aspect conserve"), - fill("Remplissage") - ; - private final String text; - private adaptation(final String text) { - this.text = text; - } - @Override - public String toString() { - return text; - } - } - public enum resolutions{ - r1024_768("XGA (1024x768) 4:3",1024,768), - r1280_720("720p (1280x720) 16:9",1280,720), - r1280_768("WXGA (1280x768) 5:3",1280,768), - r1280_1024("SXGA (1280x1024) 5:4",1280,1024), - r1400_1050("SXGA+ (1400x1050) 4:3",1400,1050), - r1680_1050("WSXGA (1680x1050) 16:10",1680,1050), - r1600_1200("UXGA (1600x1200) 4:3",1600,1200), - r1920_1080("1080p (1920x1080) 16:9",1920,1080), - r1920_1200("WUXGA (1920x1200) 16:10",1920,1200), - rmax("resolution Native",0,0) - ; - private final String text; - private int resx,resy; - boolean full; - private resolutions(final String text,int resx,int resy) { - this.text = text; - this.resx=resx; - this.resy=resy; - } - @Override - public String toString() - { - if (full) - return text+" Fullscreen"; - else - return text; - } - public void SetFull(boolean fullscreen) { - full=fullscreen; - } - public int getResolutionX() { - return resx; - } - public int getResolutionY() { - return resy; - } - public void setResolutionX(int x) { - resx=x; - } - public void setResolutionY(int y) { - resy=y; - } + + public enum quality { + Bas("Bas", TextureFilter.Nearest), Moyen("Moyen", TextureFilter.MipMap), Eleve( + "Eleve", TextureFilter.Linear); + private final String text; + private final TextureFilter aquality; + + private quality(final String text, TextureFilter aquality) { + this.text = text; + this.aquality = aquality; } + + @Override + public String toString() { + return text; + } + + public TextureFilter getQuality() { + return this.aquality; + } + }; + + public enum adaptation { + fit("Aspect conserve"), fill("Remplissage"); + private final String text; + + private adaptation(final String text) { + this.text = text; + } + + @Override + public String toString() { + return text; + } + } + + public enum resolutions { + r1024_768("XGA (1024x768) 4:3", 1024, 768), r1280_720( + "720p (1280x720) 16:9", 1280, 720), r1280_768( + "WXGA (1280x768) 5:3", 1280, 768), r1280_1024( + "SXGA (1280x1024) 5:4", 1280, 1024), r1400_1050( + "SXGA+ (1400x1050) 4:3", 1400, 1050), r1680_1050( + "WSXGA (1680x1050) 16:10", 1680, 1050), r1600_1200( + "UXGA (1600x1200) 4:3", 1600, 1200), r1920_1080( + "1080p (1920x1080) 16:9", 1920, 1080), r1920_1200( + "WUXGA (1920x1200) 16:10", 1920, 1200), rmax( + "resolution Native", 0, 0); + private final String text; + private int resx, resy; + boolean full; + + private resolutions(final String text, int resx, int resy) { + this.text = text; + this.resx = resx; + this.resy = resy; + } + + @Override + public String toString() { + if (full) + return text + " Fullscreen"; + else + return text; + } + + public void SetFull(boolean fullscreen) { + full = fullscreen; + } + + public int getResolutionX() { + return resx; + } + + public int getResolutionY() { + return resy; + } + + public void setResolutionX(int x) { + resx = x; + } + + public void setResolutionY(int y) { + resy = y; + } + } + GestureDetector gesturedetector; // This is the constructor, not the class declaration public GameScreen(Level alevel) { - this.level=alevel; - Gdx.app.debug(getClass().getSimpleName(),"Récupération des derniers niveaux."); - this.level.Grid=AssetLoader.Datahandler.user().getGrid(0, this.level.id, "LAST"); - if (this.level.Grid==null) { - Gdx.app.debug(getClass().getSimpleName(),"Copie monde original."); - this.level.Grid=this.level.Grid_orig; + this.level = alevel; + Gdx.app.debug(getClass().getSimpleName(), + "Récupération des derniers niveaux."); + this.level.Grid = AssetLoader.Datahandler.user().getGrid(0, + this.level.id, "LAST"); + if (this.level.Grid == null) { + Gdx.app.debug(getClass().getSimpleName(), "Copie monde original."); + this.level.Grid = this.level.Grid_orig; - } - else - { - Gdx.app.debug(getClass().getSimpleName(),"Récupération de la dernière grille."); + } else { + Gdx.app.debug(getClass().getSimpleName(), + "Récupération de la dernière grille."); this.level.Grid.tiling_copper(); this.level.Grid.tiling_transmuter(); } - Gdx.app.debug(getClass().getSimpleName(),"Création des Barres verticales & horizontales."); + Gdx.app.debug(getClass().getSimpleName(), + "Création des Barres verticales & horizontales."); table = new HorizontalGroup(); table.bottom().padLeft(5f).padBottom(8f).space(10f); table2 = new VerticalGroup(); - table2.setPosition(AssetLoader.width, AssetLoader.height-360); + table2.setPosition(AssetLoader.width, AssetLoader.height - 360); table2.right(); table2.space(10f); - Gdx.app.debug(getClass().getSimpleName(),"Création des elements primordiaux du screen (stage, renderer, table, level, world)"); - fpsLabel=new Label("0 FPS",AssetLoader.Skin_level,"FPS"); - fpsLabel.setPosition(AssetLoader.width-75, AssetLoader.height-220); + Gdx.app.debug( + getClass().getSimpleName(), + "Création des elements primordiaux du screen (stage, renderer, table, level, world)"); + fpsLabel = new Label("0 FPS", AssetLoader.Skin_level, "FPS"); + fpsLabel.setPosition(AssetLoader.width - 75, AssetLoader.height - 220); multiplexer = new InputMultiplexer(); processors = new Array(); stage = new Stage(AssetLoader.viewport); stage_menu = new Stage(AssetLoader.viewport); stage_info = new Stage(AssetLoader.viewport); stage_tooltip = new Stage(AssetLoader.viewport); - oldx=0; - oldy=0; - unroll=false; + oldx = 0; + oldy = 0; + unroll = false; Renderer = new GameRenderer(this); - Gdx.app.debug(getClass().getSimpleName(),"Mise en place du timer."); - ScrollTimer=new Timer(); - ScrollTask = new TimerTask() - { + 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 des barres"); - tooltip=new TextArea("tooltip:x\r\n tooltip:y", AssetLoader.Skin_level, "info_tooltip") ; + Gdx.app.debug(getClass().getSimpleName(), "Création des barres"); + tooltip = new TextArea("tooltip:x\r\n tooltip:y", + AssetLoader.Skin_level, "info_tooltip"); tooltip.setBounds(541, 27, 100, 50); - Barre=new ImageButton[tocreate.length]; - int i=0; - Gdx.app.debug(getClass().getSimpleName(),"Barre bas:"+Barre.length+" elements"); - for (String tocreateitem: tocreate) { - Barre[i]= new ImageButton(AssetLoader.Skin_level,tocreateitem); + Barre = new ImageButton[tocreate.length]; + int i = 0; + Gdx.app.debug(getClass().getSimpleName(), "Barre bas:" + Barre.length + + " elements"); + for (String tocreateitem : tocreate) { + Barre[i] = new ImageButton(AssetLoader.Skin_level, tocreateitem); Barre[i].setName(tocreateitem); - Barre[i].addListener(new ClickListener(){ + Barre[i].addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - Actor caller=event.getListenerActor(); - Gdx.app.debug("Barre","Selection dans la Barre bas:"+caller.getName()); + Actor caller = event.getListenerActor(); + Gdx.app.debug("Barre", "Selection dans la Barre bas:" + + caller.getName()); preparebarre(caller, this.getTapCount()); } }); - Barre[i++].addListener(new Tooltip(tooltip, AssetLoader.Tooltipmanager)); + Barre[i++].addListener(new Tooltip(tooltip, + AssetLoader.Tooltipmanager)); } - Barre2=new ImageTextButton[Transmuter.Class.values().length]; - Gdx.app.debug(getClass().getSimpleName(),"Menu:"+Barre2.length+" elements"); - for (i=0;i0); - Barre[17].setChecked(AssetLoader.Tooltipmanager.enabled==true); - Gdx.app.debug(getClass().getSimpleName(),"Création de la barre de gestion du haut"); - cycle=new ImageTextButton(String.valueOf(level.Cycle),AssetLoader.Skin_level,"cycle2"); - cycle.setPosition(10,AssetLoader.height-74); - temp=new ImageTextButton(String.valueOf(level.Temp),AssetLoader.Skin_level,"temp2"); - temp.setPosition(210,AssetLoader.height-74); - nrj=new ImageTextButton(String.valueOf(level.Nrj),AssetLoader.Skin_level,"nrj2"); - nrj.setPosition(410,AssetLoader.height-74); - rayon=new ImageTextButton(String.valueOf(level.Rayon),AssetLoader.Skin_level,"rayon2"); - rayon.setPosition(610,AssetLoader.height-74); - tech=new ImageTextButton(String.valueOf(level.Tech),AssetLoader.Skin_level,"tech2"); - tech.setPosition(1345,AssetLoader.height-74); - cout=new ImageTextButton(String.valueOf(level.Cout),AssetLoader.Skin_level,"cout2"); - cout.setPosition(1445,AssetLoader.height-74); - research=new ImageTextButton(String.valueOf(0),AssetLoader.Skin_level,"research2"); - research.setPosition(1545,AssetLoader.height-74); - objectives=new Objectives(); + Barre[16].setChecked(AssetLoader.intro.getVolume() > 0); + Barre[17].setChecked(AssetLoader.Tooltipmanager.enabled == true); + Gdx.app.debug(getClass().getSimpleName(), + "Création de la barre de gestion du haut"); + cycle = new ImageTextButton(String.valueOf(level.Cycle), + AssetLoader.Skin_level, "cycle2"); + cycle.setPosition(10, AssetLoader.height - 74); + temp = new ImageTextButton(String.valueOf(level.Temp), + AssetLoader.Skin_level, "temp2"); + temp.setPosition(210, AssetLoader.height - 74); + nrj = new ImageTextButton(String.valueOf(level.Nrj), + AssetLoader.Skin_level, "nrj2"); + nrj.setPosition(410, AssetLoader.height - 74); + rayon = new ImageTextButton(String.valueOf(level.Rayon), + AssetLoader.Skin_level, "rayon2"); + rayon.setPosition(610, AssetLoader.height - 74); + tech = new ImageTextButton(String.valueOf(level.Tech), + AssetLoader.Skin_level, "tech2"); + tech.setPosition(1345, AssetLoader.height - 74); + cout = new ImageTextButton(String.valueOf(level.Cout), + AssetLoader.Skin_level, "cout2"); + cout.setPosition(1445, AssetLoader.height - 74); + research = new ImageTextButton(String.valueOf(0), + AssetLoader.Skin_level, "research2"); + research.setPosition(1545, AssetLoader.height - 74); + objectives = new Objectives(); objectives.setVictory(level.Victory); - objectives.setPosition(890,AssetLoader.height-95); - buttonlevel=new ButtonLevel(level,true,1.0f); - buttonlevel.setPosition(1760,AssetLoader.height-125); + objectives.setPosition(890, AssetLoader.height - 95); + buttonlevel = new ButtonLevel(level, true, 1.0f); + buttonlevel.setPosition(1760, AssetLoader.height - 125); buttonlevel.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - Gdx.app.debug(getClass().getSimpleName(),"Remise à zéro du monde"); - GameScreen.this.level.Grid=GameScreen.this.level.Grid_orig; + Gdx.app.debug(getClass().getSimpleName(), + "Remise à zéro du monde"); + GameScreen.this.level.Grid = GameScreen.this.level.Grid_orig; level.Grid.tiling_copper(); level.Grid.tiling_transmuter(); map.redraw(53); buttonlevel.setChecked(false); } }); - Gdx.app.debug(getClass().getSimpleName(),"Création de la barre d'information"); - info_tech=new ImageTextButton("0",AssetLoader.Skin_level,"info_tech"); + Gdx.app.debug(getClass().getSimpleName(), + "Création de la barre d'information"); + info_tech = new ImageTextButton("0", AssetLoader.Skin_level, + "info_tech"); info_tech.setSize(48, 48); - info_tech.setPosition(1200, AssetLoader.height-775); - info_cout=new ImageTextButton("0",AssetLoader.Skin_level,"info_cout"); + info_tech.setPosition(1200, AssetLoader.height - 775); + info_cout = new ImageTextButton("0", AssetLoader.Skin_level, + "info_cout"); info_cout.setSize(48, 48); - info_cout.setPosition(1280, AssetLoader.height-775); - info_research=new ImageTextButton("0",AssetLoader.Skin_level,"info_research"); + info_cout.setPosition(1280, AssetLoader.height - 775); + info_research = new ImageTextButton("0", AssetLoader.Skin_level, + "info_research"); info_research.setSize(48, 48); - info_research.setPosition(1360, AssetLoader.height-775); - info_activation=new ImageTextButton("0",AssetLoader.Skin_level,"info_activation"); + info_research.setPosition(1360, AssetLoader.height - 775); + info_activation = new ImageTextButton("0", AssetLoader.Skin_level, + "info_activation"); info_activation.setSize(48, 48); - info_activation.setPosition(1440, AssetLoader.height-775); - info_up_cycleval=new ImageButton(AssetLoader.Skin_level,"info_cycleval"); - info_up_cycleval.setPosition(1819, AssetLoader.height-765); - info_up_tempval=new ImageButton(AssetLoader.Skin_level,"info_tempval"); - info_up_tempval.setPosition(1819, AssetLoader.height-832); - info_up_rayonval=new ImageButton(AssetLoader.Skin_level,"info_rayonval"); - info_up_rayonval.setPosition(1819, AssetLoader.height-900); - info_up_nrjval=new ImageButton(AssetLoader.Skin_level,"info_nrjval"); - info_up_nrjval.setPosition(1819, AssetLoader.height-967); - info_up_cycle=new ImageButton(AssetLoader.Skin_level,"info_cycle"); + info_activation.setPosition(1440, AssetLoader.height - 775); + info_up_cycleval = new ImageButton(AssetLoader.Skin_level, + "info_cycleval"); + info_up_cycleval.setPosition(1819, AssetLoader.height - 765); + info_up_tempval = new ImageButton(AssetLoader.Skin_level, + "info_tempval"); + info_up_tempval.setPosition(1819, AssetLoader.height - 832); + info_up_rayonval = new ImageButton(AssetLoader.Skin_level, + "info_rayonval"); + info_up_rayonval.setPosition(1819, AssetLoader.height - 900); + info_up_nrjval = new ImageButton(AssetLoader.Skin_level, "info_nrjval"); + info_up_nrjval.setPosition(1819, AssetLoader.height - 967); + info_up_cycle = new ImageButton(AssetLoader.Skin_level, "info_cycle"); info_up_cycle.setSize(32, 32); - info_up_cycle.setPosition(1835, AssetLoader.height-747); - info_up_temp=new ImageButton(AssetLoader.Skin_level,"info_temp"); + info_up_cycle.setPosition(1835, AssetLoader.height - 747); + info_up_temp = new ImageButton(AssetLoader.Skin_level, "info_temp"); info_up_temp.setSize(32, 32); - info_up_temp.setPosition(1837, AssetLoader.height-816); - info_up_rayon=new ImageButton(AssetLoader.Skin_level,"info_rayon"); + info_up_temp.setPosition(1837, AssetLoader.height - 816); + info_up_rayon = new ImageButton(AssetLoader.Skin_level, "info_rayon"); info_up_rayon.setSize(32, 32); - info_up_rayon.setPosition(1835, AssetLoader.height-884); - info_up_nrj=new ImageButton(AssetLoader.Skin_level,"info_nrj"); + info_up_rayon.setPosition(1835, AssetLoader.height - 884); + info_up_nrj = new ImageButton(AssetLoader.Skin_level, "info_nrj"); info_up_nrj.setSize(32, 32); - info_up_nrj.setPosition(1835, AssetLoader.height-950); - info_nom= new Label("Unknow",AssetLoader.Skin_level,"info_nom"); - info_nom.setPosition(1230, AssetLoader.height-710); - info_desc=new TextArea("Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description", AssetLoader.Skin_level, "info_desc") ; - info_desc.setBounds(1220, AssetLoader.height-965, 575, 150); - dialog=new WarnDialog(AssetLoader.Skin_ui); - Gdx.app.debug(getClass().getSimpleName(),"Création d'une tilemap"); - map=new TouchMaptiles(level,128,128); + info_up_nrj.setPosition(1835, AssetLoader.height - 950); + info_nom = new Label("Unknow", AssetLoader.Skin_level, "info_nom"); + info_nom.setPosition(1230, AssetLoader.height - 710); + info_desc = new TextArea( + "Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description Description", + AssetLoader.Skin_level, "info_desc"); + info_desc.setBounds(1220, AssetLoader.height - 965, 575, 150); + dialog = new WarnDialog(AssetLoader.Skin_ui); + Gdx.app.debug(getClass().getSimpleName(), "Création d'une tilemap"); + map = new TouchMaptiles(level, 128, 128); map.setBounds(0, 0, AssetLoader.width, AssetLoader.height); map.redraw(53); - map.addListener(new ActorGestureListener(){ + map.addListener(new ActorGestureListener() { @Override - public void zoom(InputEvent event, float initialDistance, float distance) { - String[] exec={"zoomp","zoomm"}; - int zooming=(int)(distance/initialDistance*1000f); - event_coordination(0,0,zooming,calling.zoom,exec); - } - @Override - public void pinch(InputEvent event, Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) - { - float deltaX = pointer2.x - pointer1.x; - float deltaY = pointer2.y - pointer1.y; - int angle = (int)((float)Math.atan2((double)deltaY,(double)deltaX) * MathUtils.radiansToDegrees); - angle += 90; - if(angle < 0) - angle = 360 - (-angle); - String[] exec={"transmuter"}; - event_coordination(initialPointer1.x,initialPointer1.y,angle,calling.pinch,exec); - } - @Override - public boolean longPress(Actor actor, float x, float y) { - String[] exec={"transmuter"}; - return event_coordination(x,y,0,calling.longpress,exec); - } - @Override - public void tap(InputEvent event, float x, float y, int count, int button) { - String[] exec={"transmuter"}; - if (count==1) - event_coordination(x,y,button,calling.tap,exec); - else if (count>=2) - event_coordination(x,y,button,calling.taptap,exec); - } - }); - map.addListener(new InputListener(){ - @Override - public boolean mouseMoved(InputEvent event,float x,float y) { - String[] exec={"transmuter"}; - return event_coordination(x,y,0,calling.mouseover,exec); + public void zoom(InputEvent event, float initialDistance, + float distance) { + String[] exec = { "zoomp", "zoomm" }; + int zooming = (int) (distance / initialDistance * 1000f); + event_coordination(0, 0, zooming, calling.zoom, exec); } - @Override - public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { - oldx=0; - oldy=0; - String[] exec={"cleaner","infos","zoomp","zoomm","copper_pen","fiber_pen","copper_eraser","fiber_eraser","transmuter_eraser","all_eraser","blank","transmuter","copper_brush","fiber_brush"}; - return event_coordination(x,y,button,calling.mouseclick,exec); - } @Override - public void touchDragged(InputEvent event, float x, float y, int pointer) { - String[] exec={"transmuter","move","copper_brush","fiber_brush","copper_eraser","fiber_eraser","transmuter_eraser","all_eraser","blank"}; - event_coordination(x,y,0,calling.mousedrag,exec); + public void pinch(InputEvent event, Vector2 initialPointer1, + Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) { + float deltaX = pointer2.x - pointer1.x; + float deltaY = pointer2.y - pointer1.y; + int angle = (int) ((float) Math.atan2((double) deltaY, + (double) deltaX) * MathUtils.radiansToDegrees); + angle += 90; + if (angle < 0) + angle = 360 - (-angle); + String[] exec = { "transmuter" }; + event_coordination(initialPointer1.x, initialPointer1.y, angle, + calling.pinch, exec); + } + + @Override + public boolean longPress(Actor actor, float x, float y) { + String[] exec = { "transmuter" }; + return event_coordination(x, y, 0, calling.longpress, exec); + } + + @Override + public void tap(InputEvent event, float x, float y, int count, + int button) { + String[] exec = { "transmuter" }; + if (count == 1) + event_coordination(x, y, button, calling.tap, exec); + else if (count >= 2) + event_coordination(x, y, button, calling.taptap, exec); } }); - menu=new Menu(4,8); - map.addListener(new ClickListener(){ + map.addListener(new InputListener() { @Override - public void clicked(InputEvent event, float x, float y) { - mapexit=true; - Vector2 coords=menu.screentoworld(x,y); - MapProperties tile=menu.getMenubyTile((int)coords.x,(int)coords.y); - if (tile!=null && tile.containsKey("name")) - { + public boolean mouseMoved(InputEvent event, float x, float y) { + String[] exec = { "transmuter" }; + return event_coordination(x, y, 0, calling.mouseover, exec); + } + + @Override + public boolean touchDown(InputEvent event, float x, float y, + int pointer, int button) { + oldx = 0; + oldy = 0; + String[] exec = { "cleaner", "infos", "zoomp", "zoomm", + "copper_pen", "fiber_pen", "copper_eraser", + "fiber_eraser", "transmuter_eraser", "all_eraser", + "blank", "transmuter", "copper_brush", "fiber_brush" }; + return event_coordination(x, y, button, calling.mouseclick, + exec); + } + + @Override + public void touchDragged(InputEvent event, float x, float y, + int pointer) { + String[] exec = { "transmuter", "move", "copper_brush", + "fiber_brush", "copper_eraser", "fiber_eraser", + "transmuter_eraser", "all_eraser", "blank" }; + event_coordination(x, y, 0, calling.mousedrag, exec); + } + }); + menu = new Menu(4, 8); + map.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + mapexit = true; + Vector2 coords = menu.screentoworld(x, y); + MapProperties tile = menu.getMenubyTile((int) coords.x, + (int) coords.y); + if (tile != null && tile.containsKey("name")) { menu.EraseMenuTransmuterSurtile(); map.tempclear(); - if (menuactor==null) - menuactor=new Actor(); + if (menuactor == null) + menuactor = new Actor(); map.fillempty(60); - selected=menuactor; - if (tile.get("type").toString().startsWith("transmuter")) - { + selected = menuactor; + if (tile.get("type").toString().startsWith("transmuter")) { if (tile.containsKey("movetox")) { - coords.x+=(Integer) tile.get("movetox"); - coords.y+=(Integer) tile.get("movetoy"); + coords.x += (Integer) tile.get("movetox"); + coords.y += (Integer) tile.get("movetoy"); } - MapProperties tilenew=menu.getMenubyTile((int)coords.x,(int)coords.y); - selected_transmuter=(Transmuter) ((Transmuter) tilenew.get("transmuter")).clone(); - if (selected_transmuter!=null) { + MapProperties tilenew = menu.getMenubyTile( + (int) coords.x, (int) coords.y); + selected_transmuter = (Transmuter) ((Transmuter) tilenew + .get("transmuter")).clone(); + if (selected_transmuter != null) { selected.setName("transmuter"); showInfo(selected_transmuter); - menu.setMenuTransmuterSurtile((int)coords.x,(int) coords.y,selected_transmuter); - Gdx.app.debug("menu","Choix transmuter:"+selected_transmuter.getName()); + menu.setMenuTransmuterSurtile((int) coords.x, + (int) coords.y, selected_transmuter); + Gdx.app.debug("menu", "Choix transmuter:" + + selected_transmuter.getName()); } - } - else + } else selected.setName(tile.get("name").toString()); - Vector2 coords2=menu.worldtoscreen((int)coords.x,(int)coords.y); - Gdx.app.debug("menu","Coordonnées:"+x+"x"+y+" Menu:"+coords.x+","+coords.y+" Ecran :"+coords2.x+"x"+coords2.y+" type:"+tile.get("type")); + Vector2 coords2 = menu.worldtoscreen((int) coords.x, + (int) coords.y); + Gdx.app.debug( + "menu", + "Coordonnées:" + x + "x" + y + " Menu:" + coords.x + + "," + coords.y + " Ecran :" + coords2.x + + "x" + coords2.y + " type:" + + tile.get("type")); menuactor.setBounds(coords2.x, coords2.y, 60, 60); } } }); } - boolean event_coordination(float x,float y,int button, calling call, String[] exec) { - if (selected!=null) { + boolean event_coordination(float x, float y, int button, calling call, + String[] exec) { + if (selected != null) { if (Arrays.asList(exec).contains(selected.getName())) { - Vector2 coords=map.screentoworld(x, y); - if (level.Grid.GetXY(coords.x,coords.y)!=null) - { - mapexit=false; - if (call!=calling.mouseover) - Gdx.app.debug("evenement","mode:"+call+" outil:"+selected.getName()+ " X: " + coords.x + " Y: " + coords.y+" button:"+button); + Vector2 coords = map.screentoworld(x, y); + if (level.Grid.GetXY(coords.x, coords.y) != null) { + mapexit = false; + if (call != calling.mouseover) + Gdx.app.debug("evenement", "mode:" + call + " outil:" + + selected.getName() + " X: " + coords.x + + " Y: " + coords.y + " button:" + button); Method method; try { - Class base = Class.forName("fr.evolving.screens.GameScreen"); - Class[] params={float.class, float.class,int.class, int.class, boolean.class, int.class, calling.class}; - method = base.getDeclaredMethod("map_"+selected.getName(), params); - method.invoke(this,(float)x,(float)y,(int)coords.x,(int)coords.y,true,(int)button,(calling)call); + Class base = Class + .forName("fr.evolving.screens.GameScreen"); + Class[] params = { float.class, float.class, + int.class, int.class, boolean.class, int.class, + calling.class }; + method = base.getDeclaredMethod( + "map_" + selected.getName(), params); + method.invoke(this, (float) x, (float) y, + (int) coords.x, (int) coords.y, true, + (int) button, (calling) call); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } - } - else - { - if (mapexit==false) { - mapexit=true; + } else { + if (mapexit == false) { + mapexit = true; map.tempclear(); } } @@ -475,113 +537,161 @@ public class GameScreen implements Screen { return true; } - void map_transmuter(float realx, float realy,int x, int y,boolean alone,int button,calling call) { - if (call==calling.taptap && button==0 || (call==calling.mouseclick && button==1)) - { - Angular angle=selected_transmuter.getRotation(); - if (angle==Angular.A00) + void map_transmuter(float realx, float realy, int x, int y, boolean alone, + int button, calling call) { + if (call == calling.taptap && button == 0 + || (call == calling.mouseclick && button == 1)) { + Angular angle = selected_transmuter.getRotation(); + if (angle == Angular.A00) selected_transmuter.setRotation(Angular.A90); - else if (angle==Angular.A90) + else if (angle == Angular.A90) selected_transmuter.setRotation(Angular.A180); - else if (angle==Angular.A180) + else if (angle == Angular.A180) selected_transmuter.setRotation(Angular.A270); - else if (angle==Angular.A270) + else if (angle == Angular.A270) selected_transmuter.setRotation(Angular.A00); } map.tempclear(); - boolean positionisgood=true; - int color=0; - OrderedMap tiles=selected_transmuter.getTilesidrotated(); - Entries iterator=tiles.iterator(); - while(iterator.hasNext()){ + boolean positionisgood = true; + int color = 0; + OrderedMap tiles = selected_transmuter + .getTilesidrotated(); + Entries iterator = tiles.iterator(); + while (iterator.hasNext()) { Entry all = iterator.next(); - color=63; - int index=tiles.keys().toArray().indexOf(all.key, false); - if (((selected_transmuter.getTilestype(index)==CaseType.Nimporte) || (!level.Grid.getFiber(x+all.key.x, y+all.key.y) && !level.Grid.getCopper(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Rien) || (level.Grid.getFiber(x+all.key.x, y+all.key.y) && level.Grid.getCopper(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Tout) || (level.Grid.getCopper(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Cuivre) || (level.Grid.getFiber(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Fibre) || (level.Grid.getFiber(x+all.key.x, y+all.key.y) && !level.Grid.getCopper(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Fibre_seul) || (level.Grid.getCopper(x+all.key.x, y+all.key.y) && !level.Grid.getFiber(x+all.key.x, y+all.key.y) && selected_transmuter.getTilestype(index)==CaseType.Cuivre_seul)) && (level.Grid.getTransmutercalc(x+all.key.x, y+all.key.y)==0)) - color=0; + color = 63; + int index = tiles.keys().toArray().indexOf(all.key, false); + if (((selected_transmuter.getTilestype(index) == CaseType.Nimporte) + || (!level.Grid.getFiber(x + all.key.x, y + all.key.y) + && !level.Grid.getCopper(x + all.key.x, y + + all.key.y) && selected_transmuter + .getTilestype(index) == CaseType.Rien) + || (level.Grid.getFiber(x + all.key.x, y + all.key.y) + && level.Grid.getCopper(x + all.key.x, y + + all.key.y) && selected_transmuter + .getTilestype(index) == CaseType.Tout) + || (level.Grid.getCopper(x + all.key.x, y + all.key.y) && selected_transmuter + .getTilestype(index) == CaseType.Cuivre) + || (level.Grid.getFiber(x + all.key.x, y + all.key.y) && selected_transmuter + .getTilestype(index) == CaseType.Fibre) + || (level.Grid.getFiber(x + all.key.x, y + all.key.y) + && !level.Grid.getCopper(x + all.key.x, y + + all.key.y) && selected_transmuter + .getTilestype(index) == CaseType.Fibre_seul) || (level.Grid + .getCopper(x + all.key.x, y + all.key.y) + && !level.Grid.getFiber(x + all.key.x, y + all.key.y) && selected_transmuter + .getTilestype(index) == CaseType.Cuivre_seul)) + && (level.Grid.getTransmutercalc(x + all.key.x, y + + all.key.y) == 0)) + color = 0; else - positionisgood=false; - map.tempdraw(x+all.key.x, y+all.key.y, all.value, selected_transmuter.getRotation().ordinal(),color); + positionisgood = false; + map.tempdraw(x + all.key.x, y + all.key.y, all.value, + selected_transmuter.getRotation().ordinal(), color); } - if ((call==calling.longpress && button==0) && positionisgood) - { - level.Grid.GetXY(x,y).Transmuter=(Transmuter) selected_transmuter.clone(); - if (alone) level.Grid.tiling_transmuter(); + if ((call == calling.longpress && button == 0) && positionisgood) { + level.Grid.GetXY(x, y).Transmuter = (Transmuter) selected_transmuter + .clone(); + if (alone) + level.Grid.tiling_transmuter(); map.redraw(60); - Gdx.input.vibrate(new long[] { 0, 400, 500, 400}, -1); + Gdx.input.vibrate(new long[] { 0, 400, 500, 400 }, -1); } } - - void map_infos(float realx, float realy,int x, int y,boolean alone,int button,calling call) { - if (level.Grid.GetXY(x,y)!=null) - { - Gdx.app.debug("map","Etat extension:"+unroll); - if (level.Grid.GetXY(x,y).Copper) - Gdx.app.debug("map","*** Présence de cuivre"); - if (level.Grid.GetXY(x,y).Fiber>0) - Gdx.app.debug("map","*** Présence de fibre"); - if (level.Grid.GetXY(x,y).Transmuter_calc>0) { - Gdx.app.debug("map","transmuter deplacement vers origine:"+level.Grid.GetXY(x,y).Transmuter_movex+","+level.Grid.GetXY(x,y).Transmuter_movey+" coords:"+(x+level.Grid.GetXY(x,y).Transmuter_movex)+"x"+(y+level.Grid.GetXY(x,y).Transmuter_movey)); - Gdx.app.debug("map",level.Grid.getTransmuter(x+level.Grid.GetXY(x,y).Transmuter_movex,y+level.Grid.GetXY(x,y).Transmuter_movey).getInformations()); - showInfo(level.Grid.getTransmuter(x+level.Grid.GetXY(x,y).Transmuter_movex,y+level.Grid.GetXY(x,y).Transmuter_movey)); + void map_infos(float realx, float realy, int x, int y, boolean alone, + int button, calling call) { + if (level.Grid.GetXY(x, y) != null) { + Gdx.app.debug("map", "Etat extension:" + unroll); + if (level.Grid.GetXY(x, y).Copper) + Gdx.app.debug("map", "*** Présence de cuivre"); + if (level.Grid.GetXY(x, y).Fiber > 0) + Gdx.app.debug("map", "*** Présence de fibre"); + if (level.Grid.GetXY(x, y).Transmuter_calc > 0) { + Gdx.app.debug("map", "transmuter deplacement vers origine:" + + level.Grid.GetXY(x, y).Transmuter_movex + "," + + level.Grid.GetXY(x, y).Transmuter_movey + " coords:" + + (x + level.Grid.GetXY(x, y).Transmuter_movex) + "x" + + (y + level.Grid.GetXY(x, y).Transmuter_movey)); + Gdx.app.debug( + "map", + level.Grid.getTransmuter( + x + level.Grid.GetXY(x, y).Transmuter_movex, + y + level.Grid.GetXY(x, y).Transmuter_movey) + .getInformations()); + showInfo(level.Grid.getTransmuter(x + + level.Grid.GetXY(x, y).Transmuter_movex, y + + level.Grid.GetXY(x, y).Transmuter_movey)); map.tempclear(); - map.tempdraw(x,y,1069,0,0); + map.tempdraw(x, y, 1069, 0, 0); } } } - void map_zoomp(float realx, float realy,int x, int y,boolean alone,int button,calling call) { + void map_zoomp(float realx, float realy, int x, int y, boolean alone, + int button, calling call) { map.setZoom(0.9f); - map.setDec((AssetLoader.width/2-realx)/2,(AssetLoader.height/2-realy)/2); + map.setDec((AssetLoader.width / 2 - realx) / 2, + (AssetLoader.height / 2 - realy) / 2); } - void map_zoomm(float realx, float realy,int x, int y,boolean alone,int button,calling call) { + void map_zoomm(float realx, float realy, int x, int y, boolean alone, + int button, calling call) { map.setZoom(1.1f); - map.setDec((AssetLoader.width/2-realx)/2,(AssetLoader.height/2-realy)/2); + map.setDec((AssetLoader.width / 2 - realx) / 2, + (AssetLoader.height / 2 - realy) / 2); } - - void map_move(float realx, float realy,int x, int y,boolean alone,int button,calling call) { - if (oldx!=0 && oldy!=0) { - map.setDec(realx-oldx,realy-oldy); - Gdx.app.debug("map","Decalage absolue en pixel:"+(realx-oldx)+"x"+(realy-oldy)); + void map_move(float realx, float realy, int x, int y, boolean alone, + int button, calling call) { + if (oldx != 0 && oldy != 0) { + map.setDec(realx - oldx, realy - oldy); + Gdx.app.debug("map", "Decalage absolue en pixel:" + (realx - oldx) + + "x" + (realy - oldy)); } - oldx=realx; - oldy=realy; + oldx = realx; + oldy = realy; } - void map_blank(float realx, float realy,int x, int y,boolean alone,int button,calling call) { - map_fiber_eraser(0,0,x,y,false,button,call); - map_copper_eraser(0,0,x,y,alone,button,call); + void map_blank(float realx, float realy, int x, int y, boolean alone, + int button, calling call) { + map_fiber_eraser(0, 0, x, y, false, button, call); + map_copper_eraser(0, 0, x, y, alone, button, call); } - void map_cleaner(float realx, float realy,int x, int y,boolean alone,int button,calling call) { - for(x=0;x=2) map.initzoom(); - } - else if (caller.getName()=="zoomp") { - selected=caller; - if (count>=2) map.initzoom(); - } - else if (caller.getName()=="zoomm") { - selected=caller; - if (count>=2) map.initzoom(); - } - else if (caller.getName()=="infos") { - selected=caller; - if (count>=2) map.initzoom(); - } - else if (caller.getName()=="raz") { + if (caller.getName() == "run") { + } else if (caller.getName() == "stop") { + } else if (caller.getName() == "speed") { + } else if (caller.getName() == "move") { + selected = caller; + if (count >= 2) + map.initzoom(); + } else if (caller.getName() == "zoomp") { + selected = caller; + if (count >= 2) + map.initzoom(); + } else if (caller.getName() == "zoomm") { + selected = caller; + if (count >= 2) + map.initzoom(); + } else if (caller.getName() == "infos") { + selected = caller; + if (count >= 2) + map.initzoom(); + } else if (caller.getName() == "raz") { winOptions.setVisible(false); winSave.setVisible(!winSave.isVisible()); if (winSave.isVisible()) readsaved(); - } - else if (caller.getName()=="save") { + } else if (caller.getName() == "save") { AssetLoader.Datahandler.user().setGrid(0, level.id, level.Grid); readsaved(); - } - else if (caller.getName()=="levels") { - Gdx.app.debug("Barre","Affichage des niveaux."); - AssetLoader.Datahandler.user().setGrid(0, level.id, "LAST",this.level.Grid); - ((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen(level.aWorld)); - } - else if (caller.getName()=="tree") { - } - else if (caller.getName()=="exits") { - AssetLoader.Datahandler.user().setGrid(0, level.id, "LAST",this.level.Grid); + } else if (caller.getName() == "levels") { + Gdx.app.debug("Barre", "Affichage des niveaux."); + AssetLoader.Datahandler.user().setGrid(0, level.id, "LAST", + this.level.Grid); + ((Game) Gdx.app.getApplicationListener()) + .setScreen(new LevelScreen(level.aWorld)); + } else if (caller.getName() == "tree") { + } else if (caller.getName() == "exits") { + AssetLoader.Datahandler.user().setGrid(0, level.id, "LAST", + this.level.Grid); Gdx.app.exit(); - } - else if (caller.getName()=="screen") { + } else if (caller.getName() == "screen") { DisplayMode currentMode = Gdx.graphics.getDesktopDisplayMode(); - if (Gdx.graphics.isFullscreen()) - { - Gdx.app.debug("Barre","vers fenetre."); - Gdx.graphics.setDisplayMode(currentMode.width, currentMode.height, false); + if (Gdx.graphics.isFullscreen()) { + Gdx.app.debug("Barre", "vers fenetre."); + Gdx.graphics.setDisplayMode(currentMode.width, + currentMode.height, false); + } else { + Gdx.app.debug("Barre", "vers plein ecran."); + Gdx.graphics.setDisplayMode(currentMode.width, + currentMode.height, true); } - else - { - Gdx.app.debug("Barre","vers plein ecran."); - Gdx.graphics.setDisplayMode(currentMode.width, currentMode.height, true); - } - ((ImageButton)caller).setChecked(Gdx.graphics.isFullscreen()); - } - else if (caller.getName()=="sound") { - if (AssetLoader.intro.getVolume()>0) - { - Gdx.app.debug("Barre","arret son."); + ((ImageButton) caller).setChecked(Gdx.graphics.isFullscreen()); + } else if (caller.getName() == "sound") { + if (AssetLoader.intro.getVolume() > 0) { + Gdx.app.debug("Barre", "arret son."); AssetLoader.intro.setVolume(0f); - } - else - { - Gdx.app.debug("Barre","marche son."); + } else { + Gdx.app.debug("Barre", "marche son."); AssetLoader.intro.setVolume(1f); } - ((ImageButton)caller).setChecked(AssetLoader.intro.getVolume()>0); - } - else if (caller.getName()=="tuto") { - if (AssetLoader.Tooltipmanager.enabled) - { - Gdx.app.debug("Barre","arret tuto."); - AssetLoader.Tooltipmanager.enabled=false; + ((ImageButton) caller) + .setChecked(AssetLoader.intro.getVolume() > 0); + } else if (caller.getName() == "tuto") { + if (AssetLoader.Tooltipmanager.enabled) { + Gdx.app.debug("Barre", "arret tuto."); + AssetLoader.Tooltipmanager.enabled = false; + } else { + Gdx.app.debug("Barre", "marche tuto."); + AssetLoader.Tooltipmanager.enabled = true; } - else - { - Gdx.app.debug("Barre","marche tuto."); - AssetLoader.Tooltipmanager.enabled=true; - } - ((ImageButton)caller).setChecked(AssetLoader.Tooltipmanager.enabled); - } - else if (caller.getName()=="settings") { + ((ImageButton) caller) + .setChecked(AssetLoader.Tooltipmanager.enabled); + } else if (caller.getName() == "settings") { winOptions.setVisible(!winOptions.isVisible()); winSave.setVisible(false); if (winOptions.isVisible()) readpref(); - } - else if (caller.getName()=="flag") { - if (AssetLoader.language.getLocale().getDisplayName().contains("français")) - { - Gdx.app.debug("Barre","Langue USA"); - AssetLoader.language=AssetLoader.usa; + } else if (caller.getName() == "flag") { + if (AssetLoader.language.getLocale().getDisplayName() + .contains("français")) { + Gdx.app.debug("Barre", "Langue USA"); + AssetLoader.language = AssetLoader.usa; + } else { + Gdx.app.debug("Barre", "Langue FR"); + AssetLoader.language = AssetLoader.french; } - else - { - Gdx.app.debug("Barre","Langue FR"); - AssetLoader.language=AssetLoader.french; - } - ((ImageButton)caller).setChecked(AssetLoader.language.getLocale().getDisplayName().contains("français")); - } - else if (caller.getName()=="stat") { + ((ImageButton) caller).setChecked(AssetLoader.language.getLocale() + .getDisplayName().contains("français")); + } else if (caller.getName() == "stat") { } } public void preparemenu(int menuitem) { - checkMenu(menuitem,true); + checkMenu(menuitem, true); menu.clear(); map.tempclear(); map.fillempty(53); - selected=null; + selected = null; menu.EraseMenuTransmuterSurtile(); hideInfo(); - if (menuitem==0) { + if (menuitem == 0) { menu.setMenuTile(0, 7, 71, "copper_pen"); menu.setMenuTile(1, 7, 72, "copper_brush"); menu.setMenuTile(2, 7, 73, "copper_eraser"); @@ -847,79 +949,82 @@ public class GameScreen implements Screen { menu.setMenuTile(0, 5, 77, "transmuter_eraser"); menu.setMenuTile(2, 5, 78, "all_eraser"); menu.setMenuTile(3, 3, 79, "cleaner"); - } - else if (menuitem==1) { - menu.setMenuTransmuter(0,7,"Positiveur I",Angular.A00); - menu.setMenuTransmuter(2,7,"Negativeur I",Angular.A00); - menu.setMenuTransmuter(0,6,"Positiveur II",Angular.A00); - menu.setMenuTransmuter(2,6,"Negativeur II",Angular.A00); - menu.setMenuTransmuter(0,5,"Positiveur III",Angular.A00); - menu.setMenuTransmuter(1,5,"Negativeur III",Angular.A00); - menu.setMenuTransmuter(0,4,"Inverseur I",Angular.A00); - menu.setMenuTransmuter(1,4,"Inverseur II",Angular.A00); - menu.setMenuTransmuter(0,3,"Neutraliseur I",Angular.A00); - menu.setMenuTransmuter(1,3,"Neutraliseur II",Angular.A00); - } - else if (menuitem==2) { + } else if (menuitem == 1) { + menu.setMenuTransmuter(0, 7, "Positiveur I", Angular.A00); + menu.setMenuTransmuter(2, 7, "Negativeur I", Angular.A00); + menu.setMenuTransmuter(0, 6, "Positiveur II", Angular.A00); + menu.setMenuTransmuter(2, 6, "Negativeur II", Angular.A00); + menu.setMenuTransmuter(0, 5, "Positiveur III", Angular.A00); + menu.setMenuTransmuter(1, 5, "Negativeur III", Angular.A00); + menu.setMenuTransmuter(0, 4, "Inverseur I", Angular.A00); + menu.setMenuTransmuter(1, 4, "Inverseur II", Angular.A00); + menu.setMenuTransmuter(0, 3, "Neutraliseur I", Angular.A00); + menu.setMenuTransmuter(1, 3, "Neutraliseur II", Angular.A00); + } else if (menuitem == 2) { - } - else if (menuitem==3) { + } else if (menuitem == 3) { - } - else if (menuitem==4) { + } else if (menuitem == 4) { - } - else if (menuitem==5) { + } else if (menuitem == 5) { - } - else if (menuitem==6) { + } else if (menuitem == 6) { - } - else if (menuitem==7) { - menu.setMenuTransmuter(0,7,"Positiveur non activable",Angular.A00); - menu.setMenuTransmuter(1,7,"Negativeur non activable",Angular.A00); + } else if (menuitem == 7) { + menu.setMenuTransmuter(0, 7, "Positiveur non activable", + Angular.A00); + menu.setMenuTransmuter(1, 7, "Negativeur non activable", + Angular.A00); } } public void showInfo(Transmuter transmuter) { - if (transmuter==null) + if (transmuter == null) return; - unroll=true; + unroll = true; info_nom.setText(transmuter.getName()); info_desc.setText(transmuter.getDesc()); - info_tech.setVisible(transmuter.getTechnology()>0); + info_tech.setVisible(transmuter.getTechnology() > 0); info_tech.setText(String.valueOf(transmuter.getTechnology())); - info_cout.setVisible(transmuter.getPrice()>0); + info_cout.setVisible(transmuter.getPrice() > 0); info_cout.setText(String.valueOf(transmuter.getPrice())); - info_research.setVisible(transmuter.getResearch()>0); + info_research.setVisible(transmuter.getResearch() > 0); info_research.setText(String.valueOf(transmuter.getResearch())); info_activation.setVisible(transmuter.isActivable()); - info_activation.setText(String.valueOf(transmuter.getMaxActivationLevel())); - info_up_cycle.setVisible(transmuter.isUpgradableCycle()); + info_activation.setText(String.valueOf(transmuter + .getMaxActivationLevel())); + info_up_cycle.setVisible(transmuter.isUpgradableCycle()); info_up_nrj.setVisible(transmuter.isUpgradableNrj()); info_up_temp.setVisible(transmuter.isUpgradableTemp()); info_up_rayon.setVisible(transmuter.isUpgradableRayon()); - info_up_cycleval.setVisible(transmuter.isUpgradableCycle()); + info_up_cycleval.setVisible(transmuter.isUpgradableCycle()); info_up_nrjval.setVisible(transmuter.isUpgradableNrj()); info_up_tempval.setVisible(transmuter.isUpgradableTemp()); info_up_rayonval.setVisible(transmuter.isUpgradableRayon()); - info_up_cycleval.getStyle().up =new TextureRegionDrawable(AssetLoader.Atlas_level.findRegion("jauge"+transmuter.getUpgradeCycle())); + info_up_cycleval.getStyle().up = new TextureRegionDrawable( + AssetLoader.Atlas_level.findRegion("jauge" + + transmuter.getUpgradeCycle())); info_up_cycleval.setColor(AssetLoader.Levelcolors[0]); - info_up_nrjval.getStyle().up =new TextureRegionDrawable(AssetLoader.Atlas_level.findRegion("jauge"+transmuter.getUpgradeNrj())); + info_up_nrjval.getStyle().up = new TextureRegionDrawable( + AssetLoader.Atlas_level.findRegion("jauge" + + transmuter.getUpgradeNrj())); info_up_nrjval.setColor(AssetLoader.Levelcolors[4]); - info_up_tempval.getStyle().up =new TextureRegionDrawable(AssetLoader.Atlas_level.findRegion("jauge"+transmuter.getUpgradeTemp())); + info_up_tempval.getStyle().up = new TextureRegionDrawable( + AssetLoader.Atlas_level.findRegion("jauge" + + transmuter.getUpgradeTemp())); info_up_tempval.setColor(AssetLoader.Levelcolors[1]); - info_up_rayonval.getStyle().up =new TextureRegionDrawable(AssetLoader.Atlas_level.findRegion("jauge"+transmuter.getUpgradeRayon())); + info_up_rayonval.getStyle().up = new TextureRegionDrawable( + AssetLoader.Atlas_level.findRegion("jauge" + + transmuter.getUpgradeRayon())); info_up_rayonval.setColor(AssetLoader.Levelcolors[2]); } public void hideInfo() { - unroll=false; - } + unroll = false; + } - public void checkMenu(int menu,boolean check) - { - for (int i=0;i1) - level.Grid=AssetLoader.Datahandler.user().getGrid(0, level.id, selSaved.getSelectedIndex()); - level.Grid.tiling_copper(); - level.Grid.tiling_transmuter(); - map.redraw(53); + if (this.getTapCount() > 1) + level.Grid = AssetLoader.Datahandler.user().getGrid(0, + level.id, selSaved.getSelectedIndex()); + level.Grid.tiling_copper(); + level.Grid.tiling_transmuter(); + map.redraw(53); } }); - ScrollPane scroll=new ScrollPane(selSaved); + ScrollPane scroll = new ScrollPane(selSaved); table.add(scroll).width(250).height(440).row(); return table; } - + public void readsaved() { - Array items=AssetLoader.Datahandler.user().getGrids(0, level.id); - if (items!=null) + Array items = AssetLoader.Datahandler.user().getGrids(0, + level.id); + if (items != null) selSaved.setItems(items); } - + public Table Createoption() { winOptions = new Window("Options", AssetLoader.Skin_ui); winOptions.add(SettingsVideo()).row(); @@ -987,7 +1094,7 @@ public class GameScreen implements Screen { winOptions.setPosition(100, 250); return winOptions; } - + public void readpref() { SetFullscreen.setChecked(Preference.prefs.getBoolean("Fullscreen")); SetSound.setChecked(Preference.prefs.getBoolean("Sound")); @@ -997,142 +1104,168 @@ public class GameScreen implements Screen { SetAnimation.setChecked(Preference.prefs.getBoolean("Animation")); Setflag.setChecked(Preference.prefs.getBoolean("Language")); SetEffectvolume.setValue(Preference.prefs.getFloat("Effect")); - SetMusicvolume.setValue(Preference.prefs.getFloat("Music")); - selResolution.setSelectedIndex(Preference.prefs.getInteger("Resolution")); - selAdaptscreen.setSelectedIndex(Preference.prefs.getInteger("Adaptation")); + SetMusicvolume.setValue(Preference.prefs.getFloat("Music")); + selResolution.setSelectedIndex(Preference.prefs + .getInteger("Resolution")); + selAdaptscreen.setSelectedIndex(Preference.prefs + .getInteger("Adaptation")); selTexturequal.setSelectedIndex(Preference.prefs.getInteger("Quality")); - Setdebog.setChecked(Preference.prefs.getInteger("log")==Gdx.app.LOG_DEBUG); + Setdebog.setChecked(Preference.prefs.getInteger("log") == Gdx.app.LOG_DEBUG); } - + public void writepref() { - Preference.prefs.putInteger("ResolutionX", selResolution.getSelected().getResolutionX()); - Preference.prefs.putInteger("ResolutionY", selResolution.getSelected().getResolutionY()); - Preference.prefs.putInteger("Resolution", selResolution.getSelectedIndex()); + Preference.prefs.putInteger("ResolutionX", selResolution.getSelected() + .getResolutionX()); + Preference.prefs.putInteger("ResolutionY", selResolution.getSelected() + .getResolutionY()); + Preference.prefs.putInteger("Resolution", + selResolution.getSelectedIndex()); Preference.prefs.putBoolean("Fullscreen", SetFullscreen.isChecked()); Preference.prefs.putBoolean("Sound", SetSound.isChecked()); Preference.prefs.putBoolean("Tutorial", Settuto.isChecked()); Preference.prefs.putBoolean("VSync", SetVsynch.isChecked()); Preference.prefs.putBoolean("Refresh", Setrefresh.isChecked()); Preference.prefs.putBoolean("Animation", SetAnimation.isChecked()); - Preference.prefs.putBoolean("Language", Setflag.isChecked()); + Preference.prefs.putBoolean("Language", Setflag.isChecked()); Preference.prefs.putFloat("Effect", SetEffectvolume.getValue()); Preference.prefs.putFloat("Music", SetMusicvolume.getValue()); - Preference.prefs.putInteger("Adaptation", selAdaptscreen.getSelectedIndex()); - Preference.prefs.putInteger("Quality", selTexturequal.getSelectedIndex()); + Preference.prefs.putInteger("Adaptation", + selAdaptscreen.getSelectedIndex()); + Preference.prefs.putInteger("Quality", + selTexturequal.getSelectedIndex()); if (Setdebog.isChecked()) Preference.prefs.putInteger("log", Gdx.app.LOG_DEBUG); else Preference.prefs.putInteger("log", Gdx.app.LOG_INFO); Preference.prefs.flush(); } - + private Table SettingsOther() { Table table = new Table(); table.pad(10, 10, 0, 10); - table.add(new Label("Divers", AssetLoader.Skin_level, "Fluoxetine-25", Color.ORANGE)).colspan(3); + table.add( + new Label("Divers", AssetLoader.Skin_level, "Fluoxetine-25", + Color.ORANGE)).colspan(3); table.row(); table.columnDefaults(0).padRight(10); table.columnDefaults(1).padRight(10); Settuto = new CheckBox("Activation du tutoriel", AssetLoader.Skin_ui); table.add(Settuto).left(); - table.row(); + table.row(); Setdebog = new CheckBox("Mode debugage", AssetLoader.Skin_ui); table.add(Setdebog).left(); table.row(); - Setrefresh = new CheckBox("Afficher le rafraichissement", AssetLoader.Skin_ui); + Setrefresh = new CheckBox("Afficher le rafraichissement", + AssetLoader.Skin_ui); table.add(Setrefresh).left(); - table.row(); - table.add(new Label("Choix de la langue", AssetLoader.Skin_ui, "default-font", Color.WHITE)).left(); - Setflag=new ImageButton(AssetLoader.Skin_level,"Setflag"); + table.row(); + table.add( + new Label("Choix de la langue", AssetLoader.Skin_ui, + "default-font", Color.WHITE)).left(); + Setflag = new ImageButton(AssetLoader.Skin_level, "Setflag"); table.add(Setflag); table.row(); return table; } - + private Table SettingsVideo() { Table table = new Table(); table.pad(10, 10, 0, 10); - table.add(new Label("Video", AssetLoader.Skin_level, "Fluoxetine-25", Color.ORANGE)).colspan(3); + table.add( + new Label("Video", AssetLoader.Skin_level, "Fluoxetine-25", + Color.ORANGE)).colspan(3); table.row(); table.columnDefaults(0).padRight(10); table.columnDefaults(1).padRight(10); - - SetVsynch = new CheckBox("Synchronisation verticale", AssetLoader.Skin_ui); + + SetVsynch = new CheckBox("Synchronisation verticale", + AssetLoader.Skin_ui); table.add(SetVsynch).left(); Table tablev1 = new Table(); - tablev1.add(new Label("Resolution:", AssetLoader.Skin_ui, "default-font", Color.WHITE)).left().row(); + tablev1.add( + new Label("Resolution:", AssetLoader.Skin_ui, "default-font", + Color.WHITE)).left().row(); selResolution = new SelectBox(AssetLoader.Skin_ui); selResolution.setItems(resolutions.values()); tablev1.add(selResolution).left().row(); table.add(tablev1).left(); - table.row(); - + table.row(); + SetFullscreen = new CheckBox("Plein ecran", AssetLoader.Skin_ui); table.add(SetFullscreen).left(); Table tablev2 = new Table(); - tablev2.add(new Label("Remplissage de l'ecran:", AssetLoader.Skin_ui, "default-font", Color.WHITE)).left().row(); + tablev2.add( + new Label("Remplissage de l'ecran:", AssetLoader.Skin_ui, + "default-font", Color.WHITE)).left().row(); selAdaptscreen = new SelectBox(AssetLoader.Skin_ui); selAdaptscreen.setItems(adaptation.values()); tablev2.add(selAdaptscreen).left().row(); table.add(tablev2).left(); table.row(); - + Table tablev3 = new Table(); - tablev3.add(new Label("Qualite des textures:", AssetLoader.Skin_ui, "default-font", Color.WHITE)).left().row(); - SetAnimation = new CheckBox("Activer les animations", AssetLoader.Skin_ui); + tablev3.add( + new Label("Qualite des textures:", AssetLoader.Skin_ui, + "default-font", Color.WHITE)).left().row(); + SetAnimation = new CheckBox("Activer les animations", + AssetLoader.Skin_ui); table.add(SetAnimation).left(); selTexturequal = new SelectBox(AssetLoader.Skin_ui); selTexturequal.setItems(quality.values()); tablev3.add(selTexturequal).left().row(); table.add(tablev3).left(); table.row(); - if(Gdx.app.getType() == ApplicationType.Desktop) { - Graphics.DisplayMode[] modes=Gdx.graphics.getDisplayModes(); - for(resolutions res:resolutions.values()) { + if (Gdx.app.getType() == ApplicationType.Desktop) { + Graphics.DisplayMode[] modes = Gdx.graphics.getDisplayModes(); + for (resolutions res : resolutions.values()) { res.SetFull(false); - for(DisplayMode mode:modes) { - if (res.resx==mode.width && res.resy==mode.height) + for (DisplayMode mode : modes) { + if (res.resx == mode.width && res.resy == mode.height) res.SetFull(true); } } - Vector2 maxres=Preference.getmaxresolution(); + Vector2 maxres = Preference.getmaxresolution(); resolutions.rmax.SetFull(true); - resolutions.rmax.setResolutionX((int)maxres.x); - resolutions.rmax.setResolutionY((int)maxres.y); - } - else + resolutions.rmax.setResolutionX((int) maxres.x); + resolutions.rmax.setResolutionY((int) maxres.y); + } else selResolution.setDisabled(true); return table; } - - + private Table SettingsAudio() { Table table = new Table(); table.pad(10, 10, 0, 10); - table.add(new Label("Audio", AssetLoader.Skin_level, "Fluoxetine-25", Color.ORANGE)).colspan(3); + table.add( + new Label("Audio", AssetLoader.Skin_level, "Fluoxetine-25", + Color.ORANGE)).colspan(3); table.row(); table.columnDefaults(0).padRight(10); table.columnDefaults(1).padRight(10); SetSound = new CheckBox("Activation du son", AssetLoader.Skin_ui); table.add(SetSound).left(); - table.row(); + table.row(); table.add(new Label("Volume des effets", AssetLoader.Skin_ui)); - SetEffectvolume = new Slider(0.0f, 1.0f, 0.1f, false, AssetLoader.Skin_ui); + SetEffectvolume = new Slider(0.0f, 1.0f, 0.1f, false, + AssetLoader.Skin_ui); table.add(SetEffectvolume).left(); table.row(); table.add(new Label("Volume de la musiques", AssetLoader.Skin_ui)); - SetMusicvolume = new Slider(0.0f, 1.0f, 0.1f, false, AssetLoader.Skin_ui); + SetMusicvolume = new Slider(0.0f, 1.0f, 0.1f, false, + AssetLoader.Skin_ui); table.add(SetMusicvolume).left(); - table.row(); + table.row(); return table; } - + private void onSaveClicked() { winOptions.setVisible(false); writepref(); - dialog.Show("Veuillez redémmarrer pour que les préférences soient appliquées.", stage); + dialog.Show( + "Veuillez redémmarrer pour que les préférences soient appliquées.", + stage); } - + private void onCancelClicked() { winOptions.setVisible(false); } diff --git a/core/src/fr/evolving/screens/LevelScreen.java b/core/src/fr/evolving/screens/LevelScreen.java index 3b0e83d..47a1f6f 100644 --- a/core/src/fr/evolving/screens/LevelScreen.java +++ b/core/src/fr/evolving/screens/LevelScreen.java @@ -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 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+" N°"+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 + " N°" + 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 (world0) { - 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