private IHumanPlayer startupGameEnvironment(NewGame newGameDTO) { date.setStartYear(newGameDTO.getStartYear()); GameFactory gameFactory = serverContext.getBean(GameFactory.class); CityFactory cityFactory = serverContext.getBean(CityFactory.class); ShipFactory shipFactory = serverContext.getBean(ShipFactory.class); gameFactory.createMap(newGameDTO.getMapName()); LocationTracker locationTracker = serverContext.getBean(LocationTracker.class); serverContext.getBean(StartNewGameBean.class); IGame game = gameFactory.createGame(newGameDTO.getObjective(), newGameDTO.getDifficulty(), newGameDTO.getSpeed(), newGameDTO.isSingleplayer()); ICity homeCity = cityFactory.createCityByName(newGameDTO.getHometown()); IHumanPlayer player = gameFactory.createPlayer(newGameDTO.getFirstName(), newGameDTO.getLastName(), homeCity, newGameDTO.isMale(), newGameDTO.getDifficulty().getStartingCapital(), EPlayerColor.BLUE); IShip ship = shipFactory.createCrayer(shipNameLoader.getRandomName(), EShipUpgrade.LEVEL1, 350); ship.setOwner(player); player.addShip(ship); player.addSelectableVessel(ship); ship.setLocation(homeCity.getCoordinates()); locationTracker.add(ship); // Start the game server.startGame(game, 1); server.startStandaloneGame(player); serverContext.getBean("startNewGameHandler"); // Force creation of this lazy bean return player; }
/** * Handle the GameStateChange events. * @param stateChange change of the game state */ @Subscribe public void handleGameStateChange(GameStateChange stateChange) { switch (stateChange.getStatusChange()) { case NEW_GAME: handleNewGame((NewGame) stateChange.getStateChangeData()); break; case LOAD_GAME_INIT: final NewGame stateChangeData = (NewGame) stateChange.getStateChangeData(); handleLoadGame(stateChangeData, stateChangeData.isEnvironmentInitialisation()); break; case SHUTDOWN: // This is handeled by the shutdown handler break; case GAME_INITIALISATION_COMPLETE: case GAME_LOADED: // This is handled by the LoadGameScene break; // todo: andi 04/02/14: add event to shut game down and stop threads default: throw new RuntimeException("Status change "+stateChange.getStatusChange()+" is not implemented"); } }
private EventHandler<MouseEvent> createLoadAction() { return event -> { try { NewGame newGameDTO = NewGame.builder() .difficulty(Difficulty.CHANDLER) .firstName("FirstName")
private void handleNewGame(NewGame newGameDTO) { PropertyInitializer propInit = serverContext.getBean(PropertyInitializer.class); propInit.setKeySuffix(newGameDTO.getDifficulty().getLevel()); serverContext.getBean("dependentPropertyInitializer"); // Force initialisation IHumanPlayer player = startupGameEnvironment(newGameDTO); // todo: andi 18/01/14: notify the client so the GameStatus can be updated NewGameClient newGameClientDTO = NewGameClient.builder().player(player).build(); clientServerEventBus.post(new ResumeGame()); clientServerEventBus.post(newGameClientDTO); }
private EventHandler<MouseEvent> createLoadAction() { return event -> { try { NewGame newGameDTO = NewGame.builder() .difficulty(Difficulty.CHANDLER) .firstName("FirstName")
try { if (validInput()) { NewGame newGameDTO = NewGame.builder() .difficulty(Difficulty.fromIndex(difficulty.getSelectedIndex())) .firstName(name.getText())