From 23908a8e4d2f0ac2d74bb1a21f859c461b1ea835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Hord=C3=A9?= Date: Sat, 8 Aug 2015 15:09:17 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20am=C3=A9lioration=20de=20la=20gestion=20?= =?UTF-8?q?du=20menu=20avec=20possibilit=C3=A9=20d'ajouter=20des=20transmu?= =?UTF-8?q?ter=20avec=20rotation.=20ajout=20de=20l'information=20sur=20une?= =?UTF-8?q?=20case=20=C3=A0=20partir=20du=20mode=20d=C3=A9bogueage.=20rece?= =?UTF-8?q?ntrage=20de=20la=20graille=20au=20double=20clique=20sur=20le=20?= =?UTF-8?q?bouton=20"move"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/fr/evolving/UI/Menu.java | 31 +++++++++- core/src/fr/evolving/assets/AssetLoader.java | 8 +++ .../src/fr/evolving/automata/Positiver_I.java | 2 +- .../fr/evolving/automata/Positiver_II.java | 2 +- .../fr/evolving/automata/Positiver_III.java | 2 +- core/src/fr/evolving/automata/Transmuter.java | 4 ++ core/src/fr/evolving/screens/GameScreen.java | 57 +++++++++++++------ 7 files changed, 84 insertions(+), 22 deletions(-) diff --git a/core/src/fr/evolving/UI/Menu.java b/core/src/fr/evolving/UI/Menu.java index dccfb61..7e7fda9 100644 --- a/core/src/fr/evolving/UI/Menu.java +++ b/core/src/fr/evolving/UI/Menu.java @@ -1,5 +1,7 @@ package fr.evolving.UI; +import java.util.Iterator; + import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.Batch; @@ -13,6 +15,8 @@ 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 Menu extends Actor{ @@ -62,15 +66,38 @@ public void clear() layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(54)); } -public void setMenu(int x,int y,int tile) +public void setMenuTile(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)); + Gdx.app.debug(getClass().getSimpleName(),"Tile find:"+tile+" coords"+x+","+y); } } -public int getMenu(int x,int y) +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.getTiles().keySet().iterator(); + int MainTile=transmuter.getMainTile(); + cell.setTile(AssetLoader.tileSet.getTile(MainTile++)); + cell.setRotation(Angle.ordinal()); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + ((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)(x+key.x),(int)(y+key.y)).setTile(AssetLoader.tileSet.getTile(MainTile++)); + ((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)(x+key.x),(int)(y+key.y)).setRotation(Angle.ordinal()); + } + + } + } +} + +public int getMenuTile(int x,int y) { Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y); if (cell!=null) diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index af7d2fe..59728f5 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -159,6 +159,14 @@ public class AssetLoader { return null; } + public static Transmuter getTransmuter(String Name) { + for(Transmuter transmuter:allTransmuter) { + if (transmuter.isTransmuter(Name)) + return transmuter; + } + return null; + } + public static Vector2 resolveTransmuterMain(int Id) { Transmuter transmuter=getTransmuter(Id); if (transmuter!=null) diff --git a/core/src/fr/evolving/automata/Positiver_I.java b/core/src/fr/evolving/automata/Positiver_I.java index 6dc4f97..823a074 100644 --- a/core/src/fr/evolving/automata/Positiver_I.java +++ b/core/src/fr/evolving/automata/Positiver_I.java @@ -40,7 +40,7 @@ public class Positiver_I extends Transmuter { public Positiver_I(Level level) { super(level); - this.Name="positiveur I"; + this.Name="Positiveur I"; this.theClass=Class.Charge; this.Price=50; this.Technology=2; diff --git a/core/src/fr/evolving/automata/Positiver_II.java b/core/src/fr/evolving/automata/Positiver_II.java index 646413c..6ed47ed 100644 --- a/core/src/fr/evolving/automata/Positiver_II.java +++ b/core/src/fr/evolving/automata/Positiver_II.java @@ -38,7 +38,7 @@ public class Positiver_II extends Transmuter { public Positiver_II(Level level) { super(level); - this.Name="positiveur II"; + this.Name="Positiveur II"; this.theClass=Class.Charge; this.Price=50; this.Technology=2; diff --git a/core/src/fr/evolving/automata/Positiver_III.java b/core/src/fr/evolving/automata/Positiver_III.java index cddf072..d3e3bba 100644 --- a/core/src/fr/evolving/automata/Positiver_III.java +++ b/core/src/fr/evolving/automata/Positiver_III.java @@ -38,7 +38,7 @@ public class Positiver_III extends Transmuter { public Positiver_III(Level level) { super(level); - this.Name="positiveur III"; + this.Name="Positiveur III"; this.theClass=Class.Charge; this.Price=50; this.Technology=2; diff --git a/core/src/fr/evolving/automata/Transmuter.java b/core/src/fr/evolving/automata/Transmuter.java index 0e04945..e528af4 100644 --- a/core/src/fr/evolving/automata/Transmuter.java +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -65,6 +65,10 @@ public abstract class Transmuter { return (FindMainTile(Id)==getMainTile()); } + public boolean isTransmuter(String Name) { + return Name.equals(this.getName()); + } + public Vector2 getPostitionMainTile(int Id) { if (!isTransmuter(Id)) return null; diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index 434791c..5d62d78 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -245,6 +245,9 @@ public class GameScreen implements Screen { selected=event.getListenerActor(); map.fillempty(53); Gdx.app.debug(event.getListenerActor().toString(),"Barre:Selection dans la Barre bas"); + if (this.getTapCount()>=2 && selected.getName()=="move") { + map.initzoom(); + } } }); } @@ -256,16 +259,16 @@ public class GameScreen implements Screen { menu.clear(); map.fillempty(53); selected=null; - menu.setMenu(0, 7, 71); - menu.setMenu(1, 7, 72); - menu.setMenu(2, 7, 73); - menu.setMenu(1, 5, 70); - menu.setMenu(0, 6, 74); - menu.setMenu(1, 6, 75); - menu.setMenu(2, 6, 76); - menu.setMenu(0, 5, 77); - menu.setMenu(2, 5, 78); - menu.setMenu(3, 3, 79); + menu.setMenuTile(0, 7, 71); + menu.setMenuTile(1, 7, 72); + menu.setMenuTile(2, 7, 73); + menu.setMenuTile(1, 5, 70); + menu.setMenuTile(0, 6, 74); + menu.setMenuTile(1, 6, 75); + menu.setMenuTile(2, 6, 76); + menu.setMenuTile(0, 5, 77); + menu.setMenuTile(2, 5, 78); + menu.setMenuTile(3, 3, 79); Barre2[0].setChecked(true); } }); @@ -277,12 +280,9 @@ public class GameScreen implements Screen { menu.clear(); map.fillempty(53); selected=null; - menu.setMenu(0, 7, 200); - menu.setMenu(1, 7, 201); - menu.setMenu(0, 6, 202); - menu.setMenu(1, 6, 203); - menu.setMenu(0, 5, 204); - menu.setMenu(1, 5, 205); + menu.setMenuTransmuter(0,7,"Positiveur I",Angular.A00); + menu.setMenuTransmuter(0,6,"Positiveur II",Angular.A00); + menu.setMenuTransmuter(0,5,"Positiveur III",Angular.A00); } }); Barre2[2].addListener(new ClickListener(){ @@ -371,6 +371,8 @@ public class GameScreen implements Screen { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { oldx=0; oldy=0; + if (selected!=null) + Gdx.app.debug(event.getListenerActor().toString(),"Cliquage sur la map, mode:"+selected.getName()); if (selected==null) ; else if (selected.getName()=="cleaner") @@ -386,6 +388,25 @@ public class GameScreen implements Screen { map.redraw(60); return false; } + else if (selected.getName()=="infos") + { + Vector2 coords=map.screentoworld(x, y); + if (level.Grid.GetXY(coords.x,coords.y)!=null) + { + if (level.Grid.GetXY(coords.x,coords.y).Copper) + Gdx.app.debug(getClass().getSimpleName(),"*** Présence de cuivre"); + if (level.Grid.GetXY(coords.x,coords.y).Fiber>0) + Gdx.app.debug(getClass().getSimpleName(),"*** Présence de fibre"); + if (level.Grid.GetXY(coords.x,coords.y).Transmuter_calc>0) { + Vector2 gotomain=AssetLoader.resolveTransmuterMain(level.Grid.GetXY(coords.x,coords.y).Transmuter_calc); + if (gotomain!=null) { + Gdx.app.debug(event.getListenerActor().toString(),"transmuter deplacement vers origine:"+String.valueOf(gotomain.x)+","+String.valueOf(gotomain.y)+" coords:"+(coords.x+gotomain.x)+"x"+(coords.y+gotomain.y)); + Gdx.app.debug(event.getListenerActor().toString(),level.Grid.getTransmuter(coords.x+gotomain.x,coords.y+gotomain.y).getInformations()); + } + } + } + return false; + } else if (selected.getName()=="zoomp") { map.setZoom(0.9f); @@ -454,6 +475,8 @@ public class GameScreen implements Screen { map.addListener(new ClickListener(){ @Override public void touchDragged(InputEvent event, float x, float y, int pointer) { + if (selected!=null) + Gdx.app.debug(event.getListenerActor().toString(),"Drag sur la map, mode:"+selected.getName()); if (selected==null) ; else if (selected.getName()=="move") { @@ -564,7 +587,7 @@ public class GameScreen implements Screen { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { Vector2 coords=menu.screentoworld(x,y); - int tile=menu.getMenu((int)coords.x,(int)coords.y); + int tile=menu.getMenuTile((int)coords.x,(int)coords.y); Gdx.app.debug(event.getListenerActor().toString(),"Coordonnées:"+x+"x"+y+" Coordonnées deprojettée:"+coords.x+"x"+coords.y+" tile:"+tile); if (menuactor==null) menuactor=new Actor();