Package org.gbcpainter.loaders.level.parsers

Examples of org.gbcpainter.loaders.level.parsers.AssertValidGraphParser


    setStatus( LOAD_FILE );
    ByteBuffer buffer = ByteBuffer.wrap( Files.readAllBytes( path ) );

    setStatus( PARSE_DATA );
    FileLevelParser parser = new AssertValidGraphParser();

    parser.parseData( buffer );
    SimpleGraph<Point, Segment> levelMap = parser.getLevelMap();
    Map<Integer, Set<Segment>> rawFacesMap = parser.getFacesMap();
    Point initialPlayerPosition = parser.getPlayerPosition();
    Map<String, java.util.List<Point>> monstersPositions = parser.getMonstersPosition();

    /* Creo i dati di gioco */
    setStatus( DEFINE_LEVEL );
    Player player = factory.createPlayer( initialPlayerPosition );

View Full Code Here


  @Nullable
  private Map<Face, Integer> faces = null;

  public DummyCanvas(@NotNull final String fileName)
  throws IOException, ParsingFailException {
    final FileLevelParser parser = new AssertValidGraphParser();
    File levelsPath = GameSettings.getRelativeDirectory( GameSettings
                                                               .getInstance().getValue(
            GameSettings.STRING_SETTINGS_TYPE.LEVELS_PATH ));


    File levelFile = new File( levelsPath, fileName );
    if ( ! levelFile.canRead() ) {
      for (String extension : COMMON_EXTENSIONS) {
        levelFile = new File( levelsPath, fileName + extension );
        if ( levelFile.canRead() ) {
          break;
        }
      }

    }

    if ( ! levelFile.canRead() ) {
      throw new LevelNotFoundException( "Couldn't find level: " + levelFile
          .getAbsolutePath() );
    }

    Path path = Paths.get( levelFile.getAbsolutePath() );

    ByteBuffer buffer = ByteBuffer.wrap( Files.readAllBytes( path ) );

    parser.parseData( buffer );

    this.levelMap = parser.getLevelMap();
    this.rawFacesMap = parser.getFacesMap();
    this.playerPosition = parser.getPlayerPosition();
    this.monstersPositions = parser.getMonstersPosition();
    this.levelBounds = makeBoundRectangle( this.levelMap );

    this.facesMap = new HashMap<>( this.rawFacesMap.size() );

    for (Map.Entry<Integer, Set<Segment>> faceEntry : this.rawFacesMap.entrySet()) {
View Full Code Here

TOP

Related Classes of org.gbcpainter.loaders.level.parsers.AssertValidGraphParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.