/** Attempt to join a game. */ private void attemptJoin() { mainGame.killMultiplayer(); mainGame.setLanMultiplayer(true); processPlayerClient(); mainGame.resetLifeCount(); mainGame.resetLevelCount(); mainGame.setScore(0); Client client = new Client(ipField.getText(), MainGame.getMultiplayerPort(), mainGame, gameState); mainGame.spawnClient(client); mainGame.setIsClient(true); mainGame.setIsHost(false); Logger.getInstance().log("Client started", Logger.PriorityLevels.VERYHIGH, "multiplayer"); }
/** Prepare players for the client's viewpoint. */ private void processPlayerClient() { mainGame.getPlayerList().getPlayers().get(1).setPlayerName(nameField.getText()); mainGame.getPlayerList().getPlayers().get(1).setControlsForPlayer1(); mainGame.getPlayerList().getPlayers().get(0).setControlsDisabled(); }