Archived
Creado un frontend de ejemplo implementando el backend.
Pequeñas pruebas y mejoras.
This commit is contained in:
@@ -1,66 +0,0 @@
|
|||||||
{
|
|
||||||
"RoomName": "testRoom",
|
|
||||||
"RoomSize": {
|
|
||||||
"x": 8,
|
|
||||||
"y": 5
|
|
||||||
},
|
|
||||||
"BackgroundData": [
|
|
||||||
[ 2, 2, 2, 2, 2, 2, 2, 2 ],
|
|
||||||
[ 2, 3, 3, 3, 3, 3, 3, 2 ],
|
|
||||||
[ 2, 3, 3, 3, 3, 3, 3, 2 ],
|
|
||||||
[ 2, 3, 3, 3, 3, 3, 3, 2 ],
|
|
||||||
[ 2, 2, 2, 2, 2, 2, 2, 2 ]
|
|
||||||
],
|
|
||||||
"MaquinasData": [
|
|
||||||
[
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
],
|
|
||||||
[
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
],
|
|
||||||
[
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
],
|
|
||||||
[
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"base_raspi_mk1",
|
|
||||||
"base_raspi_mk1",
|
|
||||||
null
|
|
||||||
],
|
|
||||||
[
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
asdasd
|
||||||
|
asdasd
|
||||||
|
asdasd
|
||||||
|
eso.
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"Refrigeracion": 10,
|
"Refrigeracion": 10,
|
||||||
"Electricidad": 5
|
"Electricidad": 5
|
||||||
},
|
},
|
||||||
"BackGroundTileSet": "BGTiles",
|
"BackGroundTileSet": "testTiles",
|
||||||
"BackgroundData": [
|
"BackgroundData": [
|
||||||
[ 2, 2, 2, 2, 2, 2, 2, 2 ],
|
[ 2, 2, 2, 2, 2, 2, 2, 2 ],
|
||||||
[ 2, 3, 3, 3, 3, 3, 3, 2 ],
|
[ 2, 3, 3, 3, 3, 3, 3, 2 ],
|
||||||
|
|||||||
@@ -7,8 +7,20 @@ public class LoginSystem
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Pertime autentificar a un usuario dado su archivo de datos.
|
||||||
|
* @return True si la autentificación es correcta. False si no.
|
||||||
|
*/
|
||||||
|
public static boolean AutentificarUsuario()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Indica si el usuario se ha autentificado correctamente.
|
||||||
|
* @return true si el usuario está autentificado. False si no lo está.
|
||||||
|
*/
|
||||||
|
public static boolean isIsLogged() { return isLogged; }
|
||||||
|
|
||||||
private static boolean isLogged = false;
|
private static boolean isLogged = false;
|
||||||
|
|
||||||
|
|||||||
@@ -314,6 +314,22 @@ public class Room
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getRoomName() { return roomName; }
|
||||||
|
|
||||||
|
public Vector2 getRoomSize() { return roomSize; }
|
||||||
|
|
||||||
|
public int getEspacioOcupado() { return espacioOcupado; }
|
||||||
|
|
||||||
|
public int getEspacioTotal() { return espacioTotal; }
|
||||||
|
|
||||||
|
public String getTileSetID() { return tileSetID; }
|
||||||
|
|
||||||
|
public int[][] getBgData() { return bgData; }
|
||||||
|
|
||||||
|
public Machine[][] getMachineData() { return machineData; }
|
||||||
|
|
||||||
|
public boolean isEsOnline() { return esOnline; }
|
||||||
|
|
||||||
/*-------------
|
/*-------------
|
||||||
* Variables
|
* Variables
|
||||||
* -------------*/
|
* -------------*/
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class RoomLoader
|
|||||||
loadedRooms = new HashMap<>();
|
loadedRooms = new HashMap<>();
|
||||||
|
|
||||||
mcLoader = null;
|
mcLoader = null;
|
||||||
|
Gdx.app.log("RoomLoader", "Se ha cargado con mcLoader = null");
|
||||||
|
|
||||||
loaderJson = new Json();
|
loaderJson = new Json();
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,16 @@ package uberelectron.testgame;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.utils.Json;
|
import com.badlogic.gdx.utils.Json;
|
||||||
import uberelectron.gameSystems.Machine;
|
import uberelectron.gameSystems.Machine;
|
||||||
import uberelectron.gameSystems.MachineLoader;
|
import uberelectron.gameSystems.MachineLoader;
|
||||||
import uberelectron.gameSystems.Room;
|
import uberelectron.gameSystems.Room;
|
||||||
import uberelectron.gameSystems.RoomLoader;
|
import uberelectron.gameSystems.RoomLoader;
|
||||||
|
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.logging.FileHandler;
|
||||||
|
|
||||||
public class BackEndTest implements Screen
|
public class BackEndTest implements Screen
|
||||||
{
|
{
|
||||||
final testGame game;
|
final testGame game;
|
||||||
@@ -60,7 +64,7 @@ public class BackEndTest implements Screen
|
|||||||
rmLoader.LoadRoomFromJSON(Gdx.files.internal("data/testRoom.json"));
|
rmLoader.LoadRoomFromJSON(Gdx.files.internal("data/testRoom.json"));
|
||||||
|
|
||||||
|
|
||||||
|
rmLoader.SaveRoomToJSON("testRoom", Gdx.files.local("saves/testRoom.json"));
|
||||||
// Room testRoom = new Room("testRoom", 8, 5);
|
// Room testRoom = new Room("testRoom", 8, 5);
|
||||||
// testRoom.AddMachine(3,2, mcLoader.GetMachine("test_mach2"));
|
// testRoom.AddMachine(3,2, mcLoader.GetMachine("test_mach2"));
|
||||||
// testRoom.AddMachine(4,2, mcLoader.GetMachine("base_raspi_mk1"));
|
// testRoom.AddMachine(4,2, mcLoader.GetMachine("base_raspi_mk1"));
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package uberelectron.testgame;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Screen;
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
|
import com.badlogic.gdx.maps.MapLayers;
|
||||||
|
import com.badlogic.gdx.maps.tiled.TiledMap;
|
||||||
|
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
|
||||||
|
import com.badlogic.gdx.maps.tiled.TiledMapTileSet;
|
||||||
|
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
import com.badlogic.gdx.utils.ScreenUtils;
|
||||||
|
import uberelectron.gameSystems.Room;
|
||||||
|
import uberelectron.gameSystems.RoomLoader;
|
||||||
|
|
||||||
|
public class EjemploIntegracion implements Screen
|
||||||
|
{
|
||||||
|
final testGame game;
|
||||||
|
|
||||||
|
final RoomLoader rmLoader;
|
||||||
|
|
||||||
|
|
||||||
|
OrthographicCamera camera;
|
||||||
|
OrthogonalTiledMapRenderer mapRenderer;
|
||||||
|
|
||||||
|
TiledMap map;
|
||||||
|
|
||||||
|
TiledMapTileSet bgTileSet;
|
||||||
|
TiledMapTileSet mcTileSet;
|
||||||
|
|
||||||
|
float tileUnitScale = 6f;
|
||||||
|
|
||||||
|
|
||||||
|
EjemploIntegracion(final testGame game)
|
||||||
|
{
|
||||||
|
this.game = game;
|
||||||
|
|
||||||
|
rmLoader = game.rmLoader;
|
||||||
|
Room rm = rmLoader.GetCurrentRoom();
|
||||||
|
|
||||||
|
bgTileSet = game.tileSetManager.GetTileSet(rm.getTileSetID());
|
||||||
|
//mcTileSet = game.tileSetManager.GetTileSet("mcTiles");
|
||||||
|
|
||||||
|
|
||||||
|
map = new TiledMap();
|
||||||
|
camera = new OrthographicCamera();
|
||||||
|
camera.setToOrtho(false, 800, 480);
|
||||||
|
|
||||||
|
mapRenderer = new OrthogonalTiledMapRenderer(map, tileUnitScale);
|
||||||
|
|
||||||
|
//Metemos los datos en las layers.
|
||||||
|
MapLayers layers = map.getLayers();
|
||||||
|
Vector2 rmSize = rm.getRoomSize();
|
||||||
|
int[][] roomBgData = rm.getBgData();
|
||||||
|
|
||||||
|
TiledMapTileLayer bgLayer = new TiledMapTileLayer((int)rmSize.x, (int)rmSize.y, 8, 8);
|
||||||
|
bgLayer.setName("bgLayer");
|
||||||
|
for(int y = 0; y < rmSize.y; y++)
|
||||||
|
{
|
||||||
|
for(int x = 0; x < rmSize.x; x++)
|
||||||
|
{
|
||||||
|
TiledMapTileLayer.Cell ce = new TiledMapTileLayer.Cell();
|
||||||
|
ce.setTile(bgTileSet.getTile(roomBgData[y][x]));
|
||||||
|
bgLayer.setCell(x, y, ce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
layers.add(bgLayer);
|
||||||
|
|
||||||
|
//Se repetiría lo mismo para la layer de las máquinas.
|
||||||
|
// Hay que comprobar para cada máquina si el TileSet que tenemos es el correcto.
|
||||||
|
// También nos lo podemos saltar, y considerar que en una sala todos tendrán siempre el mismo.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(float delta)
|
||||||
|
{
|
||||||
|
ScreenUtils.clear(0, 0, 0.2f, 1);
|
||||||
|
|
||||||
|
camera.update();
|
||||||
|
mapRenderer.setView(camera);
|
||||||
|
game.batch.setProjectionMatrix(camera.combined);
|
||||||
|
|
||||||
|
game.batch.begin();
|
||||||
|
|
||||||
|
mapRenderer.render();
|
||||||
|
game.batch.end();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resize(int width, int height) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {}
|
||||||
|
}
|
||||||
@@ -2,8 +2,11 @@ package uberelectron.testgame;
|
|||||||
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Game;
|
import com.badlogic.gdx.Game;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import uberelectron.gameSystems.MachineLoader;
|
||||||
|
import uberelectron.gameSystems.RoomLoader;
|
||||||
import uberelectron.gameSystems.TileSetManager;
|
import uberelectron.gameSystems.TileSetManager;
|
||||||
|
|
||||||
public class testGame extends Game
|
public class testGame extends Game
|
||||||
@@ -13,6 +16,8 @@ public class testGame extends Game
|
|||||||
//Texture img;
|
//Texture img;
|
||||||
|
|
||||||
public TileSetManager tileSetManager;
|
public TileSetManager tileSetManager;
|
||||||
|
public MachineLoader mcLoader;
|
||||||
|
public RoomLoader rmLoader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create()
|
public void create()
|
||||||
@@ -20,8 +25,10 @@ public class testGame extends Game
|
|||||||
batch = new SpriteBatch();
|
batch = new SpriteBatch();
|
||||||
font = new BitmapFont();
|
font = new BitmapFont();
|
||||||
tileSetManager = new TileSetManager();
|
tileSetManager = new TileSetManager();
|
||||||
|
mcLoader = new MachineLoader();
|
||||||
|
rmLoader = new RoomLoader(mcLoader);
|
||||||
|
|
||||||
LoadTileSets();
|
LoadAssets();
|
||||||
|
|
||||||
//this.setScreen(new TileMapTest(this));
|
//this.setScreen(new TileMapTest(this));
|
||||||
this.setScreen(new BackEndTest(this));
|
this.setScreen(new BackEndTest(this));
|
||||||
@@ -47,12 +54,20 @@ public class testGame extends Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LoadTileSets()
|
void LoadAssets()
|
||||||
{
|
{
|
||||||
|
//Cargamos los TileSets
|
||||||
tileSetManager.loadTileSet("testTiles.png",
|
tileSetManager.loadTileSet("testTiles.png",
|
||||||
"testTiles",
|
"testTiles",
|
||||||
8, 8);
|
8, 8);
|
||||||
|
|
||||||
|
//Cargamos las máquinas.
|
||||||
|
mcLoader.LoadFromJSON(Gdx.files.internal("data/testMachines.json"));
|
||||||
|
|
||||||
|
//Cargamos las salas.
|
||||||
|
rmLoader.LoadRoomFromJSON(Gdx.files.internal("data/testRoom.json"));
|
||||||
|
|
||||||
|
|
||||||
|
rmLoader.SetCurrentRoom("testRoom");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user