fix: amélioration de la gestion du menu avec possibilité d'ajouter des transmuter avec rotation. ajout de l'information sur une case à partir du mode débogueage. recentrage de la graille au double clique sur le bouton "move"
This commit is contained in:
parent
6e691f7bcc
commit
23908a8e4d
|
@ -1,5 +1,7 @@
|
||||||
package fr.evolving.UI;
|
package fr.evolving.UI;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
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;
|
||||||
|
@ -13,6 +15,8 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
|
||||||
import fr.evolving.assets.AssetLoader;
|
import fr.evolving.assets.AssetLoader;
|
||||||
import fr.evolving.automata.Level;
|
import fr.evolving.automata.Level;
|
||||||
|
import fr.evolving.automata.Transmuter;
|
||||||
|
import fr.evolving.automata.Transmuter.Angular;
|
||||||
|
|
||||||
public class Menu extends Actor{
|
public class Menu extends Actor{
|
||||||
|
|
||||||
|
@ -62,15 +66,38 @@ public void clear()
|
||||||
layer.getCell(x, y).setTile(AssetLoader.tileSet.getTile(54));
|
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);
|
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));
|
||||||
|
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<Vector2> 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);
|
Cell cell=((TiledMapTileLayer)map.getLayers().get(0)).getCell(x,y);
|
||||||
if (cell!=null)
|
if (cell!=null)
|
||||||
|
|
|
@ -159,6 +159,14 @@ public class AssetLoader {
|
||||||
return null;
|
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) {
|
public static Vector2 resolveTransmuterMain(int Id) {
|
||||||
Transmuter transmuter=getTransmuter(Id);
|
Transmuter transmuter=getTransmuter(Id);
|
||||||
if (transmuter!=null)
|
if (transmuter!=null)
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class Positiver_I extends Transmuter {
|
||||||
|
|
||||||
public Positiver_I(Level level) {
|
public Positiver_I(Level level) {
|
||||||
super(level);
|
super(level);
|
||||||
this.Name="positiveur I";
|
this.Name="Positiveur I";
|
||||||
this.theClass=Class.Charge;
|
this.theClass=Class.Charge;
|
||||||
this.Price=50;
|
this.Price=50;
|
||||||
this.Technology=2;
|
this.Technology=2;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class Positiver_II extends Transmuter {
|
||||||
|
|
||||||
public Positiver_II(Level level) {
|
public Positiver_II(Level level) {
|
||||||
super(level);
|
super(level);
|
||||||
this.Name="positiveur II";
|
this.Name="Positiveur II";
|
||||||
this.theClass=Class.Charge;
|
this.theClass=Class.Charge;
|
||||||
this.Price=50;
|
this.Price=50;
|
||||||
this.Technology=2;
|
this.Technology=2;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class Positiver_III extends Transmuter {
|
||||||
|
|
||||||
public Positiver_III(Level level) {
|
public Positiver_III(Level level) {
|
||||||
super(level);
|
super(level);
|
||||||
this.Name="positiveur III";
|
this.Name="Positiveur III";
|
||||||
this.theClass=Class.Charge;
|
this.theClass=Class.Charge;
|
||||||
this.Price=50;
|
this.Price=50;
|
||||||
this.Technology=2;
|
this.Technology=2;
|
||||||
|
|
|
@ -65,6 +65,10 @@ public abstract class Transmuter {
|
||||||
return (FindMainTile(Id)==getMainTile());
|
return (FindMainTile(Id)==getMainTile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTransmuter(String Name) {
|
||||||
|
return Name.equals(this.getName());
|
||||||
|
}
|
||||||
|
|
||||||
public Vector2 getPostitionMainTile(int Id) {
|
public Vector2 getPostitionMainTile(int Id) {
|
||||||
if (!isTransmuter(Id))
|
if (!isTransmuter(Id))
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -245,6 +245,9 @@ public class GameScreen implements Screen {
|
||||||
selected=event.getListenerActor();
|
selected=event.getListenerActor();
|
||||||
map.fillempty(53);
|
map.fillempty(53);
|
||||||
Gdx.app.debug(event.getListenerActor().toString(),"Barre:Selection dans la Barre bas");
|
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();
|
menu.clear();
|
||||||
map.fillempty(53);
|
map.fillempty(53);
|
||||||
selected=null;
|
selected=null;
|
||||||
menu.setMenu(0, 7, 71);
|
menu.setMenuTile(0, 7, 71);
|
||||||
menu.setMenu(1, 7, 72);
|
menu.setMenuTile(1, 7, 72);
|
||||||
menu.setMenu(2, 7, 73);
|
menu.setMenuTile(2, 7, 73);
|
||||||
menu.setMenu(1, 5, 70);
|
menu.setMenuTile(1, 5, 70);
|
||||||
menu.setMenu(0, 6, 74);
|
menu.setMenuTile(0, 6, 74);
|
||||||
menu.setMenu(1, 6, 75);
|
menu.setMenuTile(1, 6, 75);
|
||||||
menu.setMenu(2, 6, 76);
|
menu.setMenuTile(2, 6, 76);
|
||||||
menu.setMenu(0, 5, 77);
|
menu.setMenuTile(0, 5, 77);
|
||||||
menu.setMenu(2, 5, 78);
|
menu.setMenuTile(2, 5, 78);
|
||||||
menu.setMenu(3, 3, 79);
|
menu.setMenuTile(3, 3, 79);
|
||||||
Barre2[0].setChecked(true);
|
Barre2[0].setChecked(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -277,12 +280,9 @@ public class GameScreen implements Screen {
|
||||||
menu.clear();
|
menu.clear();
|
||||||
map.fillempty(53);
|
map.fillempty(53);
|
||||||
selected=null;
|
selected=null;
|
||||||
menu.setMenu(0, 7, 200);
|
menu.setMenuTransmuter(0,7,"Positiveur I",Angular.A00);
|
||||||
menu.setMenu(1, 7, 201);
|
menu.setMenuTransmuter(0,6,"Positiveur II",Angular.A00);
|
||||||
menu.setMenu(0, 6, 202);
|
menu.setMenuTransmuter(0,5,"Positiveur III",Angular.A00);
|
||||||
menu.setMenu(1, 6, 203);
|
|
||||||
menu.setMenu(0, 5, 204);
|
|
||||||
menu.setMenu(1, 5, 205);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Barre2[2].addListener(new ClickListener(){
|
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) {
|
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||||
oldx=0;
|
oldx=0;
|
||||||
oldy=0;
|
oldy=0;
|
||||||
|
if (selected!=null)
|
||||||
|
Gdx.app.debug(event.getListenerActor().toString(),"Cliquage sur la map, mode:"+selected.getName());
|
||||||
if (selected==null)
|
if (selected==null)
|
||||||
;
|
;
|
||||||
else if (selected.getName()=="cleaner")
|
else if (selected.getName()=="cleaner")
|
||||||
|
@ -386,6 +388,25 @@ public class GameScreen implements Screen {
|
||||||
map.redraw(60);
|
map.redraw(60);
|
||||||
return false;
|
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")
|
else if (selected.getName()=="zoomp")
|
||||||
{
|
{
|
||||||
map.setZoom(0.9f);
|
map.setZoom(0.9f);
|
||||||
|
@ -454,6 +475,8 @@ public class GameScreen implements Screen {
|
||||||
map.addListener(new ClickListener(){
|
map.addListener(new ClickListener(){
|
||||||
@Override
|
@Override
|
||||||
public void touchDragged(InputEvent event, float x, float y, int pointer) {
|
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)
|
if (selected==null)
|
||||||
;
|
;
|
||||||
else if (selected.getName()=="move") {
|
else if (selected.getName()=="move") {
|
||||||
|
@ -564,7 +587,7 @@ public class GameScreen implements Screen {
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||||
Vector2 coords=menu.screentoworld(x,y);
|
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);
|
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)
|
if (menuactor==null)
|
||||||
menuactor=new Actor();
|
menuactor=new Actor();
|
||||||
|
|
Loading…
Reference in New Issue