fix: nommage des sprites différents avec prise en compte de leur usage futur, réécriture de la gestion du menu, correction de bogues majeurs (rotation des sprites)

This commit is contained in:
Nicolas Hordé 2015-12-30 12:10:02 +01:00
parent 1bb7cfd110
commit 0632f80002
6 changed files with 160 additions and 144 deletions

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.maps.MapLayers; import com.badlogic.gdx.maps.MapLayers;
import com.badlogic.gdx.maps.MapProperties;
import com.badlogic.gdx.maps.tiled.TiledMap; import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell;
@ -66,15 +67,24 @@ public void clear()
layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(54)); layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(54));
} }
public void setMenuTile(int x,int y,int tile) public void setMenuTile(int x,int y,int tile,String title)
{ {
Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y); Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y);
if (cell!=null) { if (cell!=null) {
cell.setTile(AssetLoader.tileSet.getTile(tile)); cell.setTile(AssetLoader.tileSet.getTile(tile));
cell.getTile().getProperties().put("name", title);
Gdx.app.debug(getClass().getSimpleName(),"Tile find:"+tile+" coords"+x+","+y); Gdx.app.debug(getClass().getSimpleName(),"Tile find:"+tile+" coords"+x+","+y);
} }
} }
public int getSizeX() {
return tilesizex;
}
public int getSizeY() {
return tilesizey;
}
public void setMenuTransmuter(int x,int y,String Name,Transmuter.Angular Angle) public void setMenuTransmuter(int x,int y,String Name,Transmuter.Angular Angle)
{ {
Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y); Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y);
@ -89,23 +99,28 @@ public void setMenuTransmuter(int x,int y,String Name,Transmuter.Angular Angle)
cell.setRotation(Angle.ordinal()); cell.setRotation(Angle.ordinal());
while(keySetIterator.hasNext()){ while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)(x+key.x),(int)(y+key.y)).setTile(AssetLoader.tileSet.getTile(MainTile++)); Cell subcell=((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)(x+key.x),(int)(y+key.y));
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)(x+key.x),(int)(y+key.y)).setRotation(Angle.ordinal()); subcell.setTile(AssetLoader.tileSet.getTile(MainTile++));
subcell.setRotation(Angle.ordinal());
subcell.getTile().getProperties().put("movetox",(int) -key.x);
subcell.getTile().getProperties().put("movetoy",(int) -key.y);
} }
} }
} }
} }
public int getMenuTile(int x,int y) public MapProperties getMenubyTile(int x,int y)
{ {
Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y); Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y);
if (cell!=null) if (cell!=null)
return cell.getTile().getId(); return cell.getTile().getProperties();
else else
return 0; return null;
} }
public Vector2 screentoworld(float x, float y) { public Vector2 screentoworld(float x, float y) {
int xx=(int) ((x-1531f)/60f); int xx=(int) ((x-1531f)/60f);
int yy=(int) ((y-(AssetLoader.height-776f))/60f); int yy=(int) ((y-(AssetLoader.height-776f))/60f);

View File

@ -95,13 +95,15 @@ public void redraw(int tile) {
for (int y=0;y<level.Grid.sizeY;y++) { for (int y=0;y<level.Grid.sizeY;y++) {
if (level.Grid.getCopper(x,y)) if (level.Grid.getCopper(x,y))
((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(level.Grid.getCoppercalc(x,y))); ((TiledMapTileLayer)map.getLayers().get(1)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(level.Grid.getCoppercalc(x,y)));
if (level.Grid.GetFiber(x,y)) if (level.Grid.getFiber(x,y))
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(61)); ((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)x, (int)y).setTile(AssetLoader.tileSet.getTile(61));
if (level.Grid.getTransmutercalc(x, y)!=0) if (level.Grid.getTransmutercalc(x, y)!=0)
{ {
((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).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)); ((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).setRotation(level.Grid.getTransmuterrot(x, y));
} ((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).getTile().getProperties().put("movex",level.Grid.GetXY(x, y).Transmuter_movex);
((TiledMapTileLayer)map.getLayers().get(2)).getCell((int)x, (int)y).getTile().getProperties().put("movey",level.Grid.GetXY(x, y).Transmuter_movex);
};
} }
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)0, (int)0).setTile(AssetLoader.tileSet.getTile(1010)); ((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)0, (int)0).setTile(AssetLoader.tileSet.getTile(1010));
((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)1, (int)0).setTile(AssetLoader.tileSet.getTile(1010)); ((TiledMapTileLayer)map.getLayers().get(0)).getCell((int)1, (int)0).setTile(AssetLoader.tileSet.getTile(1010));

View File

@ -130,30 +130,35 @@ public class AssetLoader {
if (allregions.get(i).name.contains("#")) if (allregions.get(i).name.contains("#"))
{ {
String[] name=allregions.get(i).name.split("_"); String[] name=allregions.get(i).name.split("_");
String[] type=name[0].split("-");
if (name[0].contains("sprite")) if (name[0].contains("sprite"))
{ {
int id=Integer.parseInt(name[1].split("#")[0]); int id=Integer.parseInt(name[1].split("#")[0]);
if (tileSet.getTile(1000+id)==null) { if (tileSet.getTile(1000+id)==null) {
Gdx.app.debug("AssetLoader","Animated Tiles N°:"+String.valueOf(id+1000)); Gdx.app.debug("AssetLoader","Animated Tiles N°:"+String.valueOf(id+1000));
int maxid=0; int maxid=0;
for(int j=1;Atlas_level.findRegion("sprite_"+id+"#"+j)!=null;j++) for(int j=1;Atlas_level.findRegion("sprite-"+type[1]+"_"+id+"#"+j)!=null;j++)
maxid=j; maxid=j;
Array<StaticTiledMapTile> frameTiles=new Array<StaticTiledMapTile>(maxid); Array<StaticTiledMapTile> frameTiles=new Array<StaticTiledMapTile>(maxid);
for(int j=1;j<=maxid;j++) for(int j=1;j<=maxid;j++)
frameTiles.add(new StaticTiledMapTile((Atlas_level.findRegion("sprite_"+id+"#"+j)))); frameTiles.add(new StaticTiledMapTile((Atlas_level.findRegion("sprite-"+type[1]+"_"+id+"#"+j))));
AnimatedTiledMapTile atile=new AnimatedTiledMapTile(0.15f,frameTiles); AnimatedTiledMapTile atile=new AnimatedTiledMapTile(0.15f,frameTiles);
Gdx.app.debug("AssetLoader","Taille:"+String.valueOf(frameTiles.size)); Gdx.app.debug("AssetLoader","Taille:"+String.valueOf(frameTiles.size));
atile.setId(1000+id); atile.setId(1000+id);
atile.getProperties().put("type", type[1]);
tileSet.putTile(1000+id, atile); tileSet.putTile(1000+id, atile);
} }
} }
} }
else else
{ {
String[] type=allregions.get(i).name.split("-");
StaticTiledMapTile atile= new StaticTiledMapTile(allregions.get(i)); StaticTiledMapTile atile= new StaticTiledMapTile(allregions.get(i));
atile.setId(allregions.get(i).index); atile.setId(allregions.get(i).index);
atile.getProperties().put("type", type[1]);
tileSet.putTile(allregions.get(i).index, atile); tileSet.putTile(allregions.get(i).index, atile);
Gdx.app.debug("AssetLoader","Tiles N°:"+String.valueOf(allregions.get(i).index)); Gdx.app.debug("AssetLoader","Type:"+type[1]+" Tiles N°:"+String.valueOf(allregions.get(i).index));
} }
} }
} }
@ -161,7 +166,16 @@ public class AssetLoader {
allTransmuter[0]=new Positiver_I(null); allTransmuter[0]=new Positiver_I(null);
allTransmuter[1]=new Positiver_II(null); allTransmuter[1]=new Positiver_II(null);
allTransmuter[2]=new Positiver_III(null); allTransmuter[2]=new Positiver_III(null);
} for(int i=0;i<allTransmuter.length;i++) {
int[] result;
result=allTransmuter[i].getallTiles();
for (int j=0;j<result.length;j++) {
AssetLoader.tileSet.getTile(result[j]).getProperties().put("transmuter", allTransmuter[i]);
AssetLoader.tileSet.getTile(result[j]).getProperties().put("name", allTransmuter[i].getName());
Gdx.app.debug("AssetLoader","Ajustement données Tiles N°:"+String.valueOf(result[j])+" Nom:"+allTransmuter[i].getName());
}
}
}
public static Transmuter getTransmuter(int Id) { public static Transmuter getTransmuter(int Id) {
for(Transmuter transmuter:allTransmuter) { for(Transmuter transmuter:allTransmuter) {

View File

@ -10,6 +10,8 @@ public class Cell implements Serializable{
public transient int Fiber_old; public transient int Fiber_old;
public Transmuter Transmuter; public Transmuter Transmuter;
public transient int Transmuter_calc; public transient int Transmuter_calc;
public transient int Transmuter_movex;
public transient int Transmuter_movey;
public Cell() { public Cell() {
this.Fiber=0; this.Fiber=0;
@ -17,6 +19,8 @@ public class Cell implements Serializable{
this.Fiber_old=0; this.Fiber_old=0;
this.Transmuter=null; this.Transmuter=null;
this.Transmuter_calc=0; this.Transmuter_calc=0;
this.Transmuter_movex=0;
this.Transmuter_movey=0;
} }
} }

View File

@ -39,6 +39,8 @@ public class Grid implements Serializable{
while(keySetIterator.hasNext()){ while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
GetXY(x+key.x,y+key.y).Transmuter_calc=(1<<16)*transmuter.getRotation().ordinal()+MainTile++; GetXY(x+key.x,y+key.y).Transmuter_calc=(1<<16)*transmuter.getRotation().ordinal()+MainTile++;
GetXY(x+key.x,y+key.y).Transmuter_movex=(int)-key.x;
GetXY(x+key.x,y+key.y).Transmuter_movey=(int)-key.y;
} }
} }
} }
@ -218,7 +220,7 @@ public class Grid implements Serializable{
return cell.Copper; return cell.Copper;
} }
public boolean GetFiber(float X,float Y) { public boolean getFiber(float X,float Y) {
Cell cell=GetXY(X,Y); Cell cell=GetXY(X,Y);
if (cell==null) if (cell==null)
return false; return false;

View File

@ -15,11 +15,14 @@ import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Screen; import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.input.GestureDetector;
import com.badlogic.gdx.maps.MapLayers; import com.badlogic.gdx.maps.MapLayers;
import com.badlogic.gdx.maps.MapProperties;
import com.badlogic.gdx.maps.tiled.TiledMap; import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
@ -34,6 +37,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextArea; import com.badlogic.gdx.scenes.scene2d.ui.TextArea;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.badlogic.gdx.scenes.scene2d.utils.Align; import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
@ -83,7 +87,8 @@ public class GameScreen implements Screen {
private Label fpsLabel,info_nom; private Label fpsLabel,info_nom;
private TextArea info_desc,info_up_nrj_val,info_up_temp_val,info_up_rayon_val,info_up_cycle_val; private TextArea info_desc,info_up_nrj_val,info_up_temp_val,info_up_rayon_val,info_up_cycle_val;
public boolean unroll,mapexit; public boolean unroll,mapexit;
public enum calling{mouseover,mouseclick,mousedrag,mousex2click,mousescroll}; public enum calling{mouseover,mouseclick,mousedrag,longpress,tap,taptap,zoom,fling,pan,pinch};
GestureDetector gesturedetector;
// This is the constructor, not the class declaration // This is the constructor, not the class declaration
public GameScreen(Level alevel) { public GameScreen(Level alevel) {
@ -212,103 +217,63 @@ public class GameScreen implements Screen {
Barre2[0].addListener(new ClickListener(){ Barre2[0].addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); preparemenu(0);
checkMenu(0,true); menu.setMenuTile(0, 7, 71, "copper_pen");
menu.clear(); menu.setMenuTile(1, 7, 72, "copper_brush");
map.fillempty(53); menu.setMenuTile(2, 7, 73, "copper_eraser");
selected=null; menu.setMenuTile(1, 5, 70, "blank");
menu.setMenuTile(0, 7, 71); menu.setMenuTile(0, 6, 74, "fiber_pen");
menu.setMenuTile(1, 7, 72); menu.setMenuTile(1, 6, 75, "fiber_brush");
menu.setMenuTile(2, 7, 73); menu.setMenuTile(2, 6, 76, "fiber_eraser");
menu.setMenuTile(1, 5, 70); menu.setMenuTile(0, 5, 77, "transmuter_eraser");
menu.setMenuTile(0, 6, 74); menu.setMenuTile(2, 5, 78, "all_eraser");
menu.setMenuTile(1, 6, 75); menu.setMenuTile(3, 3, 79, "cleaner");
menu.setMenuTile(2, 6, 76);
menu.setMenuTile(0, 5, 77);
menu.setMenuTile(2, 5, 78);
menu.setMenuTile(3, 3, 79);
Barre2[0].setChecked(true); Barre2[0].setChecked(true);
hideInfo();
} }
}); });
Barre2[1].addListener(new ClickListener(){ Barre2[1].addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); preparemenu(1);
checkMenu(1,true);
menu.clear();
map.fillempty(53);
selected=null;
menu.setMenuTransmuter(0,7,"Positiveur I",Angular.A00); menu.setMenuTransmuter(0,7,"Positiveur I",Angular.A00);
menu.setMenuTransmuter(0,6,"Positiveur II",Angular.A00); menu.setMenuTransmuter(0,6,"Positiveur II",Angular.A00);
menu.setMenuTransmuter(0,5,"Positiveur III",Angular.A00); menu.setMenuTransmuter(0,5,"Positiveur III",Angular.A00);
hideInfo();
} }
}); });
Barre2[2].addListener(new ClickListener(){ Barre2[2].addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); preparemenu(2);
checkMenu(2,true);
menu.clear();
map.fillempty(53);
selected=null;
hideInfo();
} }
}); });
Barre2[3].addListener(new ClickListener(){ Barre2[3].addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); preparemenu(3);
checkMenu(3,true);
menu.clear();
map.fillempty(53);
selected=null;
hideInfo();
} }
}); });
Barre2[4].addListener(new ClickListener(){ Barre2[4].addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); preparemenu(4);
checkMenu(4,true);
menu.clear();
map.fillempty(53);
selected=null;
hideInfo();
} }
}); });
Barre2[5].addListener(new ClickListener(){ Barre2[5].addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); preparemenu(5);
checkMenu(5,true);
menu.clear();
map.fillempty(53);
selected=null;
hideInfo();
} }
}); });
Barre2[6].addListener(new ClickListener(){ Barre2[6].addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); preparemenu(6);
checkMenu(6,true);
menu.clear();
map.fillempty(53);
selected=null;
hideInfo();
} }
}); });
Barre2[7].addListener(new ClickListener(){ Barre2[7].addListener(new ClickListener(){
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Gdx.app.debug(event.getListenerActor().toString(),"Affichage sousmenu"); preparemenu(7);
checkMenu(7,true);
menu.clear();
map.fillempty(53);
selected=null;
hideInfo();
} }
}); });
Gdx.app.debug(getClass().getSimpleName(),"Création de la barre de gestion du haut"); Gdx.app.debug(getClass().getSimpleName(),"Création de la barre de gestion du haut");
@ -373,27 +338,52 @@ public class GameScreen implements Screen {
Gdx.app.debug(getClass().getSimpleName(),"Création d'une tilemap"); Gdx.app.debug(getClass().getSimpleName(),"Création d'une tilemap");
map=new TouchMaptiles(level,128,128); map=new TouchMaptiles(level,128,128);
map.setBounds(0, 0, AssetLoader.width, AssetLoader.height); map.setBounds(0, 0, AssetLoader.width, AssetLoader.height);
map.addListener(new ClickListener(){ map.addListener(new ActorGestureListener(){
@Override
public void zoom(InputEvent event, float initialDistance, float distance) {
String[] exec={"zoomp","zoomm"};
int zooming=(int)(distance/initialDistance*1000f);
event_coordination(0,0,zooming,calling.zoom,exec);
}
@Override
public void pinch(InputEvent event, Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2)
{
float deltaX = pointer2.x - pointer1.x;
float deltaY = pointer2.y - pointer1.y;
int angle = (int)((float)Math.atan2((double)deltaY,(double)deltaX) * MathUtils.radiansToDegrees);
angle += 90;
if(angle < 0)
angle = 360 - (-angle);
String[] exec={"transmuter"};
event_coordination(initialPointer1.x,initialPointer1.y,angle,calling.pinch,exec);
}
@Override
public boolean longPress(Actor actor, float x, float y) {
String[] exec={"transmuter"};
return event_coordination(x,y,0,calling.longpress,exec);
}
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
String[] exec={"transmuter"};
if (count==1)
event_coordination(x,y,button,calling.tap,exec);
else if (count>=2)
event_coordination(x,y,button,calling.taptap,exec);
}
});
map.addListener(new InputListener(){
@Override @Override
public boolean mouseMoved(InputEvent event,float x,float y) { public boolean mouseMoved(InputEvent event,float x,float y) {
String[] exec={"transmuter"}; String[] exec={"transmuter"};
return event_coordination(x,y,0,calling.mouseover,exec); return event_coordination(x,y,0,calling.mouseover,exec);
} }
@Override
public boolean scrolled(InputEvent event,float x,float y,int amount) {
String[] exec={"transmuter"};
Gdx.app.debug(event.getListenerActor().toString(),"Coordonnées:");
return event_coordination(x,y,amount,calling.mousescroll,exec);
}
@Override @Override
public void clicked(InputEvent event, float x, float y) { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
oldx=0; oldx=0;
oldy=0; oldy=0;
String[] exec={"cleaner","infos","zoomp","zoomm","copper_pen","fiber_pen","copper_eraser","fiber_eraser","transmuter_eraser","all_eraser","blank","transmuter","copper_brush","fiber_brush"}; String[] exec={"cleaner","infos","zoomp","zoomm","copper_pen","fiber_pen","copper_eraser","fiber_eraser","transmuter_eraser","all_eraser","blank","transmuter","copper_brush","fiber_brush"};
if (this.getTapCount()>=2) return event_coordination(x,y,button,calling.mouseclick,exec);
event_coordination(x,y,0,calling.mousex2click,exec);
else
event_coordination(x,y,0,calling.mouseclick,exec);
} }
@Override @Override
public void touchDragged(InputEvent event, float x, float y, int pointer) { public void touchDragged(InputEvent event, float x, float y, int pointer) {
@ -404,58 +394,39 @@ public class GameScreen implements Screen {
menu=new Menu(4,8); menu=new Menu(4,8);
map.addListener(new ClickListener(){ map.addListener(new ClickListener(){
@Override @Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { public void clicked(InputEvent event, float x, float y) {
mapexit=true; mapexit=true;
Vector2 coords=menu.screentoworld(x,y); Vector2 coords=menu.screentoworld(x,y);
int tile=menu.getMenuTile((int)coords.x,(int)coords.y); MapProperties tile=menu.getMenubyTile((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!=null && tile.containsKey("name"))
if (menuactor==null) {
menuactor=new Actor(); Gdx.app.debug("menu","Coordonnées:"+x+"x"+y+" Coordonnées deprojettée:"+coords.x+"x"+coords.y+" type:"+tile.get("type")+" name:"+tile.get("name").toString());
if (tile!=54 && tile!=0) { if (menuactor==null)
menuactor=new Actor();
Vector2 coords2=menu.worldtoscreen((int)coords.x,(int)coords.y); Vector2 coords2=menu.worldtoscreen((int)coords.x,(int)coords.y);
menuactor.setBounds(coords2.x, coords2.y, 60, 60); menuactor.setBounds(coords2.x, coords2.y, 60, 60);
selected=menuactor; selected=menuactor;
map.fillempty(60); map.fillempty(60);
if (tile==71) if (tile.get("type").toString().startsWith("transmuter"))
selected.setName("copper_pen"); {
if (tile==72) selected.setName("transmuter");
selected.setName("copper_brush"); selected_transmuter=(Transmuter) ((Transmuter) tile.get("transmuter")).clone();
if (tile==73) if (selected_transmuter!=null) {
selected.setName("copper_eraser"); showInfo(selected_transmuter);
if (tile==74) if (tile.containsKey("movetox")) {
selected.setName("fiber_pen"); coords2=menu.worldtoscreen((int)coords.x+(Integer) tile.get("movetox"),(int)(coords.y+(Integer) tile.get("movetoy")));
if (tile==75) menuactor.setPosition(coords2.x, coords2.y);
selected.setName("fiber_brush"); Gdx.app.debug("menu","transmuter deplacement vers origine:"+tile.get("movetox").toString()+","+tile.get("movetoy").toString()+" coords:"+coords2.x+"x"+coords2.y);
if (tile==76) }
selected.setName("fiber_eraser");
if (tile==77)
selected.setName("transmuter_eraser");
if (tile==78)
selected.setName("all_eraser");
if (tile==79)
selected.setName("cleaner");
else if (tile==70)
selected.setName("blank");
else if (tile>99) {
Transmuter transmuter=AssetLoader.getTransmuter(tile);
if (transmuter!=null) {
showInfo(transmuter);
Vector2 gotomain=transmuter.getPostitionMainTile(tile);
if (gotomain!=null) {
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) 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);
} }
} }
else
selected.setName(tile.get("name").toString());
} }
}
return false;
} }
}); });
} }
boolean event_coordination(float x,float y,int button, calling call, String[] exec) { boolean event_coordination(float x,float y,int button, calling call, String[] exec) {
if (selected!=null) { if (selected!=null) {
if (Arrays.asList(exec).contains(selected.getName())) { if (Arrays.asList(exec).contains(selected.getName())) {
@ -463,7 +434,8 @@ public class GameScreen implements Screen {
if (level.Grid.GetXY(coords.x,coords.y)!=null) if (level.Grid.GetXY(coords.x,coords.y)!=null)
{ {
mapexit=false; mapexit=false;
Gdx.app.debug("evenement","mode:"+call+" outil:"+selected.getName()+ " X: " + coords.x + " Y: " + coords.y); if (call!=calling.mouseover)
Gdx.app.debug("evenement","mode:"+call+" outil:"+selected.getName()+ " X: " + coords.x + " Y: " + coords.y+" button:"+button);
Method method; Method method;
try { try {
Class<?> base = Class.forName("fr.evolving.screens.GameScreen"); Class<?> base = Class.forName("fr.evolving.screens.GameScreen");
@ -489,7 +461,7 @@ public class GameScreen implements Screen {
} }
void map_transmuter(float realx, float realy,int x, int y,boolean alone,int button,calling call) { void map_transmuter(float realx, float realy,int x, int y,boolean alone,int button,calling call) {
if (call==calling.mousescroll || call==calling.mousex2click) if (call==calling.taptap && button==0 || (call==calling.mouseclick && button==1))
{ {
Angular angle=selected_transmuter.getRotation(); Angular angle=selected_transmuter.getRotation();
if (angle==Angular.A00) if (angle==Angular.A00)
@ -515,16 +487,17 @@ public class GameScreen implements Screen {
while(keySetIterator.hasNext()){ while(keySetIterator.hasNext()){
Vector2 key = keySetIterator.next(); Vector2 key = keySetIterator.next();
color=63; color=63;
if (((!level.Grid.GetFiber(x+key.x, y+key.y) && !level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Rien) || (level.Grid.GetFiber(x+key.x, y+key.y) && level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Tout) || (level.Grid.GetFiber(x+key.x, y+key.y) && !level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Fibre) || (level.Grid.getCopper(x+key.x, y+key.y) && !level.Grid.GetFiber(x+key.x, y+key.y) && tiles.get(key)==CaseType.Cuivre)) && (level.Grid.getTransmutercalc(x+key.x, y+key.y)==0)) if (((!level.Grid.getFiber(x+key.x, y+key.y) && !level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Rien) || (level.Grid.getFiber(x+key.x, y+key.y) && level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Tout) || (level.Grid.getFiber(x+key.x, y+key.y) && !level.Grid.getCopper(x+key.x, y+key.y) && tiles.get(key)==CaseType.Fibre) || (level.Grid.getCopper(x+key.x, y+key.y) && !level.Grid.getFiber(x+key.x, y+key.y) && tiles.get(key)==CaseType.Cuivre)) && (level.Grid.getTransmutercalc(x+key.x, y+key.y)==0))
color=0; color=0;
else else
positionisgood=false; positionisgood=false;
map.tempdraw(x+key.x, y+key.y, ++MainTile, selected_transmuter.getRotation().ordinal(),color); map.tempdraw(x+key.x, y+key.y, ++MainTile, selected_transmuter.getRotation().ordinal(),color);
if (call==calling.mouseclick && positionisgood && button!=1) if ((call==calling.longpress && button==0) && positionisgood)
{ {
level.Grid.GetXY(x,y).Transmuter=(Transmuter) selected_transmuter.clone(); level.Grid.GetXY(x,y).Transmuter=(Transmuter) selected_transmuter.clone();
if (alone) level.Grid.tiling_transmuter(); if (alone) level.Grid.tiling_transmuter();
map.redraw(53); map.redraw(60);
Gdx.input.vibrate(new long[] { 0, 400, 500, 400}, -1);
} }
} }
} }
@ -539,13 +512,10 @@ public class GameScreen implements Screen {
if (level.Grid.GetXY(x,y).Fiber>0) if (level.Grid.GetXY(x,y).Fiber>0)
Gdx.app.debug("map","*** Présence de fibre"); Gdx.app.debug("map","*** Présence de fibre");
if (level.Grid.GetXY(x,y).Transmuter_calc>0) { if (level.Grid.GetXY(x,y).Transmuter_calc>0) {
Vector2 gotomain=AssetLoader.resolveTransmuterMain(level.Grid.GetXY(x,y).Transmuter_calc); Gdx.app.debug("map","transmuter deplacement vers origine:"+level.Grid.GetXY(x,y).Transmuter_movex+","+level.Grid.GetXY(x,y).Transmuter_movey+" coords:"+(x+level.Grid.GetXY(x,y).Transmuter_movex)+"x"+(y+level.Grid.GetXY(x,y).Transmuter_movey));
if (gotomain!=null) { Gdx.app.debug("map",level.Grid.getTransmuter(x+level.Grid.GetXY(x,y).Transmuter_movex,y+level.Grid.GetXY(x,y).Transmuter_movey).getInformations());
Gdx.app.debug("map","transmuter deplacement vers origine:"+String.valueOf(gotomain.x)+","+String.valueOf(gotomain.y)+" coords:"+(x+gotomain.x)+"x"+(y+gotomain.y)); showInfo(level.Grid.getTransmuter(x+level.Grid.GetXY(x,y).Transmuter_movex,y+level.Grid.GetXY(x,y).Transmuter_movey));
//Gdx.app.debug("map",level.Grid.getTransmuter(x+gotomain.x,y+gotomain.y).getInformations());
showInfo(level.Grid.getTransmuter(x+gotomain.x,y+gotomain.y));
} }
}
} }
else else
hideInfo(); hideInfo();
@ -597,17 +567,14 @@ public class GameScreen implements Screen {
void map_transmuter_eraser(float realx, float realy,int x, int y,boolean alone,int button,calling call) { void map_transmuter_eraser(float realx, float realy,int x, int y,boolean alone,int button,calling call) {
if (level.Grid.GetXY(x,y).Transmuter_calc!=0) if (level.Grid.GetXY(x,y).Transmuter_calc!=0)
{ {
Vector2 gotomain=AssetLoader.resolveTransmuterMain(level.Grid.GetXY(x,y).Transmuter_calc); level.Grid.GetXY(x+level.Grid.GetXY(x,y).Transmuter_movex,y+level.Grid.GetXY(x,y).Transmuter_movey).Transmuter=null;
if (gotomain!=null) { Gdx.app.debug("map","transmuter deplacement vers origine:"+level.Grid.GetXY(x,y).Transmuter_movex+","+level.Grid.GetXY(x,y).Transmuter_movey+" coords:"+(x+level.Grid.GetXY(x,y).Transmuter_movex)+"x"+(y+level.Grid.GetXY(x,y).Transmuter_movey));
level.Grid.GetXY(x+gotomain.x,y+gotomain.y).Transmuter=null;
Gdx.app.debug("map","transmuter deplacement vers origine:"+String.valueOf(gotomain.x)+","+String.valueOf(gotomain.y)+" coords:"+(x+gotomain.x)+"x"+(y+gotomain.y));
} }
if (alone) { if (alone) {
level.Grid.tiling_transmuter(); level.Grid.tiling_transmuter();
map.redraw(53); map.redraw(60);
} }
} }
}
void map_fiber_eraser(float realx, float realy,int x, int y,boolean alone,int button,calling call) { void map_fiber_eraser(float realx, float realy,int x, int y,boolean alone,int button,calling call) {
level.Grid.GetXY(x,y).Fiber=0; level.Grid.GetXY(x,y).Fiber=0;
@ -713,8 +680,21 @@ public class GameScreen implements Screen {
stage.addActor(menu); stage.addActor(menu);
processors.add(stage); processors.add(stage);
processors.add(stage_menu); processors.add(stage_menu);
gesturedetector=new GestureDetector(null);
processors.add(gesturedetector);
multiplexer.setProcessors(processors); multiplexer.setProcessors(processors);
Gdx.input.setInputProcessor(multiplexer); Gdx.input.setInputProcessor(multiplexer);
//Gdx.input.setInputProcessor(multiplexer);
}
public void preparemenu(int menuitem) {
Gdx.app.debug("menu","Affichage sousmenu "+menuitem);
checkMenu(menuitem,true);
menu.clear();
map.tempclear();
map.fillempty(53);
selected=null;
hideInfo();
} }
public void showInfo(Transmuter transmuter) { public void showInfo(Transmuter transmuter) {
@ -751,7 +731,6 @@ public class GameScreen implements Screen {
public void hideInfo() { public void hideInfo() {
unroll=false; unroll=false;
} }
public void checkMenu(int menu,boolean check) public void checkMenu(int menu,boolean check)