Esempio n. 1
0
  /**
   * Load game.
   *
   * <p>static, meant to provide an easy way to get a GameBoard object without needing to deal with
   * instanciation of saves.
   *
   * <p>requires that the player already be placed on the GameplayElement's GameBoard
   *
   * @param game the GameplayElement into which the game will be loaded
   * @param saveLocation the save location
   * @param targetFloor the target floor
   * @return the game board
   */
  public static void enterNewMap(GameplayElement game, String saveLocation, String targetFloor)
      throws SlickException {
    try {
      BufferedReader r;
      r = new BufferedReader(new FileReader(saveLocation + "/" + targetFloor));

      GameBoard b = loadBoard(game, saveLocation, targetFloor, r);
      game.setBoard(b);
      loadEntities(b, r);
      setPlayerPosition(game.player, b, game.lastMap);

    } catch (FileNotFoundException e) {
      throw new SlickException("f**k", e);
    }
    game.resetCamera();
  }
Esempio n. 2
0
  /**
   * Loads the game. self explanatory. loads player from player file loads board, entities from
   * current map file (loadBoard and LoadEntities are passed the same BufferedReader, because the
   * required data is stored on different lines of the same file)'
   *
   * <p>for initial startup
   *
   * @param state the GameplayElement into which the game will be loaded
   * @throws IOException Signals that an I/O exception has occurred.
   * @throws SlickException the slick exception
   * @throws ClassNotFoundException the class not found exception
   * @throws InstantiationException the instantiation exception
   * @throws IllegalAccessException the illegal access exception
   */
  public void loadGame(GameplayElement state, GameContainer c) throws SlickException {
    try {
      BufferedReader r = new BufferedReader(new FileReader(saveLocation + "/" + currentMap));
      GameBoard g = loadBoard(state, saveLocation, currentMap, r);

      BufferedReader playerReader =
          new BufferedReader(new FileReader(saveLocation + "/player.txt"));
      Player play = loadPlayerStatus(playerReader, c, g, loadPlayerProfession(playerReader));
      setPlayerPosition(play, g, state.lastMap);
      state.setPlayer(play);
      state.saveLocation = this.saveLocation;

      loadEntities(g, r);
      state.setBoard(g);

    } catch (FileNotFoundException e) {
      throw new SlickException("f**k", e);
    } catch (IOException e) {
      throw new SlickException("f**k", e);
    }
  }