@Override protected Node fetchNextOrNull() { while (true) { Relationship nextRel = fetchNextRelOrNull(); if (nextRel == null) { return null; } if (!hitDecider.canVisitRelationship(sharedVisitedRels, nextRel)) { continue; } Node result = nextRel.getOtherNode(this.lastParentTraverserNode); LevelData levelData = this.visitedNodes.get(result); boolean createdLevelData = false; if (levelData == null) { levelData = new LevelData(nextRel, this.currentDepth); this.visitedNodes.put(result, levelData); createdLevelData = true; } if (this.currentDepth == levelData.depth && !createdLevelData) { levelData.addRel(nextRel); } // Was this leveldata created right now, i.e. have we visited this node before? // In that case don't add it as next node to traverse if (!createdLevelData) { continue; } this.nextNodes.add(result); return result; } }
/** * Change the level for the game. The new level is written to the space, so the other players can * download it if they don't have it. * * @param newData LevelData */ public void setLevelData(LevelData newData) { if (!java.util.Arrays.equals(newData.getCheckSum(), levelCheckSum) || !newData.getLevelDir().equals(levelDir)) { levelDir = newData.getLevelDir(); levelCheckSum = newData.getCheckSum(); } System.out.println("setLevelData: Daten in Space speichern " + levelDir + " " + levelCheckSum); }
private OutputStream getLevelDataOutputStream(LevelData levelData) throws FileNotFoundException { Chapter chapter = levelData.getChapter(); return getLevelResourceFileAsOutputStream( chapter.getPlayMode().getLevelFolderName() + "/" + chapter.getFolderName() + "/" + levelData.getLevelFileName()); }
public LevelData saveLevelData(LevelData levelData) throws FileNotFoundException { PrintWriter writer = new PrintWriter(getLevelDataOutputStream(levelData)); writer.print(levelData.getLevelDataJSON()); writer.close(); String fileName = levelData.getLevelFileName(); Chapter chapter = levelData.getChapter(); for (int i = 0; i < chapter.getLevelDataList().size(); i++) { if (chapter.getLevelDataList().get(i).getLevelFileName().equals(fileName)) { chapter.getLevelDataList().remove(i); chapter.getLevelDataList().add(i, levelData); break; } } return levelData; }
/** * Start a rendering job for specified {@link Chapter}. The job will sequentially render a * thumbnail one by one, starting from the first {@link LevelData}. * * @param chapter a {@link Chapter} that all of its {@link LevelData}'s thumbnail images will be * rendered. */ protected static void startRenderThumbnail(Chapter chapter) { // if (!chapter.isRenderingJobStarted()) { chapter.setRenderingJobStarted(true); System.out.println( "Thumbnail rendering job of chapter \"" + chapter.getChapterName() + "\" has started"); RendererRunnable previousJob = null; for (LevelData level : chapter.getLevelDataList()) { if (!level.isThumbnailRenderJobOccupied()) { level.setThumbnailRenderJobOccupied(); previousJob = new RendererRunnable(level, previousJob); new Thread(previousJob).start(); } } // } }
public Scene getNextLevelPlayScene(LevelData currentLevel) { Chapter chapter = currentLevel.getChapter(); List<LevelData> levelList = chapter.getLevelDataList(); if (levelList.indexOf(currentLevel) < levelList.size() - 1) { // Not last level return new PlayScene(levelList.get(levelList.indexOf(currentLevel) + 1)); } else { List<Chapter> chapterList = (currentLevel.getPlayerCount() == 1) ? singlePlayerChapterList : coopModeChapterList; int i = chapterList.indexOf(chapter) + 1; while (i < chapterList.size()) { if (!chapterList.get(i).isUserFolder() && chapterList.get(i).getLevelDataList().size() > 0) { return new PlayScene(chapterList.get(i).getLevelDataList().get(0)); } i++; } } return new MainMenuScene(false); }