diff --git a/core/src/fr/evolving/UI/TouchMaptiles.java b/core/src/fr/evolving/UI/TouchMaptiles.java index 682642d..2aafb27 100644 --- a/core/src/fr/evolving/UI/TouchMaptiles.java +++ b/core/src/fr/evolving/UI/TouchMaptiles.java @@ -1,6 +1,7 @@ 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,6 +15,7 @@ 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{ @@ -32,7 +34,7 @@ public TouchMaptiles(Level level,int sizex,int sizey) { map=new TiledMap(); map.getTileSets().addTileSet(AssetLoader.tileSet); MapLayers layers = map.getLayers(); - for (int i = 0; i < 3; i++) { + 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++) { @@ -44,6 +46,7 @@ public TouchMaptiles(Level level,int sizex,int sizey) { } layers.add(layer); } + layers.get(3).setOpacity(0.9f); MapRenderer = new OrthogonalTiledMapRenderer(map,1/128.0f); camera = new OrthographicCamera(); initzoom(); @@ -61,6 +64,26 @@ public Vector2 screentoworldsize(float x, float y) { 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); + ((TiledMapTileLayer)map.getLayers().get(3)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(surtile)); + } +} + +public void tempclear() +{ + for (int x=0;x allregions=Atlas_level.getRegions(); + for (int i=0;i frameTiles=new Array(maxid); + for(int j=1;j<=maxid;j++) + frameTiles.add(new StaticTiledMapTile((Atlas_level.findRegion("sprite_"+id+"#"+j)))); + AnimatedTiledMapTile atile=new AnimatedTiledMapTile(0.15f,frameTiles); + Gdx.app.debug("AssetLoader","Taille:"+String.valueOf(frameTiles.size)); + atile.setId(1000+id); + tileSet.putTile(1000+id, atile); + } + } + } + else + { + StaticTiledMapTile atile= new StaticTiledMapTile(allregions.get(i)); + atile.setId(allregions.get(i).index); + tileSet.putTile(allregions.get(i).index, atile); + Gdx.app.debug("AssetLoader","Tiles N°:"+String.valueOf(allregions.get(i).index)); + } + } } 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 tiles=selected_transmuter.getTiles(); + Iterator keySetIterator = selected_transmuter.getTiles().keySet().iterator(); + int MainTile=selected_transmuter.getMainTile(); + int color=64; + if (level.Grid.getCopper(coords.x,coords.y) && level.Grid.getTransmutercalc(coords.x,coords.y)==0) + color=63; + map.tempdraw(coords.x, coords.y, MainTile, selected_transmuter.getRotation().ordinal(),color); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + color=64; + if (((!level.Grid.GetFiber(coords.x+key.x, coords.y+key.y) && !level.Grid.getCopper(coords.x+key.x, coords.y+key.y) && tiles.get(key)==CaseType.Rien) || (level.Grid.GetFiber(coords.x+key.x, coords.y+key.y) && level.Grid.getCopper(coords.x+key.x, coords.y+key.y) && tiles.get(key)==CaseType.Tout) || (level.Grid.GetFiber(coords.x+key.x, coords.y+key.y) && !level.Grid.getCopper(coords.x+key.x, coords.y+key.y) && tiles.get(key)==CaseType.Fibre) || (level.Grid.getCopper(coords.x+key.x, coords.y+key.y) && !level.Grid.GetFiber(coords.x+key.x, coords.y+key.y) && tiles.get(key)==CaseType.Cuivre)) && (level.Grid.getTransmutercalc(coords.x+key.x, coords.y+key.y)==0)) + color=63; + map.tempdraw(coords.x+key.x, coords.y+key.y, ++MainTile, selected_transmuter.getRotation().ordinal(),color); + } + } + } + return true; + } @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { oldx=0; @@ -466,15 +498,69 @@ public class GameScreen implements Screen { } else if (selected.getName()=="transmuter") { + if (button==1) + { + 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); + Angular angle=selected_transmuter.getRotation(); + if (angle==Angular.A00) + selected_transmuter.setRotation(Angular.A90); + else if (angle==Angular.A90) + selected_transmuter.setRotation(Angular.A180); + else if (angle==Angular.A180) + selected_transmuter.setRotation(Angular.A270); + else if (angle==Angular.A270) + selected_transmuter.setRotation(Angular.A00); + map.tempclear(); + HashMap tiles=selected_transmuter.getTiles(); + Iterator keySetIterator = selected_transmuter.getTiles().keySet().iterator(); + int MainTile=selected_transmuter.getMainTile(); + int color=64; + if (level.Grid.getCopper(coords.x,coords.y) && level.Grid.getTransmutercalc(coords.x,coords.y)==0) + color=63; + map.tempdraw(coords.x, coords.y, MainTile, selected_transmuter.getRotation().ordinal(),color); + while(keySetIterator.hasNext()){ + Vector2 key = keySetIterator.next(); + color=64; + if (((!level.Grid.GetFiber(coords.x+key.x, coords.y+key.y) && !level.Grid.getCopper(coords.x+key.x, coords.y+key.y) && tiles.get(key)==CaseType.Rien) || (level.Grid.GetFiber(coords.x+key.x, coords.y+key.y) && level.Grid.getCopper(coords.x+key.x, coords.y+key.y) && tiles.get(key)==CaseType.Tout) || (level.Grid.GetFiber(coords.x+key.x, coords.y+key.y) && !level.Grid.getCopper(coords.x+key.x, coords.y+key.y) && tiles.get(key)==CaseType.Fibre) || (level.Grid.getCopper(coords.x+key.x, coords.y+key.y) && !level.Grid.GetFiber(coords.x+key.x, coords.y+key.y) && tiles.get(key)==CaseType.Cuivre)) && (level.Grid.getTransmutercalc(coords.x+key.x, coords.y+key.y)==0)) + color=63; + map.tempdraw(coords.x+key.x, coords.y+key.y, ++MainTile, selected_transmuter.getRotation().ordinal(),color); + } + } + return true; + } 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).Transmuter=selected_transmuter; + level.Grid.GetXY(coords.x,coords.y).Transmuter=(Transmuter) selected_transmuter.clone(); level.Grid.tiling_transmuter(); map.redraw(60); } } + else if (selected.getName()=="copper-brush") + { + 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_copper(); + map.redraw(60); + } + } + else if (selected.getName()=="fiber-brush") + { + 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); + } + } return true; } }); @@ -631,7 +717,7 @@ public class GameScreen implements Screen { coords2=menu.worldtoscreen((int)(coords.x+gotomain.x),(int)(coords.y+gotomain.y)); menuactor.setPosition(coords2.x, coords2.y); selected.setName("transmuter"); - selected_transmuter=transmuter; + selected_transmuter=(Transmuter) transmuter.clone(); Gdx.app.debug(event.getListenerActor().toString(),"transmuter deplacement vers origine:"+String.valueOf(gotomain.x)+","+String.valueOf(gotomain.y)+" coords:"+coords2.x+"x"+coords2.y); } } diff --git a/core/src/fr/evolving/worlds/GameRenderer.java b/core/src/fr/evolving/worlds/GameRenderer.java index e8c929d..1e2cc07 100644 --- a/core/src/fr/evolving/worlds/GameRenderer.java +++ b/core/src/fr/evolving/worlds/GameRenderer.java @@ -47,8 +47,8 @@ public class GameRenderer { 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("barrebas"),0.0f,0.0f,1920.0f,170.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.end();