feat: ajout de transmuter dans le menu permet l'ajout de transmuter sur le plateau (sans vérification conditions) ajout de fonctions permettant la gestion des transmuteurs
This commit is contained in:
parent
7a3e33dd6b
commit
e2f28ba535
|
@ -25,6 +25,7 @@ public class Menu extends Actor{
|
|||
private float decy;
|
||||
private int size=32;
|
||||
|
||||
|
||||
public Menu(int tilesizex,int tilesizey) {
|
||||
this.tilesizex=tilesizex;
|
||||
this.tilesizey=tilesizey;
|
||||
|
|
|
@ -150,6 +150,14 @@ public class AssetLoader {
|
|||
}
|
||||
}
|
||||
|
||||
public static Transmuter getTransmuter(int Id) {
|
||||
for(Transmuter transmuter:allTransmuter) {
|
||||
if (transmuter.isTransmuter(Id))
|
||||
return transmuter;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int setpref() {
|
||||
prefs = Gdx.app.getPreferences("WireWorld - Evolving Games");
|
||||
if (prefs.contains("log"))
|
||||
|
|
|
@ -148,6 +148,26 @@ public class Positiver_I extends Transmuter {
|
|||
return result;
|
||||
}
|
||||
|
||||
public Vector2[] getallSize() {
|
||||
HashMap<Vector2,CaseType> newTiles= new HashMap<Vector2,CaseType>();
|
||||
Iterator<Vector2> keySetIterator = this.Tiles.keySet().iterator();
|
||||
Vector2[] vector=new Vector2[2];
|
||||
vector[0]=new Vector2();
|
||||
vector[1]=new Vector2();
|
||||
while(keySetIterator.hasNext()){
|
||||
Vector2 key = keySetIterator.next();
|
||||
double delta=key.len();
|
||||
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
|
||||
float x=(float)Math.round(delta*Math.cos(alpha));
|
||||
float y=(float)Math.round(delta*Math.sin(alpha));
|
||||
vector[0].x=Math.min(vector[0].x, x);
|
||||
vector[0].y=Math.min(vector[0].y, y);
|
||||
vector[1].x=Math.max(vector[1].x, x);
|
||||
vector[1].y=Math.max(vector[1].y, y);
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
public HashMap<Vector2,CaseType> getTiles() {
|
||||
HashMap<Vector2,CaseType> newTiles= new HashMap<Vector2,CaseType>();
|
||||
Iterator<Vector2> keySetIterator = this.Tiles.keySet().iterator();
|
||||
|
|
|
@ -146,6 +146,26 @@ public class Positiver_II extends Transmuter {
|
|||
return result;
|
||||
}
|
||||
|
||||
public Vector2[] getallSize() {
|
||||
HashMap<Vector2,CaseType> newTiles= new HashMap<Vector2,CaseType>();
|
||||
Iterator<Vector2> keySetIterator = this.Tiles.keySet().iterator();
|
||||
Vector2[] vector=new Vector2[2];
|
||||
vector[0]=new Vector2();
|
||||
vector[1]=new Vector2();
|
||||
while(keySetIterator.hasNext()){
|
||||
Vector2 key = keySetIterator.next();
|
||||
double delta=key.len();
|
||||
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
|
||||
float x=(float)Math.round(delta*Math.cos(alpha));
|
||||
float y=(float)Math.round(delta*Math.sin(alpha));
|
||||
vector[0].x=Math.min(vector[0].x, x);
|
||||
vector[0].y=Math.min(vector[0].y, y);
|
||||
vector[1].x=Math.max(vector[1].x, x);
|
||||
vector[1].y=Math.max(vector[1].y, y);
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
public HashMap<Vector2,CaseType> getTiles() {
|
||||
HashMap<Vector2,CaseType> newTiles= new HashMap<Vector2,CaseType>();
|
||||
Iterator<Vector2> keySetIterator = this.Tiles.keySet().iterator();
|
||||
|
|
|
@ -146,6 +146,26 @@ public class Positiver_III extends Transmuter {
|
|||
return result;
|
||||
}
|
||||
|
||||
public Vector2[] getallSize() {
|
||||
HashMap<Vector2,CaseType> newTiles= new HashMap<Vector2,CaseType>();
|
||||
Iterator<Vector2> keySetIterator = this.Tiles.keySet().iterator();
|
||||
Vector2[] vector=new Vector2[2];
|
||||
vector[0]=new Vector2();
|
||||
vector[1]=new Vector2();
|
||||
while(keySetIterator.hasNext()){
|
||||
Vector2 key = keySetIterator.next();
|
||||
double delta=key.len();
|
||||
double alpha=key.angleRad()+this.getRotation().ordinal()*Math.PI/2;
|
||||
float x=(float)Math.round(delta*Math.cos(alpha));
|
||||
float y=(float)Math.round(delta*Math.sin(alpha));
|
||||
vector[0].x=Math.min(vector[0].x, x);
|
||||
vector[0].y=Math.min(vector[0].y, y);
|
||||
vector[1].x=Math.max(vector[1].x, x);
|
||||
vector[1].y=Math.max(vector[1].y, y);
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
public HashMap<Vector2,CaseType> getTiles() {
|
||||
HashMap<Vector2,CaseType> newTiles= new HashMap<Vector2,CaseType>();
|
||||
Iterator<Vector2> keySetIterator = this.Tiles.keySet().iterator();
|
||||
|
|
|
@ -61,6 +61,27 @@ public abstract class Transmuter {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public boolean isTransmuter(int Id) {
|
||||
return (FindMainTile(Id)==getMainTile());
|
||||
}
|
||||
|
||||
public Vector2 getPostitionMainTile(int Id) {
|
||||
if (!isTransmuter(Id))
|
||||
return null;
|
||||
HashMap<Vector2,CaseType> tiles=this.getTiles();
|
||||
Iterator<Vector2> keySetIterator = tiles.keySet().iterator();
|
||||
int Idrec=this.getMainTile();
|
||||
if (Id==Idrec)
|
||||
return new Vector2();
|
||||
while(keySetIterator.hasNext()){
|
||||
Vector2 key = keySetIterator.next();
|
||||
Idrec++;
|
||||
if (Id==Idrec)
|
||||
return new Vector2().sub(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<Vector2,CaseType> getTiles() {
|
||||
return null;
|
||||
}
|
||||
|
@ -176,11 +197,22 @@ public abstract class Transmuter {
|
|||
return null;
|
||||
}
|
||||
|
||||
public Vector2[] getallSize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getInformations() {
|
||||
HashMap<Vector2,CaseType> tiles=this.getTiles();
|
||||
Iterator<Vector2> keySetIterator = tiles.keySet().iterator();
|
||||
String result;
|
||||
result="**********************************\n"+"Name:"+this.getName()+"\nClass:"+this.getaClass()+" Id:"+this.getMainTile()+" Rotation:"+this.getRotation()+"\nPrice:"+this.getPrice()+" Tech:"+this.getTechnology()+"\nResearch:"+this.getResearch()+" Size:"+this.getSize()+"\nActivable:"+this.isActivable()+" Activation:"+this.getActivationLevel()+" Visible:"+this.isShowed()+"\nUpgradable:"+((this.isUpgradable())?this.getUpgrade().getName():this.isUpgradable())+" Unlockable:"+((this.isUnlockable())?this.getUnlock().getName():this.isUnlockable())+"\nUpgrade Cycle:"+this.getUpgradeCycle()+" upgrade:"+this.isUpgradableCycle()+"\nUpgrade Temperature:"+this.getUpgradeTemp()+" upgrade:"+this.isUpgradableTemp()+"\nUpgrade Nrj:"+this.getUpgradeNrj()+" upgrade:"+this.isUpgradableNrj()+"\nUpgrade Rayon:"+this.getUpgradeRayon()+" upgrade:"+this.isUpgradableRayon()+"\nTemperature /turn:"+this.getTurnTemp()+" Rayon /turn:"+this.getTurnRayon()+" Nrj /turn:"+this.getTurnNrj()+"\nTemperature /use:"+this.getUsedTemp()+" Rayon /use:"+this.getUsedRayon()+" Nrj /use:"+this.getUsedNrj()+"\n";
|
||||
result="**********************************\n"+"Name:"+this.getName()+"\nClass:"+this.getaClass()+" Id:"+this.getMainTile()+" Rotation:"+this.getRotation()+"\nPrice:"+this.getPrice()+" Tech:"+this.getTechnology()+"\nResearch:"+this.getResearch()+" Size:"+this.getSize()+"\nActivable:"+this.isActivable()+" Activation:"+this.getActivationLevel()+" Visible:"+this.isShowed()+"\nUpgradable:"+((this.isUpgradable())?this.getUpgrade().getName():this.isUpgradable())+" Unlockable:"+((this.isUnlockable())?this.getUnlock().getName():this.isUnlockable())+"\nUpgrade Cycle:"+this.getUpgradeCycle()+" upgrade:"+this.isUpgradableCycle()+"\nUpgrade Temperature:"+this.getUpgradeTemp()+" upgrade:"+this.isUpgradableTemp()+"\nUpgrade Nrj:"+this.getUpgradeNrj()+" upgrade:"+this.isUpgradableNrj()+"\nUpgrade Rayon:"+this.getUpgradeRayon()+" upgrade:"+this.isUpgradableRayon()+"\nTemperature /turn:"+this.getTurnTemp()+" Rayon /turn:"+this.getTurnRayon()+" Nrj /turn:"+this.getTurnNrj()+"\nTemperature /use:"+this.getUsedTemp()+" Rayon /use:"+this.getUsedRayon()+" Nrj /use:"+this.getUsedNrj()+"\nTiles:";
|
||||
int[] allTiles;
|
||||
Vector2[] allSize;
|
||||
allTiles=this.getallTiles();
|
||||
for(int i=0;i<allTiles.length;i++)
|
||||
result+=allTiles[i]+" ";
|
||||
allSize=this.getallSize();
|
||||
result+="Size x&y:"+allSize[0].x+","+allSize[0].y+" to "+ allSize[1].x+","+allSize[1].y+"\n *Placement*\n";
|
||||
while(keySetIterator.hasNext()){
|
||||
Vector2 key = keySetIterator.next();
|
||||
result+="\ncoords:" + key.x+","+key.y + " type: " + tiles.get(key);
|
||||
|
|
|
@ -46,6 +46,7 @@ import fr.evolving.automata.Level;
|
|||
import fr.evolving.automata.Positiver_I;
|
||||
import fr.evolving.automata.Positiver_II;
|
||||
import fr.evolving.automata.Positiver_III;
|
||||
import fr.evolving.automata.Transmuter;
|
||||
import fr.evolving.automata.Transmuter.Angular;
|
||||
import fr.evolving.inputs.InputHandler;
|
||||
|
||||
|
@ -67,6 +68,7 @@ public class GameScreen implements Screen {
|
|||
String[] tocreate={"run","stop","speed","separator","move","zoomp","zoomm","separator","raz","save","levels","tree","exits","separator","screen","sound","tuto","settings","separator","stat"};
|
||||
String[] tocreate2={"Structure","Charge","Direction","Selection","Création","Détection","Action","Scénario"};
|
||||
public Actor selected;
|
||||
public Transmuter selected_transmuter;
|
||||
private ButtonLevel buttonlevel;
|
||||
private Objectives objectives;
|
||||
private TouchMaptiles map;
|
||||
|
@ -176,6 +178,7 @@ public class GameScreen implements Screen {
|
|||
level.Grid.Cells[2][2].Transmuter.setRotation(Angular.A270);
|
||||
level.Grid.Cells[7][2].Transmuter=new Positiver_III(level);
|
||||
level.Grid.Cells[7][2].Transmuter.setRotation(Angular.A270);
|
||||
Gdx.app.debug("7.2 A270 place main",String.valueOf(level.Grid.Cells[7][2].Transmuter.getPostitionMainTile(205)));
|
||||
level.Grid.tiling_transmuter();
|
||||
int[] result;
|
||||
result=level.Grid.Cells[5][5].Transmuter.getallTiles();
|
||||
|
@ -184,6 +187,7 @@ public class GameScreen implements Screen {
|
|||
result=level.Grid.Cells[8][8].Transmuter.getallTiles();
|
||||
for (int i=0;i<result.length;i++)
|
||||
Gdx.app.debug("getalltiles 8,8",String.valueOf(result[i]));
|
||||
Gdx.app.debug("istransmuter 203",AssetLoader.getTransmuter(201).getName());
|
||||
}
|
||||
});
|
||||
if (Gdx.graphics.isFullscreen())
|
||||
|
@ -266,7 +270,12 @@ public class GameScreen implements Screen {
|
|||
menu.clear();
|
||||
map.fillempty(53);
|
||||
selected=null;
|
||||
menu.setMenu(0, 7, 10);
|
||||
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);
|
||||
}
|
||||
});
|
||||
Barre2[2].addListener(new ClickListener(){
|
||||
|
@ -408,6 +417,17 @@ public class GameScreen implements Screen {
|
|||
map.redraw(60);
|
||||
}
|
||||
}
|
||||
else if (selected.getName()=="transmuter")
|
||||
{
|
||||
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.tiling_transmuter();
|
||||
map.redraw(60);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -466,9 +486,9 @@ public class GameScreen implements Screen {
|
|||
Vector2 coords=menu.screentoworld(x,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();
|
||||
if (tile!=54 && tile!=0) {
|
||||
Vector2 coords2=menu.worldtoscreen((int)coords.x,(int)coords.y);
|
||||
menuactor.setBounds(coords2.x, coords2.y, 60, 60);
|
||||
selected=menuactor;
|
||||
|
@ -480,6 +500,19 @@ public class GameScreen implements Screen {
|
|||
selected.setName("fiber");
|
||||
else if (tile==53)
|
||||
selected.setName("blank");
|
||||
else if (tile>99) {
|
||||
Transmuter transmuter=AssetLoader.getTransmuter(tile);
|
||||
if (transmuter!=null) {
|
||||
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;
|
||||
Gdx.app.debug(event.getListenerActor().toString(),"transmuter deplacement vers origine:"+String.valueOf(gotomain.x)+","+String.valueOf(gotomain.y)+" coords:"+coords2.x+"x"+coords2.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue