From 7a3e33dd6b0d7448dd2fde35943afa9e4272bfa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Wed, 5 Aug 2015 12:03:53 +0200 Subject: [PATCH] feat: ajout de l'affichage des transmuters --- core/src/fr/evolving/UI/TouchMaptiles.java | 7 ++ core/src/fr/evolving/assets/AssetLoader.java | 23 +++++ core/src/fr/evolving/automata/Cell.java | 4 +- core/src/fr/evolving/automata/Grid.java | 55 ++++++++++- .../src/fr/evolving/automata/Positiver_I.java | 22 ++++- .../fr/evolving/automata/Positiver_II.java | 20 +++- .../fr/evolving/automata/Positiver_III.java | 22 ++++- core/src/fr/evolving/automata/Transmuter.java | 25 ++++- core/src/fr/evolving/screens/GameScreen.java | 95 +++++++++++-------- 9 files changed, 224 insertions(+), 49 deletions(-) diff --git a/core/src/fr/evolving/UI/TouchMaptiles.java b/core/src/fr/evolving/UI/TouchMaptiles.java index 43ccc27..b421ed9 100644 --- a/core/src/fr/evolving/UI/TouchMaptiles.java +++ b/core/src/fr/evolving/UI/TouchMaptiles.java @@ -13,6 +13,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor; import fr.evolving.assets.AssetLoader; import fr.evolving.automata.Level; +import fr.evolving.automata.Transmuter; public class TouchMaptiles extends Actor{ @@ -71,6 +72,12 @@ public void redraw(int tile) { ((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(61)); else ((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(tile)); + if (level.Grid.getTransmutercalc(x, y)==0) + ((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).setTile(null); + else { + ((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(level.Grid.getTransmutercalc(x, y))); + ((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).setRotation(level.Grid.getTransmuterrot(x, y)); + } } } diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index 7500fed..9af1b05 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -29,6 +29,11 @@ import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.ScalingViewport; import com.badlogic.gdx.utils.viewport.StretchViewport; +import fr.evolving.automata.Positiver_I; +import fr.evolving.automata.Positiver_II; +import fr.evolving.automata.Positiver_III; +import fr.evolving.automata.Transmuter; + public class AssetLoader { public static Skin Skin_level; public static TextureAtlas Atlas_level; @@ -52,6 +57,7 @@ public class AssetLoader { public static NinePatch full; public static AssetManager manager; public static TiledMapTileSet tileSet; + public static Transmuter[] allTransmuter; public static void addstyle(TextureAtlas Atlas_level,String Name) { AtlasRegion AnAtlasRegion = Atlas_level.findRegion(Name); @@ -125,6 +131,23 @@ public class AssetLoader { Gdx.app.debug("AssetLoader","Tiles N°:"+String.valueOf(i)); } } + allTransmuter=new Transmuter[3]; + allTransmuter[0]=new Positiver_I(null); + allTransmuter[1]=new Positiver_II(null); + allTransmuter[2]=new Positiver_III(null); + for(int i=0;i keySetIterator = transmuter.getTiles().keySet().iterator(); + int MainTile=transmuter.getMainTile(); + GetXY(x,y).Transmuter_calc=(1<<16)*transmuter.getRotation().ordinal()+MainTile++; + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + GetXY(x+key.x,y+key.y).Transmuter_calc=(1<<16)*transmuter.getRotation().ordinal()+MainTile++; + } + } + } + for (int x=0;x0) + Gdx.app.debug("info",x+","+y+">"+GetXY(x, y).Transmuter_calc); + } + } + + public void tiling_copper() { for (int x=0;x>16; + } + public boolean getCopper(float X,float Y) { Cell cell=GetXY(X,Y); if (cell==null) diff --git a/core/src/fr/evolving/automata/Positiver_I.java b/core/src/fr/evolving/automata/Positiver_I.java index 4419c29..d3844a0 100644 --- a/core/src/fr/evolving/automata/Positiver_I.java +++ b/core/src/fr/evolving/automata/Positiver_I.java @@ -1,6 +1,7 @@ package fr.evolving.automata; import java.util.HashMap; +import java.util.Iterator; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; @@ -34,6 +35,7 @@ public class Positiver_I extends Transmuter { private static int Id; private static boolean Activable; private int ActivationLevel; + private int Rotation; private static HashMap Tiles; public Positiver_I(Level level) { @@ -137,8 +139,25 @@ public class Positiver_I extends Transmuter { return thesize*100+((int)(deltaid/thesize))*thesize; } + public int[] getallTiles() { + int thesize=Tiles.size()+1; + int[] result; + result=new int[thesize]; + for(int i=0;i getTiles() { - return this.Tiles; + HashMap newTiles= new HashMap(); + Iterator keySetIterator = this.Tiles.keySet().iterator(); + 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.Tiles.get(key)); + } + return newTiles; } public boolean isActivable() { @@ -254,4 +273,5 @@ public class Positiver_I extends Transmuter { 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 60a09fe..b67373a 100644 --- a/core/src/fr/evolving/automata/Positiver_II.java +++ b/core/src/fr/evolving/automata/Positiver_II.java @@ -1,6 +1,7 @@ package fr.evolving.automata; import java.util.HashMap; +import java.util.Iterator; import com.badlogic.gdx.math.Vector2; @@ -136,8 +137,25 @@ public class Positiver_II extends Transmuter { return thesize*100+((int)(deltaid/thesize))*thesize; } + public int[] getallTiles() { + int thesize=Tiles.size()+1; + int[] result; + result=new int[thesize]; + for(int i=0;i getTiles() { - return this.Tiles; + HashMap newTiles= new HashMap(); + Iterator keySetIterator = this.Tiles.keySet().iterator(); + 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.Tiles.get(key)); + } + return newTiles; } public boolean isActivable() { diff --git a/core/src/fr/evolving/automata/Positiver_III.java b/core/src/fr/evolving/automata/Positiver_III.java index 890abb0..87ba68c 100644 --- a/core/src/fr/evolving/automata/Positiver_III.java +++ b/core/src/fr/evolving/automata/Positiver_III.java @@ -1,6 +1,7 @@ package fr.evolving.automata; import java.util.HashMap; +import java.util.Iterator; import com.badlogic.gdx.math.Vector2; @@ -59,7 +60,7 @@ public class Positiver_III extends Transmuter { this.TurnTemp=0f; this.TurnRayon=0f; this.TurnNrj=0f; - this.Id=1; + this.Id=2; this.Activable=true; this.ActivationLevel=0; this.Tiles= new HashMap(); @@ -136,8 +137,25 @@ public class Positiver_III extends Transmuter { return thesize*100+((int)(deltaid/thesize))*thesize; } + public int[] getallTiles() { + int thesize=Tiles.size()+1; + int[] result; + result=new int[thesize]; + for(int i=0;i getTiles() { - return this.Tiles; + HashMap newTiles= new HashMap(); + Iterator keySetIterator = this.Tiles.keySet().iterator(); + 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.Tiles.get(key)); + } + return newTiles; } public boolean isActivable() { diff --git a/core/src/fr/evolving/automata/Transmuter.java b/core/src/fr/evolving/automata/Transmuter.java index 3fca7b1..a77787f 100644 --- a/core/src/fr/evolving/automata/Transmuter.java +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -9,10 +9,13 @@ 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}; + public enum Angular{A00,A90,A180,A270}; protected Level level; + protected Angular Rotation; public Transmuter(Level level) { this.level=level; + this.Rotation=Angular.A00; } public String getName() { @@ -168,17 +171,31 @@ public abstract class Transmuter { public float getTurnNrj() { return 0; } + + public int[] getallTiles() { + return null; + } public String getInformations() { - Iterator keySetIterator = this.getTiles().keySet().iterator(); + HashMap tiles=this.getTiles(); + Iterator keySetIterator = tiles.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()){ + result="**********************************\n"+"Name:"+this.getName()+"\nClass:"+this.getaClass()+" Id:"+this.getMainTile()+" 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()+"\n"; + while(keySetIterator.hasNext()){ Vector2 key = keySetIterator.next(); - result+="coords:" + key + " type: " + this.getTiles().get(key); + result+="\ncoords:" + key.x+","+key.y + " type: " + tiles.get(key); } result+="\n**********************************"; return result; } + + + public Angular getRotation() { + return this.Rotation; + } + + public void setRotation(Angular rotation) { + this.Rotation=rotation; + } } \ 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 663b1c5..fa02f74 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -45,6 +45,8 @@ 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.automata.Positiver_III; +import fr.evolving.automata.Transmuter.Angular; import fr.evolving.inputs.InputHandler; public class GameScreen implements Screen { @@ -131,40 +133,57 @@ public class GameScreen implements Screen { @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())); + level.Grid.Cells[10][0].Transmuter=new Positiver_I(level); + level.Grid.Cells[10][1].Transmuter=new Positiver_II(level); + level.Grid.Cells[10][2].Transmuter=new Positiver_I(level); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[10][0].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 activation",String.valueOf(level.Grid.Cells[10][0].Transmuter.getActivationLevel())); + Gdx.app.debug("2 activation",String.valueOf(level.Grid.Cells[10][2].Transmuter.getActivationLevel())); + level.Grid.Cells[10][0].Transmuter.Activate(); + level.Grid.Cells[10][0].Transmuter.UpgradeCycle(); + Gdx.app.debug("0 activation",String.valueOf(level.Grid.Cells[10][0].Transmuter.getActivationLevel())); + Gdx.app.debug("2 activation",String.valueOf(level.Grid.Cells[10][2].Transmuter.getActivationLevel())); + level.Grid.Cells[10][0].Transmuter.Activate(); + Gdx.app.debug("0 activation",String.valueOf(level.Grid.Cells[10][0].Transmuter.getActivationLevel())); + Gdx.app.debug("2 upgrade",String.valueOf(level.Grid.Cells[10][2].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[10][0].Transmuter.getUpgradeCycle())); + level.Grid.Cells[10][0].Transmuter.UpgradeCycle(); + Gdx.app.debug("2 upgrade",String.valueOf(level.Grid.Cells[10][2].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[10][0].Transmuter.getUpgradeCycle())); + level.Grid.Cells[10][0].Transmuter.UpgradeCycle(); + Gdx.app.debug("2 upgrade",String.valueOf(level.Grid.Cells[10][2].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[10][0].Transmuter.getUpgradeCycle())); + level.Grid.Cells[10][0].Transmuter.UpgradeCycle(); + Gdx.app.debug("2 upgrade",String.valueOf(level.Grid.Cells[10][2].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 upgrade",String.valueOf(level.Grid.Cells[10][0].Transmuter.getUpgradeCycle())); + Gdx.app.debug("1 upgrade",String.valueOf(level.Grid.Cells[10][1].Transmuter.getUpgradeCycle())); + Gdx.app.debug("0 nom",String.valueOf(level.Grid.Cells[10][0].Transmuter.getName())); + Gdx.app.debug("1 nom",String.valueOf(level.Grid.Cells[10][1].Transmuter.getName())); + Gdx.app.debug("1 taille",String.valueOf(level.Grid.Cells[10][1].Transmuter.getTiles().size())); + level.Grid.Cells[10][0].Transmuter.UpgradeTemp(); + level.Grid.Cells[10][1].Transmuter.UpgradeTemp(); + level.Grid.Cells[10][2].Transmuter.UpgradeTemp(); + level.Grid.Cells[10][2].Transmuter.UpgradeNrj(); + level.Grid.Cells[10][2].Transmuter.setRotation(Angular.A90); + Gdx.app.debug("2 informations",String.valueOf(level.Grid.Cells[10][0].Transmuter.getInformations())); + Gdx.app.debug("2 informations",String.valueOf(level.Grid.Cells[10][1].Transmuter.getInformations())); + Gdx.app.debug("2 informations",String.valueOf(level.Grid.Cells[10][2].Transmuter.getInformations())); + level.Grid.Cells[5][5].Transmuter=new Positiver_I(level); + level.Grid.Cells[5][5].Transmuter.setRotation(Angular.A90); + level.Grid.Cells[8][8].Transmuter=new Positiver_II(level); + level.Grid.Cells[8][8].Transmuter.setRotation(Angular.A180); + level.Grid.Cells[2][2].Transmuter=new Positiver_I(level); + level.Grid.Cells[2][2].Transmuter.setRotation(Angular.A270); + level.Grid.Cells[7][2].Transmuter=new Positiver_III(level); + level.Grid.Cells[7][2].Transmuter.setRotation(Angular.A270); + level.Grid.tiling_transmuter(); + int[] result; + result=level.Grid.Cells[5][5].Transmuter.getallTiles(); + for (int i=0;i