feat: mise en place du mode "play" ou simulation pour les photons
This commit is contained in:
parent
321ee560b2
commit
2b430d4bbf
|
@ -6,6 +6,7 @@ import java.util.Arrays;
|
|||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.InputProcessor;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.input.GestureDetector.GestureListener;
|
||||
|
@ -27,6 +28,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
|
|||
import fr.evolving.assets.AssetLoader;
|
||||
import fr.evolving.automata.Level;
|
||||
import fr.evolving.automata.Worlds;
|
||||
import fr.evolving.automata.Worlds.State;
|
||||
import fr.evolving.screens.GameScreen.calling;
|
||||
|
||||
public class TouchMaptiles extends Actor implements GestureListener,InputProcessor {
|
||||
|
@ -169,40 +171,51 @@ public class TouchMaptiles extends Actor implements GestureListener,InputProcess
|
|||
// 4 Surtile Fond du transmuteur | Effets
|
||||
// 5 Verrouillage | Jauge activation
|
||||
// 6 Gratuité
|
||||
// 7 Direction du centre
|
||||
public void redraw() {
|
||||
for (int x = 0; x < level.Grid.sizeX; x++)
|
||||
for (int y = 0; y < level.Grid.sizeY; y++) {
|
||||
if (worlds.isDebug()) {
|
||||
if (level.Grid.GetXY(x,y).Locked)
|
||||
((TiledMapTileLayer) map.getLayers().get(5)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(90));
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(5)).getCell((int) x,(int) y).setTile(null);
|
||||
if (level.Grid.GetXY(x,y).Free)
|
||||
((TiledMapTileLayer) map.getLayers().get(6)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(89));
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(6)).getCell((int) x,(int) y).setTile(null);
|
||||
}
|
||||
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)));
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(1)).getCell((int) x,(int) y).setTile(null);
|
||||
if (level.Grid.getFiber(x, y))
|
||||
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x, (int) y).setTile(AssetLoader.tileSet.getTile(61));
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(this.clearsprite));
|
||||
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).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);
|
||||
if (worlds.getState()==State.simulating) {
|
||||
if (level.Grid.GetXY(x,y).Fiber)
|
||||
if (level.Grid.GetXY(x,y).Fiber_state==0)
|
||||
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(61));
|
||||
else {
|
||||
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(90+level.Grid.GetXY(x,y).Fiber_state));
|
||||
}
|
||||
}
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(2)).getCell((int) x,(int) y).setTile(null);
|
||||
;
|
||||
{
|
||||
if (worlds.isDebug()) {
|
||||
if (level.Grid.GetXY(x,y).Locked)
|
||||
((TiledMapTileLayer) map.getLayers().get(5)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(90));
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(5)).getCell((int) x,(int) y).setTile(null);
|
||||
if (level.Grid.GetXY(x,y).Free)
|
||||
((TiledMapTileLayer) map.getLayers().get(6)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(89));
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(6)).getCell((int) x,(int) y).setTile(null);
|
||||
}
|
||||
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)));
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(1)).getCell((int) x,(int) y).setTile(null);
|
||||
if (level.Grid.getFiber(x, y))
|
||||
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x, (int) y).setTile(AssetLoader.tileSet.getTile(61));
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(0)).getCell((int) x,(int) y).setTile(AssetLoader.tileSet.getTile(this.clearsprite));
|
||||
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).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);
|
||||
}
|
||||
else
|
||||
((TiledMapTileLayer) map.getLayers().get(2)).getCell((int) x,(int) y).setTile(null);
|
||||
((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) 2, (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) 2, (int) 0).setTile(AssetLoader.tileSet.getTile(1010));
|
||||
}
|
||||
|
||||
public void initzoom() {
|
||||
|
|
|
@ -3,19 +3,20 @@ package fr.evolving.automata;
|
|||
import java.io.Serializable;
|
||||
|
||||
public class Cell implements Serializable,Cloneable {
|
||||
public int Fiber;
|
||||
public boolean Fiber;
|
||||
public boolean Copper;
|
||||
public Transmuter Transmuter;
|
||||
public boolean Locked;
|
||||
public boolean Free;
|
||||
|
||||
public transient int Fiber_state;
|
||||
public transient int Copper_calc;
|
||||
public transient int Transmuter_calc;
|
||||
public transient int Transmuter_movex;
|
||||
public transient int Transmuter_movey;
|
||||
|
||||
public Cell() {
|
||||
this.Fiber = 0;
|
||||
this.Fiber = false;
|
||||
this.Copper = false;
|
||||
this.Locked = false;
|
||||
this.Free = false;
|
||||
|
|
|
@ -8,6 +8,9 @@ import com.badlogic.gdx.math.Vector2;
|
|||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectMap.Entry;
|
||||
|
||||
import fr.evolving.automata.Particle.Orientation;
|
||||
import fr.evolving.automata.Particle.Type;
|
||||
|
||||
public class Grid implements Serializable,Cloneable {
|
||||
protected Cell[][] Cells;
|
||||
public Integer sizeX, sizeY;
|
||||
|
@ -15,7 +18,7 @@ public class Grid implements Serializable,Cloneable {
|
|||
public transient Array<Particle> particles;
|
||||
|
||||
public Grid(Integer X, Integer Y) {
|
||||
particles=new Array<Particle>();
|
||||
Reinit();
|
||||
this.sizeX = X;
|
||||
this.sizeY = Y;
|
||||
this.Cells = new Cell[this.sizeX][this.sizeY];
|
||||
|
@ -26,21 +29,48 @@ public class Grid implements Serializable,Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
public void Reinit() {
|
||||
if (particles==null)
|
||||
particles=new Array<Particle>();
|
||||
}
|
||||
|
||||
//Réalise un cycle de simulation dans la grille
|
||||
public void Cycle() {
|
||||
|
||||
for(Particle particle: particles) {
|
||||
Gdx.app.debug("wirechem-Grid", "Grid Cycle -> Particle "+particle.getType()+"/"+particle.getSize()+ " coords:"+particle.getCoordx()+","+particle.getCoordy()+"/"+particle.getOrientation()+" charge:"+particle.getCharge());
|
||||
if (particle.getType()==Type.Photon) {
|
||||
particle.Next();
|
||||
if (!particle.isAlive()) {
|
||||
Gdx.app.debug("wirechem-Particle", "coords:"+particle.getCoordx()+","+particle.getCoordy()+" killed & removed");
|
||||
particles.removeValue(particle, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Affiche le cycle en cours à l'écran
|
||||
public void tiling_particle() {
|
||||
for (int x = 0; x < this.sizeX; x++)
|
||||
for (int y = 0; y < this.sizeY; y++)
|
||||
if (GetXY(x, y).Fiber)
|
||||
GetXY(x, y).Fiber_state = 0;
|
||||
for(Particle particle: particles) {
|
||||
|
||||
if (particle.getType()==Type.Photon) {
|
||||
GetXY(particle.getCoordx(), particle.getCoordy()).Fiber_state=Math.floorDiv(29-particle.getLife(),3);
|
||||
Gdx.app.debug("wirechem-Grid", "Grid Tiling -> Photon state :"+GetXY(particle.getCoordx(), particle.getCoordy()).Fiber_state+":"+particle.getCoordx()+","+particle.getCoordy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Initialise la simulation pour permettre ensuite de faire des cycles
|
||||
public void Initialize() {
|
||||
|
||||
particles.clear();
|
||||
this.tiling_particle();
|
||||
particles.add(new Particle(this));
|
||||
particles.get(0).setType(Type.Photon);
|
||||
particles.get(0).setCoordx(6);
|
||||
particles.get(0).setCoordy(3);
|
||||
particles.get(0).setOrientation(Orientation.E);
|
||||
}
|
||||
|
||||
//Genère des tiles qui correspondent aux transmuteurs sur la grille
|
||||
|
@ -300,7 +330,7 @@ public class Grid implements Serializable,Cloneable {
|
|||
if (cell == null)
|
||||
return false;
|
||||
else
|
||||
return cell.Fiber > 0;
|
||||
return cell.Fiber;
|
||||
}
|
||||
|
||||
public int getCoppercalc(float X, float Y) {
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package fr.evolving.automata;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
|
||||
public class Particle {
|
||||
public enum Type {
|
||||
Electron, Photon, Proton, Neutron
|
||||
}
|
||||
public enum Orientation {
|
||||
Nord, Sud, Est, Ouest
|
||||
N, S, E, O, NE, SE, NO, SO
|
||||
};
|
||||
public enum Size {
|
||||
Gros, Petit
|
||||
|
@ -14,16 +16,21 @@ public class Particle {
|
|||
Positif, Negatif, Neutre
|
||||
};
|
||||
|
||||
protected Orientation orientation;
|
||||
protected Size size;
|
||||
protected Charge charge;
|
||||
protected int coordX;
|
||||
protected int coordY;
|
||||
private Orientation orientation;
|
||||
private Size size;
|
||||
private Charge charge;
|
||||
private int coordX;
|
||||
private int coordY;
|
||||
private Type type;
|
||||
private int life;
|
||||
private boolean Alive;
|
||||
|
||||
static protected Grid grid;
|
||||
static private Grid grid;
|
||||
|
||||
public Particle(Grid grid) {
|
||||
this.orientation=Orientation.Est;
|
||||
this.Alive=true;
|
||||
this.type=Type.Electron;
|
||||
this.orientation=Orientation.E;
|
||||
this.size=Size.Petit;
|
||||
this.charge=Charge.Neutre;
|
||||
this.coordX=0;
|
||||
|
@ -31,6 +38,38 @@ public class Particle {
|
|||
Particle.grid=grid;
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
this.Alive=false;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return this.Alive;
|
||||
}
|
||||
|
||||
public int getLife() {
|
||||
return this.life;
|
||||
}
|
||||
|
||||
public void setLife(int life) {
|
||||
this.life=life;
|
||||
}
|
||||
|
||||
public int getCoordx() {
|
||||
return this.coordX;
|
||||
}
|
||||
|
||||
public int getCoordy() {
|
||||
return this.coordY;
|
||||
}
|
||||
|
||||
public void setCoordx(int coordX) {
|
||||
this.coordX=coordX;
|
||||
}
|
||||
|
||||
public void setCoordy(int coordY) {
|
||||
this.coordY=coordY;
|
||||
}
|
||||
|
||||
public Orientation getOrientation() {
|
||||
return this.orientation;
|
||||
}
|
||||
|
@ -43,6 +82,14 @@ public class Particle {
|
|||
return this.charge;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type=type;
|
||||
}
|
||||
|
||||
public void setOrientation(Orientation orientation) {
|
||||
this.orientation=orientation;
|
||||
}
|
||||
|
@ -83,8 +130,158 @@ public class Particle {
|
|||
}
|
||||
|
||||
public void Next() {
|
||||
|
||||
this.life++;
|
||||
int movex = 0,movey = 0;
|
||||
Orientation neworientation=this.orientation;
|
||||
if (type==Type.Photon) {
|
||||
if (life>=30) this.kill();
|
||||
if (this.orientation==Orientation.E)
|
||||
{
|
||||
if (this.grid.GetXY(this.coordX+1, this.coordY)!=null && this.grid.GetXY(this.coordX+1, this.coordY).Fiber) {
|
||||
movex=+1;
|
||||
neworientation=Orientation.E;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX+1, this.coordY+1)!=null && this.grid.GetXY(this.coordX+1, this.coordY+1).Fiber) {
|
||||
movex=+1;
|
||||
movey=+1;
|
||||
neworientation=Orientation.NE;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX+1, this.coordY-1)!=null && this.grid.GetXY(this.coordX+1, this.coordY-1).Fiber) {
|
||||
movex=+1;
|
||||
movey=-1;
|
||||
neworientation=Orientation.SE;
|
||||
}
|
||||
}
|
||||
else if (this.orientation==Orientation.NE)
|
||||
{
|
||||
if (this.grid.GetXY(this.coordX+1, this.coordY+1)!=null && this.grid.GetXY(this.coordX+1, this.coordY+1).Fiber) {
|
||||
movex=+1;
|
||||
movey=+1;
|
||||
neworientation=Orientation.NE;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX, this.coordY+1)!=null && this.grid.GetXY(this.coordX, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
neworientation=Orientation.N;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX+1, this.coordY)!=null && this.grid.GetXY(this.coordX+1, this.coordY).Fiber) {
|
||||
movex=+1;
|
||||
neworientation=Orientation.E;
|
||||
}
|
||||
}
|
||||
else if (this.orientation==Orientation.N)
|
||||
{
|
||||
if (this.grid.GetXY(this.coordX, this.coordY+1)!=null && this.grid.GetXY(this.coordX, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
neworientation=Orientation.N;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX-1, this.coordY+1)!=null && this.grid.GetXY(this.coordX-1, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
movex=-1;
|
||||
neworientation=Orientation.NO;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX+1, this.coordY+1)!=null && this.grid.GetXY(this.coordX+1, this.coordY+1).Fiber) {
|
||||
movex=+1;
|
||||
movey=+1;
|
||||
neworientation=Orientation.NE;
|
||||
}
|
||||
}
|
||||
else if (this.orientation==Orientation.NO)
|
||||
{
|
||||
if (this.grid.GetXY(this.coordX-1, this.coordY+1)!=null && this.grid.GetXY(this.coordX-1, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
movex=-1;
|
||||
neworientation=Orientation.NO;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX-1, this.coordY+1)!=null && this.grid.GetXY(this.coordX-1, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
movex=-1;
|
||||
neworientation=Orientation.N;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX+1, this.coordY+1)!=null && this.grid.GetXY(this.coordX+1, this.coordY+1).Fiber) {
|
||||
movex=+1;
|
||||
movey=+1;
|
||||
neworientation=Orientation.O;
|
||||
}
|
||||
}
|
||||
else if (this.orientation==Orientation.O)
|
||||
{
|
||||
if (this.grid.GetXY(this.coordX, this.coordY+1)!=null && this.grid.GetXY(this.coordX, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
neworientation=Orientation.N;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX-1, this.coordY+1)!=null && this.grid.GetXY(this.coordX-1, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
movex=-1;
|
||||
neworientation=Orientation.NO;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX+1, this.coordY+1)!=null && this.grid.GetXY(this.coordX+1, this.coordY+1).Fiber) {
|
||||
movex=+1;
|
||||
movey=+1;
|
||||
neworientation=Orientation.NE;
|
||||
}
|
||||
}
|
||||
else if (this.orientation==Orientation.SO)
|
||||
{
|
||||
if (this.grid.GetXY(this.coordX, this.coordY+1)!=null && this.grid.GetXY(this.coordX, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
neworientation=Orientation.N;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX-1, this.coordY+1)!=null && this.grid.GetXY(this.coordX-1, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
movex=-1;
|
||||
neworientation=Orientation.NO;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX+1, this.coordY+1)!=null && this.grid.GetXY(this.coordX+1, this.coordY+1).Fiber) {
|
||||
movex=+1;
|
||||
movey=+1;
|
||||
neworientation=Orientation.NE;
|
||||
}
|
||||
}
|
||||
else if (this.orientation==Orientation.S)
|
||||
{
|
||||
if (this.grid.GetXY(this.coordX, this.coordY+1)!=null && this.grid.GetXY(this.coordX, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
neworientation=Orientation.N;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX-1, this.coordY+1)!=null && this.grid.GetXY(this.coordX-1, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
movex=-1;
|
||||
neworientation=Orientation.NO;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX+1, this.coordY+1)!=null && this.grid.GetXY(this.coordX+1, this.coordY+1).Fiber) {
|
||||
movex=+1;
|
||||
movey=+1;
|
||||
neworientation=Orientation.NE;
|
||||
}
|
||||
}
|
||||
else if (this.orientation==Orientation.SE)
|
||||
{
|
||||
if (this.grid.GetXY(this.coordX, this.coordY+1)!=null && this.grid.GetXY(this.coordX, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
neworientation=Orientation.N;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX-1, this.coordY+1)!=null && this.grid.GetXY(this.coordX-1, this.coordY+1).Fiber) {
|
||||
movey=+1;
|
||||
movex=-1;
|
||||
neworientation=Orientation.NO;
|
||||
}
|
||||
else if (this.grid.GetXY(this.coordX+1, this.coordY+1)!=null && this.grid.GetXY(this.coordX+1, this.coordY+1).Fiber) {
|
||||
movex=+1;
|
||||
movey=+1;
|
||||
neworientation=Orientation.NE;
|
||||
}
|
||||
}
|
||||
if (movex==0 && movey==0)
|
||||
{
|
||||
Gdx.app.debug("wirechem-Particle", "coords:"+this.coordX+","+this.coordY+" killed no place to go");
|
||||
this.kill();
|
||||
}
|
||||
else {
|
||||
Gdx.app.debug("wirechem-Particle", "coords:"+this.coordX+","+this.coordY+" move to "+orientation+":"+movex+","+movey+" life:"+this.life);
|
||||
orientation=neworientation;
|
||||
this.coordX+=movex;
|
||||
this.coordY+=movey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class Worlds extends Actor {
|
|||
private int research;
|
||||
private Level lastchange;
|
||||
|
||||
public enum State {pause,simulating,notloaded,databasefailed};
|
||||
public enum State {stop,simulating,notloaded,databasefailed};
|
||||
public enum LinkDelMethod {all,in,out,rebase};
|
||||
|
||||
public Worlds(String campaign) {
|
||||
|
@ -83,7 +83,7 @@ public class Worlds extends Actor {
|
|||
if (Transmuters==null)
|
||||
state=State.notloaded;
|
||||
else
|
||||
state=State.pause;
|
||||
state=State.stop;
|
||||
}
|
||||
|
||||
public Array<Transmuter> getTransmuters() {
|
||||
|
@ -98,8 +98,11 @@ public class Worlds extends Actor {
|
|||
}
|
||||
|
||||
public void ReadGrid(int number) {
|
||||
if (usedlevel!=null)
|
||||
if (usedlevel!=null) {
|
||||
usedlevel.Grid = AssetLoader.Datahandler.user().getGrid(0, usedlevel.id, number);
|
||||
if (usedlevel.Grid!=null)
|
||||
usedlevel.Grid.Reinit();
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveGrid() {
|
||||
|
@ -108,8 +111,11 @@ public class Worlds extends Actor {
|
|||
}
|
||||
|
||||
public void ReadLastGrid() {
|
||||
if (usedlevel!=null)
|
||||
if (usedlevel!=null) {
|
||||
usedlevel.Grid = AssetLoader.Datahandler.user().getGrid(0, usedlevel.id, "LAST");
|
||||
if (usedlevel.Grid!=null)
|
||||
usedlevel.Grid.Reinit();
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveLastGrid() {
|
||||
|
@ -474,7 +480,7 @@ public class Worlds extends Actor {
|
|||
if (levels==null)
|
||||
state=State.notloaded;
|
||||
else
|
||||
state=State.pause;
|
||||
state=State.stop;
|
||||
}
|
||||
|
||||
public void create(String campaign) {
|
||||
|
@ -485,7 +491,7 @@ public class Worlds extends Actor {
|
|||
Preference.prefs.flush();
|
||||
name=campaign;
|
||||
AssetLoader.Datahandler.game().setCampaign(levels,name);
|
||||
state=State.pause;
|
||||
state=State.stop;
|
||||
research=0;
|
||||
Transmuters=AssetLoader.allTransmuter;
|
||||
SaveTransmuters();
|
||||
|
@ -563,5 +569,15 @@ public class Worlds extends Actor {
|
|||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void simulate() {
|
||||
if (this.state==State.stop)
|
||||
this.state=State.simulating;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (this.state==State.simulating)
|
||||
this.state=State.stop;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ import fr.evolving.automata.Neutraliser_II;
|
|||
import fr.evolving.automata.Transmuter;
|
||||
import fr.evolving.automata.Transmuter.Angular;
|
||||
import fr.evolving.automata.Transmuter.CaseType;
|
||||
import fr.evolving.automata.Worlds.State;
|
||||
import fr.evolving.automata.Worlds;
|
||||
import fr.evolving.dialogs.PrefWindow;
|
||||
import fr.evolving.dialogs.SavingWindow;
|
||||
|
@ -82,7 +83,6 @@ public class GameScreen implements Screen {
|
|||
private Array<InputProcessor> processors;
|
||||
private float[] speed;
|
||||
private int speedindex;
|
||||
boolean start;
|
||||
private Stage stage, stage_info, stage_tooltip;
|
||||
private Timer RunTimer;
|
||||
private Task RunTask;
|
||||
|
@ -211,9 +211,10 @@ public class GameScreen implements Screen {
|
|||
public void run() {
|
||||
Gdx.app.debug("wirechem-GameScreen", "Cycle particule...");
|
||||
worlds.getLevelData().Grid.Cycle();
|
||||
worlds.getLevelData().Grid.tiling_particle();
|
||||
map.redraw();
|
||||
}
|
||||
};
|
||||
start=false;
|
||||
speed=new float[] {4,2,1,0.5f,0.25f,0.125f,0.0625f};
|
||||
speedindex=2;
|
||||
RunTimer.stop();
|
||||
|
@ -583,7 +584,7 @@ public class GameScreen implements Screen {
|
|||
Gdx.app.debug("wirechem-GameScreen", "Etat extension:" + unroll);
|
||||
if (level.Grid.GetXY(x, y).Copper)
|
||||
Gdx.app.debug("wirechem-GameScreen", "*** Présence de cuivre");
|
||||
if (level.Grid.GetXY(x, y).Fiber > 0)
|
||||
if (level.Grid.GetXY(x, y).Fiber)
|
||||
Gdx.app.debug("wirechem-GameScreen", "*** Présence de fibre");
|
||||
if (level.Grid.GetXY(x, y).Transmuter_calc > 0) {
|
||||
Gdx.app.debug("wirechem-GameScreen", "transmuter deplacement vers origine:"
|
||||
|
@ -680,7 +681,7 @@ public class GameScreen implements Screen {
|
|||
public void map_fiber_eraser(float realx, float realy, int x, int y,
|
||||
boolean alone, int button, calling call) {
|
||||
if (level.Grid.GetXY(x, y).Transmuter_calc == 0 && !level.Grid.GetXY(x, y).Locked) {
|
||||
level.Grid.GetXY(x, y).Fiber = 0;
|
||||
level.Grid.GetXY(x, y).Fiber = false;
|
||||
if (alone) {
|
||||
level.Cout_copperfiber=level.Grid.tiling_copper();
|
||||
map.redraw();
|
||||
|
@ -693,8 +694,7 @@ public class GameScreen implements Screen {
|
|||
if (!worlds.isDebug() && level.Cout<5)
|
||||
return;
|
||||
if (level.Grid.GetXY(x, y).Transmuter_calc == 0 && !level.Grid.GetXY(x, y).Locked)
|
||||
level.Grid.GetXY(x, y).Fiber = -1 * level.Grid.GetXY(x, y).Fiber
|
||||
+ 1;
|
||||
level.Grid.GetXY(x, y).Fiber = !level.Grid.GetXY(x, y).Fiber;
|
||||
if (alone) {
|
||||
level.Cout_copperfiber=level.Grid.tiling_copper();
|
||||
map.redraw();
|
||||
|
@ -706,7 +706,7 @@ public class GameScreen implements Screen {
|
|||
if (!worlds.isDebug() && level.Cout<5)
|
||||
return;
|
||||
if (level.Grid.GetXY(x, y).Transmuter_calc == 0 && !level.Grid.GetXY(x, y).Locked)
|
||||
level.Grid.GetXY(x, y).Fiber = 1;
|
||||
level.Grid.GetXY(x, y).Fiber = true;
|
||||
if (alone) {
|
||||
level.Cout_copperfiber=level.Grid.tiling_copper();
|
||||
map.redraw();
|
||||
|
@ -859,27 +859,27 @@ public class GameScreen implements Screen {
|
|||
}
|
||||
|
||||
public void run_mode() {
|
||||
if (start==false) {
|
||||
if (worlds.getState()==State.stop) {
|
||||
worlds.simulate();
|
||||
Gdx.app.log("wirechem-GameScreen", "***** Mode run.");
|
||||
worlds.getLevelData().Grid.Initialize();
|
||||
worlds.getLevelData().Grid.tiling_particle();
|
||||
RunTimer.start();
|
||||
}
|
||||
start=true;
|
||||
RunTimer.start();
|
||||
}
|
||||
|
||||
public void stop_mode() {
|
||||
Gdx.app.log("wirechem-GameScreen", "***** Mode stop.");
|
||||
worlds.stop();
|
||||
worlds.getLevelData().Grid.Initialize();
|
||||
worlds.getLevelData().Grid.tiling_particle();
|
||||
RunTimer.stop();
|
||||
start=false;
|
||||
}
|
||||
|
||||
public void pause_mode() {
|
||||
Gdx.app.log("wirechem-GameScreen", "***** Mode pause" +
|
||||
".");
|
||||
if (start==false) {
|
||||
if (worlds.getState()==State.stop) {
|
||||
run_mode();
|
||||
}
|
||||
RunTimer.stop();
|
||||
|
@ -1059,7 +1059,7 @@ public class GameScreen implements Screen {
|
|||
}
|
||||
|
||||
public void hideInfo() {
|
||||
if (start) {
|
||||
if (worlds.getState()==State.simulating) {
|
||||
menu.setVisible(false);
|
||||
vertibar.setVisible(false);
|
||||
nextpage.setVisible(false);
|
||||
|
|
Loading…
Reference in New Issue