private void addPlayer(Connection connection) { final int roomId = 100; connection.sendTCP(new PacketNewConnection(nextPlayerId, roomId)); // We'd like to send all roomData to client but we're having issues with serialization // connection.sendTCP(new PacketGameData(roomControllerMap.values())); final GameCharacter newPlayer = loadPlayer("StandardPlayer", new Vector2D(200, 300), nextPlayerId); game.addPlayer(newPlayer); final CharacterController playerController = new CharacterController(newPlayer); networkServer.addListener(playerController); playerController.setServer(networkServer); roomControllerMap.get(roomId).addCharacter(playerController); networkServer.sendTCP(new PacketNewCharacter(roomId, newPlayer)); nextPlayerId++; }
public void init(GameContainer gameContainer) throws SlickException { final RoomFactory roomFactory = new RoomFactory(); final List<Room> rooms = roomFactory.getRooms(); game.setMap(rooms); roomFactory.getDoorHandler().addListener(new DoorController(networkServer, roomControllerMap)); initRooms(rooms); networkServer.start(this); }
public void closeRequested() { networkServer.closeRequested(); }