From ee17dfd5d58caf0b4c95c8bd9a5079cbdc0eb23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sun, 2 Aug 2015 18:19:09 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20ajout=20de=20fichiers=20pr=C3=A9c=C3=A9?= =?UTF-8?q?demment=20oubli=C3=A9s=20dans=20git=20(dossier=20ui)=20cr=C3=A9?= =?UTF-8?q?ation=20de=20la=20classe=20transmuter=20cr=C3=A9ation=20de=203?= =?UTF-8?q?=20classes=20d=C3=A9riv=C3=A9e=20pour=20le=20positiver=201,2=20?= =?UTF-8?q?&=203=20r=C3=A9alisation=20de=20test=20pour=20v=C3=A9rifier=20q?= =?UTF-8?q?ue=20la=20classe=20fonctionne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/fr/evolving/UI/Menu.java | 103 +++++++ core/src/fr/evolving/UI/Objectives.java | 58 ++++ core/src/fr/evolving/UI/TouchMaptiles.java | 143 ++++++++++ core/src/fr/evolving/automata/Grid.java | 84 +++--- .../src/fr/evolving/automata/Positiver_I.java | 257 ++++++++++++++++++ .../fr/evolving/automata/Positiver_II.java | 256 +++++++++++++++++ .../fr/evolving/automata/Positiver_III.java | 256 +++++++++++++++++ core/src/fr/evolving/automata/Transmuter.java | 183 ++++++++++++- core/src/fr/evolving/screens/GameScreen.java | 45 ++- 9 files changed, 1340 insertions(+), 45 deletions(-) create mode 100644 core/src/fr/evolving/UI/Menu.java create mode 100644 core/src/fr/evolving/UI/Objectives.java create mode 100644 core/src/fr/evolving/UI/TouchMaptiles.java create mode 100644 core/src/fr/evolving/automata/Positiver_I.java create mode 100644 core/src/fr/evolving/automata/Positiver_II.java create mode 100644 core/src/fr/evolving/automata/Positiver_III.java diff --git a/core/src/fr/evolving/UI/Menu.java b/core/src/fr/evolving/UI/Menu.java new file mode 100644 index 0000000..3c99ab7 --- /dev/null +++ b/core/src/fr/evolving/UI/Menu.java @@ -0,0 +1,103 @@ +package fr.evolving.UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.maps.MapLayers; +import com.badlogic.gdx.maps.tiled.TiledMap; +import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; +import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; +import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.scenes.scene2d.Actor; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Level; + +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); + } + 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; + camera.translate(decx,decy); + Gdx.app.debug(getClass().getSimpleName(),"Décalage:"+decx+"x"+decy); +} + +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 setMenu(int x,int y,int tile) +{ + Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y); + if (cell!=null) + cell.setTile(AssetLoader.tileSet.getTile(tile)); +} + +public int getMenu(int x,int y) +{ + Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y); + if (cell!=null) + return cell.getTile().getId(); + else + return 0; +} + +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 new file mode 100644 index 0000000..a523df5 --- /dev/null +++ b/core/src/fr/evolving/UI/Objectives.java @@ -0,0 +1,58 @@ +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.g2d.BitmapFont.HAlignment; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; +import com.badlogic.gdx.scenes.scene2d.Actor; + +import fr.evolving.assets.AssetLoader; + +public class Objectives extends Actor { + + public ShapeRenderer shaperenderer; + 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"); + } + + public void setVictory(int[] 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) { + batch.end(); + shaperenderer.begin(ShapeType.Filled); + shaperenderer.setColor(AssetLoader.Typecolors[type]); + 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.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; + } + type+=1; + } + } + + +} diff --git a/core/src/fr/evolving/UI/TouchMaptiles.java b/core/src/fr/evolving/UI/TouchMaptiles.java new file mode 100644 index 0000000..43ccc27 --- /dev/null +++ b/core/src/fr/evolving/UI/TouchMaptiles.java @@ -0,0 +1,143 @@ +package fr.evolving.UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.maps.MapLayers; +import com.badlogic.gdx.maps.tiled.TiledMap; +import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; +import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; +import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.scenes.scene2d.Actor; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Level; + +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 < 3; 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); + } + MapRenderer = new OrthogonalTiledMapRenderer(map,1/128.0f); + camera = new OrthographicCamera(); + initzoom(); +} + +public Vector2 screentoworld(float x, float y) { + x=(int)((x/AssetLoader.width*camera.viewportWidth)+decx); + y=(int)((y/AssetLoader.height*camera.viewportHeight)+decy); + return new Vector2(x,y); +} + +public Vector2 screentoworldsize(float x, float y) { + x=((x/AssetLoader.width*camera.viewportWidth)); + y=((y/AssetLoader.height*camera.viewportHeight)); + return new Vector2(x,y); +} + +public void redraw(int tile) { + 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 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 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/automata/Grid.java b/core/src/fr/evolving/automata/Grid.java index 623a098..286c306 100644 --- a/core/src/fr/evolving/automata/Grid.java +++ b/core/src/fr/evolving/automata/Grid.java @@ -21,16 +21,16 @@ public class Grid implements Serializable{ public void tiling() { for (int x=0;x=5) GetXY(x,y).Copper_calc=GetXY(x,y).Copper_calc+20; } else { - if (GetCoppercalc(x,y)!=-1) + if (getCoppercalc(x,y)!=-1) { int oldvalue=GetXY(x,y).Copper_calc; - if (GetCoppercalc(x-1,y-1)==15 || GetCoppercalc(x-1,y-1)==35) + if (getCoppercalc(x-1,y-1)==15 || getCoppercalc(x-1,y-1)==35) value++; - if (GetCoppercalc(x,y-1)==15 || GetCoppercalc(x,y-1)==35) + if (getCoppercalc(x,y-1)==15 || getCoppercalc(x,y-1)==35) value++; - if (GetCoppercalc(x+1,y-1)==15 || GetCoppercalc(x+1,y-1)==35) + if (getCoppercalc(x+1,y-1)==15 || getCoppercalc(x+1,y-1)==35) value++; - if (GetCoppercalc(x-1,y)==15 || GetCoppercalc(x-1,y)==35) + if (getCoppercalc(x-1,y)==15 || getCoppercalc(x-1,y)==35) value++; - if (GetCoppercalc(x+1,y)==15 || GetCoppercalc(x+1,y)==35) + if (getCoppercalc(x+1,y)==15 || getCoppercalc(x+1,y)==35) value++; - if (GetCoppercalc(x-1,y+1)==15 || GetCoppercalc(x-1,y+1)==35) + if (getCoppercalc(x-1,y+1)==15 || getCoppercalc(x-1,y+1)==35) value++; - if (GetCoppercalc(x,y+1)==15 || GetCoppercalc(x,y+1)==35) + if (getCoppercalc(x,y+1)==15 || getCoppercalc(x,y+1)==35) value++; - if (GetCoppercalc(x+1,y+1)==15 || GetCoppercalc(x+1,y+1)==35) + if (getCoppercalc(x+1,y+1)==15 || getCoppercalc(x+1,y+1)==35) value++; if (value>=1 && oldvalue!=1 && oldvalue!=2 && oldvalue!=4 && oldvalue!=8 && oldvalue!=10 && oldvalue!=5) GetXY(x,y).Copper_calc=oldvalue+20; @@ -90,16 +90,16 @@ public class Grid implements Serializable{ 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)) + if (oldvalue==34 && (getCoppercalc(x-1,y)==31 || getCoppercalc(x-1,y)==55 || getCoppercalc(x-1,y)==58)) value=62; - if (oldvalue==34 && (GetCoppercalc(x+1,y)==31 || GetCoppercalc(x+1,y)==55 || GetCoppercalc(x+1,y)==58)) + if (oldvalue==34 && (getCoppercalc(x+1,y)==31 || getCoppercalc(x+1,y)==55 || getCoppercalc(x+1,y)==58)) value=58; - if (oldvalue==31 && (GetCoppercalc(x-1,y)==34 || GetCoppercalc(x-1,y)==58 || GetCoppercalc(x-1,y)==62)) + if (oldvalue==31 && (getCoppercalc(x-1,y)==34 || getCoppercalc(x-1,y)==58 || getCoppercalc(x-1,y)==62)) value=59; - if (oldvalue==31 && (GetCoppercalc(x+1,y)==34 || GetCoppercalc(x+1,y)==58 || GetCoppercalc(x+1,y)==62)) + if (oldvalue==31 && (getCoppercalc(x+1,y)==34 || getCoppercalc(x+1,y)==58 || getCoppercalc(x+1,y)==62)) value=55; - if (oldvalue==33 && (GetCoppercalc(x,y-1)==27 || GetCoppercalc(x,y-1)==50 || GetCoppercalc(x,y-1)==51)) + if (oldvalue==33 && (getCoppercalc(x,y-1)==27 || getCoppercalc(x,y-1)==50 || getCoppercalc(x,y-1)==51)) value=57; - if (oldvalue==33 && (GetCoppercalc(x,y+1)==27 || GetCoppercalc(x,y+1)==50 || GetCoppercalc(x,y+1)==51)) + if (oldvalue==33 && (getCoppercalc(x,y+1)==27 || getCoppercalc(x,y+1)==50 || getCoppercalc(x,y+1)==51)) value=56; - if (oldvalue==27 && (GetCoppercalc(x,y-1)==33 || GetCoppercalc(x,y-1)==56 || GetCoppercalc(x,y-1)==57)) + if (oldvalue==27 && (getCoppercalc(x,y-1)==33 || getCoppercalc(x,y-1)==56 || getCoppercalc(x,y-1)==57)) value=51; - if (oldvalue==27 && (GetCoppercalc(x,y+1)==33 || GetCoppercalc(x,y+1)==56 || GetCoppercalc(x,y+1)==57)) + if (oldvalue==27 && (getCoppercalc(x,y+1)==33 || getCoppercalc(x,y+1)==56 || getCoppercalc(x,y+1)==57)) value=50; if (value>0) GetXY(x,y).Copper_calc=value; @@ -154,7 +154,7 @@ public class Grid implements Serializable{ return this.Cells[(int)X][(int)Y]; } - public boolean GetCopper(float X,float Y) { + public boolean getCopper(float X,float Y) { Cell cell=GetXY(X,Y); if (cell==null) return false; @@ -170,7 +170,7 @@ public class Grid implements Serializable{ return cell.Fiber>0; } - public int GetCoppercalc(float X,float Y) { + public int getCoppercalc(float X,float Y) { Cell cell=GetXY(X,Y); if (cell==null) return 0; diff --git a/core/src/fr/evolving/automata/Positiver_I.java b/core/src/fr/evolving/automata/Positiver_I.java new file mode 100644 index 0000000..4419c29 --- /dev/null +++ b/core/src/fr/evolving/automata/Positiver_I.java @@ -0,0 +1,257 @@ +package fr.evolving.automata; + +import java.util.HashMap; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Positiver_I extends Transmuter { + private static String Name; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static int Id; + private static boolean Activable; + private int ActivationLevel; + private static HashMap Tiles; + + public Positiver_I(Level level) { + super(level); + this.Name="positiveur I"; + 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.Id=0; + this.Activable=true; + this.ActivationLevel=0; + this.Tiles= new HashMap(); + this.Tiles.put(new Vector2(1,0), CaseType.Fibre); + } + + public String getName() { + return this.Name; + } + + 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; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public int getMainTile() { + return this.getSize()*100+Id*this.getSize(); + } + + public int FindMainTile(int Id) { + int thesize=Id/100; + int deltaid=Id-thesize*100; + return thesize*100+((int)(deltaid/thesize))*thesize; + } + + public HashMap getTiles() { + return this.Tiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tiles.size()+1); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + 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 new file mode 100644 index 0000000..60a09fe --- /dev/null +++ b/core/src/fr/evolving/automata/Positiver_II.java @@ -0,0 +1,256 @@ +package fr.evolving.automata; + +import java.util.HashMap; + +import com.badlogic.gdx.math.Vector2; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Positiver_II extends Transmuter { + private static String Name; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static int Id; + private static boolean Activable; + private int ActivationLevel; + private static HashMap Tiles; + + public Positiver_II(Level level) { + super(level); + this.Name="positiveur II"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=40; + 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.Id=1; + this.Activable=true; + this.ActivationLevel=0; + this.Tiles= new HashMap(); + this.Tiles.put(new Vector2(1,0), CaseType.Fibre); + } + + public String getName() { + return this.Name; + } + + 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; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public int getMainTile() { + return this.getSize()*100+Id*this.getSize(); + } + + public int FindMainTile(int Id) { + int thesize=Id/100; + int deltaid=Id-thesize*100; + return thesize*100+((int)(deltaid/thesize))*thesize; + } + + public HashMap getTiles() { + return this.Tiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tiles.size()+1); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + 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 new file mode 100644 index 0000000..890abb0 --- /dev/null +++ b/core/src/fr/evolving/automata/Positiver_III.java @@ -0,0 +1,256 @@ +package fr.evolving.automata; + +import java.util.HashMap; + +import com.badlogic.gdx.math.Vector2; + +import fr.evolving.automata.Transmuter.CaseType; +import fr.evolving.automata.Transmuter.Class; + +public class Positiver_III extends Transmuter { + private static String Name; + private static Class theClass; + private static int Price; + private static int Technology; + private static int Research; + private static Transmuter Upgrade; + private static Transmuter Unlock; + private static boolean showed; + private static boolean CanUpgradeTemp; + private static boolean CanUpgradeCycle; + private static boolean CanUpgradeRayon; + private static boolean CanUpgradeNrj; + private static float UpgradedTemp; + private static float UpgradedCycle; + private static float UpgradedRayon; + private static float UpgradedNrj; + private static float UsedTemp; + private static float UsedRayon; + private static float UsedNrj; + private static float TurnTemp; + private static float TurnRayon; + private static float TurnNrj; + private static int Id; + private static boolean Activable; + private int ActivationLevel; + private static HashMap Tiles; + + public Positiver_III(Level level) { + super(level); + this.Name="positiveur III"; + this.theClass=Class.Charge; + this.Price=50; + this.Technology=2; + this.Research=120; + 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.Id=1; + this.Activable=true; + this.ActivationLevel=0; + this.Tiles= new HashMap(); + this.Tiles.put(new Vector2(1,0), CaseType.Fibre); + } + + public String getName() { + return this.Name; + } + + 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; + if (this.Activable) + this.ActivationLevel-=1; + } + + public void Run() { + this.level.Temp+=UsedTemp*UpgradedTemp; + this.level.Rayon+=UsedRayon*UpgradedRayon; + this.level.Nrj+=UsedNrj*UpgradedNrj; + } + + public void Unlock() { + if (this.Unlock==null) + return; + this.Unlock.SetShowed(true); + } + + public void Upgrade() { + if (this.Upgrade==null) + return; + this.Unlock.SetShowed(true); + this.SetShowed(false); + } + + public void Activate() { + if (this.Activable) + ActivationLevel=(int)(10*this.UpgradedCycle); + } + + public void UpgradeTemp() { + if (isUpgradableTemp()) + UpgradedTemp+=-0.2f; + } + + public void UpgradeNrj() { + if (isUpgradableNrj()) + UpgradedNrj+=-0.2f; + } + + public void UpgradeRayon() { + if (isUpgradableRayon()) + UpgradedRayon+=-0.2f; + } + + public void UpgradeCycle() { + if (isUpgradableCycle()) + UpgradedCycle+=0.2f; + } + + public int getMainTile() { + return this.getSize()*100+Id*this.getSize(); + } + + public int FindMainTile(int Id) { + int thesize=Id/100; + int deltaid=Id-thesize*100; + return thesize*100+((int)(deltaid/thesize))*thesize; + } + + public HashMap getTiles() { + return this.Tiles; + } + + public boolean isActivable() { + return this.Activable; + } + + public int getActivationLevel() { + if (this.Activable) + return ActivationLevel; + else + return -1; + } + + public boolean getActivation() { + if (this.Activable) + return ActivationLevel>0; + else + return true; + } + + public int getPrice() { + return Price; + } + + public int getSize() { + return (Tiles.size()+1); + } + + public int getTechnology() { + return Technology; + } + + public int getResearch() { + return Research; + } + + public boolean isUpgradable() { + return this.Upgrade!=null && this.Upgrade.isShowed(); + } + + public boolean isUnlockable() { + return this.Unlock!=null && this.Unlock.isShowed(); + } + + public boolean isShowed() { + return this.showed; + } + + public void SetShowed(boolean value) { + this.showed=value; + } + + public boolean isUpgradableTemp() { + return CanUpgradeTemp && getUpgradeTemp()<3; + } + + public boolean isUpgradableCycle() { + return CanUpgradeCycle && getUpgradeCycle()<3; + } + + public boolean isUpgradableRayon() { + return CanUpgradeRayon && getUpgradeRayon()<3; + } + + public boolean isUpgradableNrj() { + return CanUpgradeNrj && getUpgradeNrj()<3; + } + + public int getUpgradeTemp() { + return Math.abs((int)((10*UpgradedTemp-10)/2f)); + } + + public int getUpgradeCycle() { + return Math.abs((int)((10*UpgradedCycle-10)/2f)); + } + + public int getUpgradeRayon() { + return Math.abs((int)((10*UpgradedRayon-10)/2f)); + } + + public int getUpgradeNrj() { + return Math.abs((int)((10*UpgradedNrj-10)/2f)); + } + + public float getUsedTemp() { + return UsedTemp*UpgradedTemp; + } + + public float getUsedRayon() { + return UsedRayon*UpgradedRayon; + } + + public float getUsedNrj() { + return UsedNrj*UpgradedNrj; + } + + public float getTurnTemp() { + return TurnTemp*UpgradedTemp; + } + + public float getTurnRayon() { + return TurnRayon*UpgradedRayon; + } + + public float getTurnNrj() { + 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 e17df72..3fca7b1 100644 --- a/core/src/fr/evolving/automata/Transmuter.java +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -1,5 +1,184 @@ package fr.evolving.automata; -abstract public class Transmuter { +import java.util.HashMap; +import java.util.Iterator; -} +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; + +public abstract class Transmuter { + public enum CaseType{Rien,Cuivre,Fibre,Tout,Nimporte}; + public enum Class{Structure,Charge,Direction,Filtrage,Synthèse,Détection,Divers,Scénario}; + protected Level level; + + public Transmuter(Level level) { + this.level=level; + } + + public String getName() { + 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 int getMainTile() { + return 0; + } + + public int FindMainTile(int Id) { + return 0; + } + + public HashMap getTiles() { + return null; + } + + public int getActivationLevel() { + return 0; + } + + public boolean getActivation() { + return false; + } + + public int getPrice() { + return 0; + } + + public int getSize() { + return 0; + } + + public int getTechnology() { + return 0; + } + + 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() { + Iterator keySetIterator = this.getTiles().keySet().iterator(); + String result; + result="**********************************\n"+"Name:"+this.getName()+"\nClass:"+this.getaClass()+" Id:"+this.getMainTile()+"\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()+"\n"; + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + result+="coords:" + key + " type: " + this.getTiles().get(key); + } + result+="\n**********************************"; + return result; + + } +} \ No newline at end of file diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index 25dbaa4..663b1c5 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -1,5 +1,6 @@ package fr.evolving.screens; +import java.util.Iterator; import java.util.Timer; import java.util.TimerTask; @@ -42,6 +43,8 @@ import fr.evolving.UI.Objectives; import fr.evolving.UI.TouchMaptiles; import fr.evolving.assets.AssetLoader; import fr.evolving.automata.Level; +import fr.evolving.automata.Positiver_I; +import fr.evolving.automata.Positiver_II; import fr.evolving.inputs.InputHandler; public class GameScreen implements Screen { @@ -123,6 +126,46 @@ public class GameScreen implements Screen { Gdx.app.debug(event.getListenerActor().toString(),"Barre:Niveaux"); ((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen(level.aWorld)); } + }); + Barre[0].addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.debug(event.getListenerActor().toString(),"tests"); + level.Grid.Cells[0][0].Transmuter=new Positiver_I(level); + level.Grid.Cells[0][1].Transmuter=new Positiver_II(level); + level.Grid.Cells[0][2].Transmuter=new Positiver_I(level); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[0][0].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 activation",String.valueOf(level.Grid.Cells[0][0].Transmuter.getActivationLevel())); + Gdx.app.debug("2 activation",String.valueOf(level.Grid.Cells[0][2].Transmuter.getActivationLevel())); + level.Grid.Cells[0][0].Transmuter.Activate(); + level.Grid.Cells[0][0].Transmuter.UpgradeCycle(); + Gdx.app.debug("0 activation",String.valueOf(level.Grid.Cells[0][0].Transmuter.getActivationLevel())); + Gdx.app.debug("2 activation",String.valueOf(level.Grid.Cells[0][2].Transmuter.getActivationLevel())); + level.Grid.Cells[0][0].Transmuter.Activate(); + Gdx.app.debug("0 activation",String.valueOf(level.Grid.Cells[0][0].Transmuter.getActivationLevel())); + Gdx.app.debug("2 upgrade",String.valueOf(level.Grid.Cells[0][2].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[0][0].Transmuter.getUpgradeCycle())); + level.Grid.Cells[0][0].Transmuter.UpgradeCycle(); + Gdx.app.debug("2 upgrade",String.valueOf(level.Grid.Cells[0][2].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[0][0].Transmuter.getUpgradeCycle())); + level.Grid.Cells[0][0].Transmuter.UpgradeCycle(); + Gdx.app.debug("2 upgrade",String.valueOf(level.Grid.Cells[0][2].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[0][0].Transmuter.getUpgradeCycle())); + level.Grid.Cells[0][0].Transmuter.UpgradeCycle(); + Gdx.app.debug("2 upgrade",String.valueOf(level.Grid.Cells[0][2].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[0][0].Transmuter.getUpgradeCycle())); + Gdx.app.debug("1 upgrade",String.valueOf(level.Grid.Cells[0][1].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 nom",String.valueOf(level.Grid.Cells[0][0].Transmuter.getName())); + Gdx.app.debug("1 nom",String.valueOf(level.Grid.Cells[0][1].Transmuter.getName())); + Gdx.app.debug("1 taille",String.valueOf(level.Grid.Cells[0][1].Transmuter.getTiles().size())); + level.Grid.Cells[0][0].Transmuter.UpgradeTemp(); + level.Grid.Cells[0][1].Transmuter.UpgradeTemp(); + level.Grid.Cells[0][2].Transmuter.UpgradeTemp(); + level.Grid.Cells[0][2].Transmuter.UpgradeNrj(); + Gdx.app.debug("0 informations",String.valueOf(level.Grid.Cells[0][0].Transmuter.getInformations())); + Gdx.app.debug("1 informations",String.valueOf(level.Grid.Cells[0][1].Transmuter.getInformations())); + Gdx.app.debug("2 informations",String.valueOf(level.Grid.Cells[0][2].Transmuter.getInformations())); + } }); if (Gdx.graphics.isFullscreen()) Barre[14].getStyle().up =new TextureRegionDrawable(AssetLoader.Atlas_level.findRegion("windows")); @@ -313,7 +356,7 @@ public class GameScreen implements Screen { if (level.Grid.GetXY(coords.x,coords.y)!=null) { Gdx.app.debug(event.getListenerActor().toString(),"Screen coordinates translated to world coordinates: "+ "X: " + coords.x + " Y: " + coords.y); - if (level.Grid.GetCopper(coords.x,coords.y)==false) + if (level.Grid.getCopper(coords.x,coords.y)==false) level.Grid.GetXY(coords.x,coords.y).Copper=true; else level.Grid.GetXY(coords.x,coords.y).Copper=false;