Commit d29494f8 authored by Stefano Grisendi's avatar Stefano Grisendi
Browse files

minor changes

parent 5ca49f72
......@@ -23,8 +23,8 @@ public class NetworkController {
this.client = new Client();
client.start();
try {
String IP4_LAN_ADDRESS = "192.168.0.136"; //122 //"192.168.87.20";
client.connect(10000, IP4_LAN_ADDRESS, 54555, 54777);
String IP4_LAN_ADDRESS = "192.168.10.154"; //122 //"192.168.87.20";
client.connect(10000, IP4_LAN_ADDRESS, 20123, 21393);
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -17,7 +17,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.mygdx.game.controllers.PlayerController;
public abstract class View extends ApplicationAdapter {
public abstract class AbstractView extends ApplicationAdapter {
protected OrthographicCamera cam;
protected float[] lastTouch = new float[2];;
......@@ -44,7 +44,7 @@ public abstract class View extends ApplicationAdapter {
protected boolean startFadeIn;
protected Texture fadeOverlayTexture;
protected View(GameViewManager gvm, PlayerController playerController, AssetManager assetManager, Stage stage, Skin skin){
protected AbstractView(GameViewManager gvm, PlayerController playerController, AssetManager assetManager, Stage stage, Skin skin){
this.gvm = gvm;
this.stage = stage;
this.assetManager = assetManager;
......
package com.mygdx.game.views;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
......@@ -28,7 +26,7 @@ import com.mygdx.game.views.tokens.AnimatedSprite;
import java.util.ArrayList;
public class CinematicView extends View{
public class CinematicView extends AbstractView {
private final Image lobbyImage;
private final Image backgroundImage;
......
......@@ -5,23 +5,23 @@ import java.util.Stack;
public class GameViewManager {
private Stack<View> views;
private Stack<AbstractView> views;
public GameViewManager(){
views = new Stack<>();
}
public void push(View view){
views.push(view);
public void push(AbstractView abstractView){
views.push(abstractView);
}
public void pop(){
views.pop();
}
public void set(View view){
public void set(AbstractView abstractView){
views.pop();
views.push(view);
views.push(abstractView);
}
public void handleInput(float dt){
......
......@@ -3,16 +3,14 @@ package com.mygdx.game.views;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.mygdx.game.controllers.PlayerController;
import com.mygdx.game.views.enums.CharacterAssets;
import com.mygdx.game.views.enums.LobbyAssets;
import com.mygdx.game.views.enums.MenuAssets;
public class LoadingView extends View {
public class LoadingView extends AbstractView {
private Image loadingTextImage = new Image(new Texture("Loading/LoadingText.png"));
private Image loadingDotImage = new Image(new Texture("Loading/LoadingDot.png"));
......
......@@ -38,7 +38,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class LobbyView extends View{
public class LobbyView extends AbstractView {
private final ArrayList<Actor> playerUIWidgets = new ArrayList<>();
private final Music currentSong;
......
......@@ -33,7 +33,7 @@ import com.mygdx.game.views.tokens.AnimatedSprite;
import java.util.ArrayList;
import java.util.HashMap;
public class MenuView extends View{
public class MenuView extends AbstractView {
private boolean startFadeFromWhiteToBlank;
private boolean startFadeFromBlankToWhite;
......@@ -81,8 +81,10 @@ public class MenuView extends View{
availableAvatarsHashMap = Constants.AVAILABLEAVATARSHASHMAP;
this.backgroundImage = new Image ((Texture) assetManager.get(MenuAssets.BACKGROUND.path, MenuAssets.BACKGROUND.classType));
backgroundImage.setPosition(Gdx.graphics.getWidth()/2-backgroundImage.getWidth()/2, 0);
backgroundImage.setOrigin(0,0);
//backgroundImage.setPosition(Gdx.graphics.getWidth()/2-backgroundImage.getWidth()/2, 0);
//backgroundImage.setOrigin(0,0);
backgroundImage.setPosition(0, 0);
backgroundImage.setSize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
formImage = new Image((Texture) assetManager.get(MenuAssets.FORM.path, MenuAssets.FORM.classType));
formImage.setPosition(col_width*6-formImage.getWidth()/2, row_height*0.15f);
......
......@@ -8,7 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.mygdx.game.controllers.PlayerController;
public class PauseView extends View{
public class PauseView extends AbstractView {
private Texture background;
private Texture playBtn;
......
......@@ -13,13 +13,11 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Scaling;
import com.mygdx.game.Constants;
import com.mygdx.game.controllers.GameController;
import com.mygdx.game.controllers.PlayerController;
import com.mygdx.game.controllers.UtilsKt;
import com.mygdx.game.model.Lobby;
import com.mygdx.game.model.Player;
import com.mygdx.game.views.enums.PlayAssets;
import com.mygdx.game.views.tokens.AnimatedSprite;
......@@ -30,10 +28,8 @@ import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import static com.badlogic.gdx.scenes.scene2d.InputEvent.Type.touchDown;
public class PlayView extends View{
public class PlayView extends AbstractView {
int Help_Guides = 12;
int row_height = Gdx.graphics.getHeight() / Help_Guides;
......
......@@ -2,18 +2,10 @@ package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryonet.Connection;
import com.esotericsoftware.kryonet.Listener;
import com.esotericsoftware.kryonet.Server;
import com.mygdx.game.controller.NetworkController;
import java.io.IOException;
import com.mygdx.game.controller.ServerController;
public class UniCheckersServer extends ApplicationAdapter {
SpriteBatch batch;
......@@ -23,7 +15,7 @@ public class UniCheckersServer extends ApplicationAdapter {
public void create () {
batch = new SpriteBatch();
img = new Texture("ServerBackground.png");
NetworkController networkController = new NetworkController();
ServerController serverController = new ServerController();
}
@Override
......
......@@ -11,11 +11,10 @@ import com.mygdx.game.model.Player;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
public class NetworkController {
public class ServerController {
private final int MAX_PLAYERS = 8;
private final int MAX_LOBBIES = 40;
......@@ -27,11 +26,11 @@ public class NetworkController {
private Server server;
private Kryo kryo;
public NetworkController(){
public ServerController(){
server = new Server();
server.start();
try {
server.bind(54555, 54777);
server.bind(54555);
} catch (IOException e) {
e.printStackTrace();
}
......@@ -165,7 +164,7 @@ public class NetworkController {
kryo.register(List.class, 30);
}
public NetworkController getNetworkController() { return this; }
public ServerController getNetworkController() { return this; }
public ArrayList<Connection> getConnections(Lobby lobby){
HashSet<Integer> players_id = lobby.getPlayersID();
......
package com.mygdx.game.controller.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.controller.ServerController;
public class Command{
......@@ -18,7 +18,7 @@ public class Command{
this.data = "None";
}
public void execute(NetworkController net, Connection connection){}
public void execute(ServerController net, Connection connection){}
public String getText(){ return text; }
......
package com.mygdx.game.controller.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.controller.commands.Command;
import com.mygdx.game.controller.ServerController;
import com.mygdx.game.model.Lobby;
import com.mygdx.game.model.Player;
import java.util.ArrayList;
......@@ -15,7 +13,7 @@ public class cLobbyCreate extends Command {
//public cLobbyCreate(int MAX_PLAYERS) { super("cLobbyCreate", (Integer) MAX_PLAYERS); }
@Override
public void execute(NetworkController net, Connection connection){
public void execute(ServerController net, Connection connection){
if(data instanceof ArrayList){
String name = (String) ((ArrayList) data).get(0);
int MAX_PLAYERS = (int) ((ArrayList) data).get(1);
......
package com.mygdx.game.controller.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.controller.ServerController;
import com.mygdx.game.model.Lobby;
import java.util.HashSet;
public class cLobbyDelete extends Command{
public cLobbyDelete() { super("cLobbyDelete"); }
@Override
public void execute(NetworkController net, Connection connection){
public void execute(ServerController net, Connection connection){
if(data instanceof Integer) {
int lobby_id = (int) data;
Lobby lobby = net.getLobby(lobby_id);
......
package com.mygdx.game.controller.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.controller.ServerController;
import com.mygdx.game.model.Lobby;
import com.mygdx.game.model.Player;
import java.util.ArrayList;
import java.util.List;
......@@ -13,7 +12,7 @@ public class cLobbyGetList extends Command{
public cLobbyGetList(){ super("cLobbyGetList"); }
@Override
public void execute(NetworkController net, Connection connection){
public void execute(ServerController net, Connection connection){
data = net.getLobbies();
// Exclude lobbies where game has already started
......
package com.mygdx.game.controller.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.controller.ServerController;
import com.mygdx.game.model.Lobby;
public class cLobbyJoin extends Command{
......@@ -11,7 +11,7 @@ public class cLobbyJoin extends Command{
//public cLobbyJoin(int id) { super("cLobbyJoin", (Integer) id); }
@Override
public void execute(NetworkController net, Connection connection){
public void execute(ServerController net, Connection connection){
if(data instanceof Integer){
int lobby_id = (int) data;
data = net.joinLobby(connection.getID(), lobby_id);
......
package com.mygdx.game.controller.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.controller.ServerController;
import com.mygdx.game.model.Lobby;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
public class cLobbyLeave extends Command{
......@@ -18,7 +17,7 @@ public class cLobbyLeave extends Command{
public cLobbyLeave(Lobby lobby) { super("cLobbyLeave", lobby); }
@Override
public void execute(NetworkController net, Connection connection){
public void execute(ServerController net, Connection connection){
if (data instanceof ArrayList) {
List<Object> receivedData = (ArrayList<Object>) data;
......
package com.mygdx.game.controller.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.controller.ServerController;
import com.mygdx.game.model.Player;
import java.io.PrintStream;
public class cPlayerJoin extends Command {
public cPlayerJoin() {
......@@ -13,7 +11,7 @@ public class cPlayerJoin extends Command {
}
@Override
public void execute(NetworkController net, Connection connection){
public void execute(ServerController net, Connection connection){
if (data instanceof Integer){
int indexAvatar = (int) data;
data = net.playerJoin(connection.getID(), indexAvatar);
......
package com.mygdx.game.controller.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.controller.ServerController;
// THIS SHOULD PROBABLY BE AN INPUT COMMAND, AND NOT A NETWORK COMMAND. MAYBE SPLIT NON-NETWORKING COMMANDS ETC.
public class cPlayerPieceClick extends Command {
......@@ -11,7 +11,7 @@ public class cPlayerPieceClick extends Command {
}
@Override
public void execute(NetworkController net, Connection connection){
public void execute(ServerController net, Connection connection){
}
}
......@@ -2,7 +2,7 @@ package com.mygdx.game.controller.commands;
import com.badlogic.gdx.math.Vector3;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.controller.ServerController;
import java.util.ArrayList;
......@@ -33,7 +33,7 @@ public class cPlayerPieceMove extends Command {
}*/
@Override
public void execute(NetworkController net, Connection connection){
public void execute(ServerController net, Connection connection){
if (data instanceof ArrayList) {
System.out.println("Checking if valid move.. If valid, moving player piece from A to B... Updating model.. Sending move to clients....");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment