diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java index dedd451..7500fed 100644 --- a/core/src/fr/evolving/assets/AssetLoader.java +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -119,7 +119,9 @@ public class AssetLoader { for (int i = 0; i < 70; i++) { TextureRegion tileText = Atlas_level.findRegion("sprite"+i); if (tileText != null) { - tileSet.putTile(i, new StaticTiledMapTile(tileText)); + StaticTiledMapTile atile= new StaticTiledMapTile(tileText); + atile.setId(i); + tileSet.putTile(i, atile); Gdx.app.debug("AssetLoader","Tiles N°:"+String.valueOf(i)); } } diff --git a/core/src/fr/evolving/automata/Grid.java b/core/src/fr/evolving/automata/Grid.java index 455cc71..623a098 100644 --- a/core/src/fr/evolving/automata/Grid.java +++ b/core/src/fr/evolving/automata/Grid.java @@ -35,7 +35,7 @@ public class Grid implements Serializable{ GetXY(x,y).Copper_calc=value; } else - GetXY(x,y).Copper_calc=60; + GetXY(x,y).Copper_calc=-1; for (int x=0;x0; + } + public int GetCoppercalc(float X,float Y) { Cell cell=GetXY(X,Y); if (cell==null) diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java index dd681c6..25dbaa4 100644 --- a/core/src/fr/evolving/screens/GameScreen.java +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -66,6 +66,7 @@ public class GameScreen implements Screen { private Objectives objectives; private TouchMaptiles map; private Menu menu; + private Actor menuactor; private float oldx,oldy; private Label fpsLabel; @@ -176,6 +177,7 @@ public class GameScreen implements Screen { @Override public void clicked(InputEvent event, float x, float y) { selected=event.getListenerActor(); + map.fillempty(53); Gdx.app.debug(event.getListenerActor().toString(),"Barre:Selection dans la Barre bas"); } }); @@ -184,7 +186,85 @@ public class GameScreen implements Screen { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); - ((TiledMapTileLayer)menu.map.getLayers().get(0)).getCell(1,6).setTile(AssetLoader.tileSet.getTile(10)); + checkMenu(0,true); + menu.clear(); + map.fillempty(53); + selected=null; + menu.setMenu(0, 7, 10); + menu.setMenu(1, 7, 61); + menu.setMenu(2, 7, 53); + Barre2[0].setChecked(true); + } + }); + Barre2[1].addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); + checkMenu(1,true); + menu.clear(); + map.fillempty(53); + selected=null; + menu.setMenu(0, 7, 10); + } + }); + Barre2[2].addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); + checkMenu(2,true); + menu.clear(); + map.fillempty(53); + selected=null; + } + }); + Barre2[3].addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); + checkMenu(3,true); + menu.clear(); + map.fillempty(53); + selected=null; + } + }); + Barre2[4].addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); + checkMenu(4,true); + menu.clear(); + map.fillempty(53); + selected=null; + } + }); + Barre2[5].addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); + checkMenu(5,true); + menu.clear(); + map.fillempty(53); + selected=null; + } + }); + Barre2[6].addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); + checkMenu(6,true); + menu.clear(); + map.fillempty(53); + selected=null; + } + }); + Barre2[7].addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); + checkMenu(7,true); + menu.clear(); + map.fillempty(53); + selected=null; } }); Gdx.app.debug(getClass().getSimpleName(),"Création de la barre de gestion du haut"); @@ -227,7 +307,7 @@ public class GameScreen implements Screen { map.setDec((AssetLoader.width/2-x)/2,(AssetLoader.height/2-y)/2); return false; } - else if (selected.getName()=="pen") + else if (selected.getName()=="copper") { Vector2 coords=map.screentoworld(x, y); if (level.Grid.GetXY(coords.x,coords.y)!=null) @@ -238,9 +318,33 @@ public class GameScreen implements Screen { else level.Grid.GetXY(coords.x,coords.y).Copper=false; level.Grid.tiling(); - map.redraw(); + map.redraw(60); + } + } + else if (selected.getName()=="fiber") + { + Vector2 coords=map.screentoworld(x, y); + 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.GetFiber(coords.x,coords.y)==false) + level.Grid.GetXY(coords.x,coords.y).Fiber=1; + else + level.Grid.GetXY(coords.x,coords.y).Fiber=0; + map.redraw(60); + } + } + else if (selected.getName()=="blank") + { + Vector2 coords=map.screentoworld(x, y); + 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); + level.Grid.GetXY(coords.x,coords.y).Fiber=0; + level.Grid.GetXY(coords.x,coords.y).Copper=false; + level.Grid.tiling(); + map.redraw(60); } - return false; } return true; } @@ -258,15 +362,63 @@ public class GameScreen implements Screen { oldx=x; oldy=y; } + else if (selected.getName()=="copper") + { + Vector2 coords=map.screentoworld(x, y); + 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); + level.Grid.GetXY(coords.x,coords.y).Copper=true; + level.Grid.tiling(); + map.redraw(60); + } } - }); + else if (selected.getName()=="fiber") + { + Vector2 coords=map.screentoworld(x, y); + 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); + level.Grid.GetXY(coords.x,coords.y).Fiber=1; + map.redraw(60); + } + } + else if (selected.getName()=="blank") + { + Vector2 coords=map.screentoworld(x, y); + 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); + level.Grid.GetXY(coords.x,coords.y).Fiber=0; + level.Grid.GetXY(coords.x,coords.y).Copper=false; + level.Grid.tiling(); + map.redraw(60); + } + } + } + }); menu=new Menu(4,8); map.addListener(new ClickListener(){ @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { Vector2 coords=menu.screentoworld(x,y); - Gdx.app.debug(event.getListenerActor().toString(),"Coordonnées:"+x+"x"+y+" Coordonnées deprojettée:"+coords.x+"x"+coords.y); - + int tile=menu.getMenu((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 (tile!=54 && tile!=0) { + if (menuactor==null) + menuactor=new Actor(); + Vector2 coords2=menu.worldtoscreen((int)coords.x,(int)coords.y); + menuactor.setBounds(coords2.x, coords2.y, 60, 60); + selected=menuactor; + if (tile==10 || tile==61 || tile==53) + map.fillempty(60); + if (tile==10) + selected.setName("copper"); + else if (tile==61) + selected.setName("fiber"); + else if (tile==53) + selected.setName("blank"); + } return false; } }); @@ -314,6 +466,13 @@ public class GameScreen implements Screen { multiplexer.setProcessors(processors); Gdx.input.setInputProcessor(multiplexer); } + + public void checkMenu(int menu,boolean check) + { + for (int i=0;i