Refactoring to allow MyNewLevelGenerator to determine the level type, difficulty and music based on the player metrics.
Work in progress.
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
package dk.itu.mario.MarioInterface;
|
package dk.itu.mario.MarioInterface;
|
||||||
|
|
||||||
import java.io.File;
|
import dk.itu.mario.engine.DataRecorder;
|
||||||
|
|
||||||
|
public interface LevelGenerator {
|
||||||
public interface LevelGenerator {
|
public int generateLevelDifficulty (GamePlay playerMetrics, DataRecorder detailedInfo);
|
||||||
|
public int generateLevelType (GamePlay playerMetrics, DataRecorder detailedInfo);
|
||||||
//Use one of these methods to generate your level
|
|
||||||
|
|
||||||
public LevelInterface generateLevel (GamePlay playerMetrics);
|
public LevelInterface generateLevel (GamePlay playerMetrics);
|
||||||
public LevelInterface generateLevel (String detailedInfo);
|
public LevelInterface generateLevel (String detailedInfo);
|
||||||
|
public LevelInterface generateLevel (GamePlay playerMetrics, DataRecorder detailedInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,14 @@ import dk.itu.mario.level.RandomLevel;
|
|||||||
import dk.itu.mario.scene.LevelScene;
|
import dk.itu.mario.scene.LevelScene;
|
||||||
|
|
||||||
public class DataRecorder {
|
public class DataRecorder {
|
||||||
|
public static final DataRecorder BLANK_RECORD = new DataRecorder();
|
||||||
|
|
||||||
public boolean recording = true;
|
public boolean recording = true;
|
||||||
|
private boolean []keys, keyPressed;
|
||||||
|
|
||||||
@XStreamOmitField
|
@XStreamOmitField
|
||||||
private RandomLevel level;
|
private RandomLevel level;
|
||||||
private boolean []keys, keyPressed;
|
|
||||||
@XStreamOmitField
|
@XStreamOmitField
|
||||||
private LevelScene levelScene;
|
private LevelScene levelScene;
|
||||||
|
|
||||||
@@ -111,6 +114,12 @@ public class DataRecorder {
|
|||||||
return detailedLog;
|
return detailedLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For use by BLANK_RECORD
|
||||||
|
*/
|
||||||
|
private DataRecorder() {;
|
||||||
|
}
|
||||||
|
|
||||||
public DataRecorder(LevelScene levelScene, RandomLevel level, boolean []keys){
|
public DataRecorder(LevelScene levelScene, RandomLevel level, boolean []keys){
|
||||||
this.levelScene = levelScene;
|
this.levelScene = levelScene;
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
|||||||
@@ -34,22 +34,21 @@ import dk.itu.mario.scene.WinScene;
|
|||||||
|
|
||||||
public class MarioComponent extends JComponent implements Runnable,
|
public class MarioComponent extends JComponent implements Runnable,
|
||||||
KeyListener, FocusListener, MouseListener {
|
KeyListener, FocusListener, MouseListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = 739318775993206607L;
|
private static final long serialVersionUID = 739318775993206607L;
|
||||||
|
|
||||||
public static final int TICKS_PER_SECOND = 24;
|
public static final int TICKS_PER_SECOND = 24;
|
||||||
|
|
||||||
public static final int EVOLVE_VERSION = 4;
|
public static final int EVOLVE_VERSION = 4;
|
||||||
public static final int GAME_VERSION = 4;
|
public static final int GAME_VERSION = 4;
|
||||||
|
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
private boolean screenshotTaken = false;
|
private boolean screenshotTaken = false;
|
||||||
private int width, height;
|
|
||||||
private GraphicsConfiguration graphicsConfiguration;
|
|
||||||
private Scene scene;
|
|
||||||
private SonarSoundEngine sound;
|
|
||||||
private boolean useScale2x = false;
|
private boolean useScale2x = false;
|
||||||
private boolean isCustom = false;
|
private boolean isCustom = false;
|
||||||
|
private int width, height;
|
||||||
|
private GraphicsConfiguration graphicsConfiguration;
|
||||||
private LevelGenerator levelGenerator;
|
private LevelGenerator levelGenerator;
|
||||||
|
private Scene scene;
|
||||||
|
private SonarSoundEngine sound;
|
||||||
private Scale2x scale2x = new Scale2x(320, 240);
|
private Scale2x scale2x = new Scale2x(320, 240);
|
||||||
|
|
||||||
public MarioComponent(int width, int height, boolean isCustomized,
|
public MarioComponent(int width, int height, boolean isCustomized,
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ import java.util.Random;
|
|||||||
import dk.itu.mario.MarioInterface.Constraints;
|
import dk.itu.mario.MarioInterface.Constraints;
|
||||||
import dk.itu.mario.MarioInterface.GamePlay;
|
import dk.itu.mario.MarioInterface.GamePlay;
|
||||||
import dk.itu.mario.MarioInterface.LevelInterface;
|
import dk.itu.mario.MarioInterface.LevelInterface;
|
||||||
|
import dk.itu.mario.engine.DataRecorder;
|
||||||
import dk.itu.mario.engine.sprites.Enemy;
|
import dk.itu.mario.engine.sprites.Enemy;
|
||||||
import dk.itu.mario.engine.sprites.SpriteTemplate;
|
import dk.itu.mario.engine.sprites.SpriteTemplate;
|
||||||
|
|
||||||
public class CustomizedLevel extends Level implements LevelInterface {
|
public class CustomizedLevel extends Level implements LevelInterface {
|
||||||
|
|
||||||
Random random;
|
|
||||||
|
|
||||||
private static final int ODDS_STRAIGHT = 0;
|
private static final int ODDS_STRAIGHT = 0;
|
||||||
private static final int ODDS_HILL_STRAIGHT = 1;
|
private static final int ODDS_HILL_STRAIGHT = 1;
|
||||||
private static final int ODDS_TUBES = 2;
|
private static final int ODDS_TUBES = 2;
|
||||||
@@ -19,25 +17,38 @@ public class CustomizedLevel extends Level implements LevelInterface {
|
|||||||
private static final int ODDS_CANNONS = 4;
|
private static final int ODDS_CANNONS = 4;
|
||||||
private static final int JumpingThreshold = 3;
|
private static final int JumpingThreshold = 3;
|
||||||
|
|
||||||
|
private DataRecorder dataRecorder;
|
||||||
|
private GamePlay playerM;
|
||||||
private int[] odds = new int[5];
|
private int[] odds = new int[5];
|
||||||
private int totalOdds;
|
private int totalOdds;
|
||||||
|
|
||||||
private int difficulty;
|
private int difficulty;
|
||||||
private int type;
|
private int type;
|
||||||
private int gaps;
|
private int gaps;
|
||||||
private int turtles;
|
private int turtles;
|
||||||
private int coins;
|
private int coins;
|
||||||
|
private Random random;
|
||||||
|
|
||||||
private GamePlay playerM;
|
public CustomizedLevel(int width, int height, long seed, int difficulty,
|
||||||
|
int type, GamePlay playerMetrics, DataRecorder dataRecorder) {
|
||||||
|
super(width, height);
|
||||||
|
System.out.println("Generating level based on previous GamePlay AND DataRecorder metrics.");
|
||||||
|
this.dataRecorder = dataRecorder;
|
||||||
|
this.playerM = playerMetrics;
|
||||||
|
create(seed, difficulty, type);
|
||||||
|
}
|
||||||
|
|
||||||
public CustomizedLevel(int width, int height, long seed, int difficulty,
|
public CustomizedLevel(int width, int height, long seed, int difficulty,
|
||||||
int type, GamePlay playerMetrics) {
|
int type, GamePlay playerMetrics) {
|
||||||
super(width, height);
|
super(width, height);
|
||||||
|
System.out.println("Generating level based on previous GamePlay metrics ONLY.");
|
||||||
this.playerM = playerMetrics;
|
this.playerM = playerMetrics;
|
||||||
creat(seed, difficulty, type);
|
create(seed, difficulty, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void creat(long seed, int difficulty, int type) {
|
public void create(long seed, int difficulty, int type) {
|
||||||
|
if (dataRecorder == DataRecorder.BLANK_RECORD) {
|
||||||
|
System.out.println("DataRecorder record is BLANK - using GamePlay metrics only.");
|
||||||
|
}
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.difficulty = difficulty;
|
this.difficulty = difficulty;
|
||||||
odds[ODDS_STRAIGHT] = 30;
|
odds[ODDS_STRAIGHT] = 30;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
import dk.itu.mario.MarioInterface.GamePlay;
|
import dk.itu.mario.MarioInterface.GamePlay;
|
||||||
import dk.itu.mario.MarioInterface.LevelInterface;
|
import dk.itu.mario.MarioInterface.LevelInterface;
|
||||||
|
import dk.itu.mario.engine.DataRecorder;
|
||||||
import dk.itu.mario.engine.sprites.Enemy;
|
import dk.itu.mario.engine.sprites.Enemy;
|
||||||
import dk.itu.mario.engine.sprites.SpriteTemplate;
|
import dk.itu.mario.engine.sprites.SpriteTemplate;
|
||||||
|
|
||||||
@@ -15,21 +16,20 @@ public class MyNewLevel extends Level {
|
|||||||
|
|
||||||
public static long lastSeed;
|
public static long lastSeed;
|
||||||
private static Random levelSeedRandom = new Random();
|
private static Random levelSeedRandom = new Random();
|
||||||
|
|
||||||
public int BLOCKS_COINS = 0; // the number of coin blocks
|
public int BLOCKS_COINS = 0; // the number of coin blocks
|
||||||
public int BLOCKS_EMPTY = 0; // the number of empty blocks
|
public int BLOCKS_EMPTY = 0; // the number of empty blocks
|
||||||
|
|
||||||
public int BLOCKS_POWER = 0; // the number of power blocks
|
public int BLOCKS_POWER = 0; // the number of power blocks
|
||||||
public int COINS = 0; // These are the coins in boxes that Mario collect
|
public int COINS = 0; // These are the coins in boxes that Mario collect
|
||||||
|
|
||||||
|
private DataRecorder dataRecorder;
|
||||||
|
private int difficulty;
|
||||||
// Store information about the level
|
// Store information about the level
|
||||||
public int ENEMIES = 0; // the number of enemies the level contains
|
public int ENEMIES = 0; // the number of enemies the level contains
|
||||||
|
|
||||||
private int difficulty;
|
|
||||||
private int gaps;
|
private int gaps;
|
||||||
private int type;
|
private int type;
|
||||||
|
private Random random;
|
||||||
Random random;
|
|
||||||
|
|
||||||
public MyNewLevel(int width, int height) {
|
public MyNewLevel(int width, int height) {
|
||||||
super(width, height);
|
super(width, height);
|
||||||
}
|
}
|
||||||
@@ -37,9 +37,23 @@ public class MyNewLevel extends Level {
|
|||||||
public MyNewLevel(int width, int height, long seed, int difficulty,
|
public MyNewLevel(int width, int height, long seed, int difficulty,
|
||||||
int type, GamePlay playerMetrics) {
|
int type, GamePlay playerMetrics) {
|
||||||
this(width, height);
|
this(width, height);
|
||||||
creat(seed, difficulty, type);
|
|
||||||
|
System.out.println("Generating level based on previous GamePlay metrics ONLY.");
|
||||||
|
this.dataRecorder = DataRecorder.BLANK_RECORD;
|
||||||
|
|
||||||
|
create(seed, difficulty, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MyNewLevel(int width, int height, long seed, int difficulty,
|
||||||
|
int type, GamePlay playerMetrics, DataRecorder dataRecorder) {
|
||||||
|
this(width, height);
|
||||||
|
|
||||||
|
System.out.println("Generating level based on previous GamePlay AND DataRecorder metrics.");
|
||||||
|
this.dataRecorder = dataRecorder;
|
||||||
|
|
||||||
|
create(seed, difficulty, type);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RandomLevel clone() throws CloneNotSupportedException {
|
public RandomLevel clone() throws CloneNotSupportedException {
|
||||||
|
|
||||||
@@ -65,7 +79,11 @@ public class MyNewLevel extends Level {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void creat(long seed, int difficulty, int type) {
|
public void create(long seed, int difficulty, int type) {
|
||||||
|
if (dataRecorder == DataRecorder.BLANK_RECORD) {
|
||||||
|
System.out.println("DataRecorder record is BLANK - using GamePlay metrics only.");
|
||||||
|
}
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.difficulty = difficulty;
|
this.difficulty = difficulty;
|
||||||
|
|
||||||
@@ -234,7 +252,7 @@ public class MyNewLevel extends Level {
|
|||||||
int length = random.nextInt(maxLength - 19) + 20;
|
int length = random.nextInt(maxLength - 19) + 20;
|
||||||
int soFar = 0;
|
int soFar = 0;
|
||||||
int next;
|
int next;
|
||||||
MazeLevel last = MazeLevel.BOT;
|
//MazeLevel last = MazeLevel.BOT;
|
||||||
|
|
||||||
class Stretch {
|
class Stretch {
|
||||||
public int len;
|
public int len;
|
||||||
@@ -314,7 +332,7 @@ public class MyNewLevel extends Level {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last = str.lvl;
|
//last = str.lvl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
|
|||||||
@@ -5,21 +5,41 @@ import java.util.Random;
|
|||||||
import dk.itu.mario.MarioInterface.GamePlay;
|
import dk.itu.mario.MarioInterface.GamePlay;
|
||||||
import dk.itu.mario.MarioInterface.LevelGenerator;
|
import dk.itu.mario.MarioInterface.LevelGenerator;
|
||||||
import dk.itu.mario.MarioInterface.LevelInterface;
|
import dk.itu.mario.MarioInterface.LevelInterface;
|
||||||
|
import dk.itu.mario.engine.DataRecorder;
|
||||||
import dk.itu.mario.level.CustomizedLevel;
|
import dk.itu.mario.level.CustomizedLevel;
|
||||||
|
import dk.itu.mario.level.Level;
|
||||||
|
|
||||||
public class CustomizedLevelGenerator implements LevelGenerator {
|
public class CustomizedLevelGenerator implements LevelGenerator {
|
||||||
|
@Override
|
||||||
|
public int generateLevelDifficulty(GamePlay playerMetrics, DataRecorder dataRecorder) {
|
||||||
|
System.out.println("Generating level difficulty based on playerMetrics, dataRecorder: 1");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LevelInterface generateLevel(GamePlay playerMetrics) {
|
public LevelInterface generateLevel(GamePlay playerMetrics) {
|
||||||
System.out.println("Generating customized level");
|
System.out.println("Generating customized level");
|
||||||
LevelInterface level = new CustomizedLevel(320, 15,
|
LevelInterface level = new CustomizedLevel(320, 15,
|
||||||
new Random().nextLong(), 1, 1, playerMetrics);
|
new Random().nextLong(), 1, 1, playerMetrics);
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LevelInterface generateLevel(GamePlay playerMetrics, DataRecorder dataRecorder) {
|
||||||
|
System.out.println("Generating customized level");
|
||||||
|
LevelInterface level = new CustomizedLevel(320, 15,
|
||||||
|
new Random().nextLong(), 1, 1, playerMetrics, dataRecorder);
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LevelInterface generateLevel(String detailedInfo) {
|
public LevelInterface generateLevel(String detailedInfo) {
|
||||||
// TODO Auto-generated method stub
|
throw new UnsupportedOperationException("Level generation from DataRecorder String not implemented.");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public int generateLevelType(GamePlay playerMetrics, DataRecorder dataRecorder) {
|
||||||
|
System.out.println("Generating level type based on playerMetrics, dataRecorder: TYPE_OVERGROUND");
|
||||||
|
return Level.TYPE_OVERGROUND;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,23 +5,42 @@ import java.util.Random;
|
|||||||
import dk.itu.mario.MarioInterface.GamePlay;
|
import dk.itu.mario.MarioInterface.GamePlay;
|
||||||
import dk.itu.mario.MarioInterface.LevelGenerator;
|
import dk.itu.mario.MarioInterface.LevelGenerator;
|
||||||
import dk.itu.mario.MarioInterface.LevelInterface;
|
import dk.itu.mario.MarioInterface.LevelInterface;
|
||||||
import dk.itu.mario.level.MyLevel;
|
import dk.itu.mario.engine.DataRecorder;
|
||||||
|
import dk.itu.mario.level.Level;
|
||||||
import dk.itu.mario.level.MyNewLevel;
|
import dk.itu.mario.level.MyNewLevel;
|
||||||
|
|
||||||
public class MyNewLevelGenerator extends CustomizedLevelGenerator implements
|
public class MyNewLevelGenerator implements
|
||||||
LevelGenerator {
|
LevelGenerator {
|
||||||
|
@Override
|
||||||
|
public int generateLevelDifficulty(GamePlay playerMetrics, DataRecorder dataRecorder) {
|
||||||
|
System.out.println("Generating level difficulty based on playerMetrics, dataRecorder: 1");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int generateLevelType(GamePlay playerMetrics, DataRecorder dataRecorder) {
|
||||||
|
System.out.println("Generating level type based on playerMetrics, dataRecorder: TYPE_OVERGROUND");
|
||||||
|
return Level.TYPE_OVERGROUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LevelInterface generateLevel(GamePlay playerMetrics) {
|
public LevelInterface generateLevel(GamePlay playerMetrics) {
|
||||||
System.out.println("Generating my new level");
|
System.out.println("Generating customized level");
|
||||||
LevelInterface level = new MyNewLevel(320, 15, new Random().nextLong(), 1,
|
LevelInterface level = new MyNewLevel(320, 15,
|
||||||
LevelInterface.TYPE_OVERGROUND, playerMetrics);
|
new Random().nextLong(), generateLevelDifficulty(playerMetrics,DataRecorder.BLANK_RECORD), generateLevelType(playerMetrics,DataRecorder.BLANK_RECORD), playerMetrics);
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LevelInterface generateLevel(GamePlay playerMetrics, DataRecorder dataRecorder) {
|
||||||
|
System.out.println("Generating customized level");
|
||||||
|
LevelInterface level = new MyNewLevel(320, 15,
|
||||||
|
new Random().nextLong(), generateLevelDifficulty(playerMetrics,DataRecorder.BLANK_RECORD), generateLevelType(playerMetrics,dataRecorder), playerMetrics, dataRecorder);
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LevelInterface generateLevel(String detailedInfo) {
|
public LevelInterface generateLevel(String detailedInfo) {
|
||||||
// TODO Auto-generated method stub
|
throw new UnsupportedOperationException("Level generation from DataRecorder String not implemented.");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ public class LevelScene extends Scene implements SpriteContext {
|
|||||||
|
|
||||||
protected long levelSeed;
|
protected long levelSeed;
|
||||||
protected MarioComponent marioComponent;
|
protected MarioComponent marioComponent;
|
||||||
protected int levelType;
|
//protected int levelType;
|
||||||
protected int levelDifficulty;
|
//protected int levelDifficulty;
|
||||||
|
|
||||||
public static DataRecorder recorder;
|
public static DataRecorder recorder;
|
||||||
|
|
||||||
@@ -66,12 +66,12 @@ public class LevelScene extends Scene implements SpriteContext {
|
|||||||
private int xArrow, yArrow;
|
private int xArrow, yArrow;
|
||||||
|
|
||||||
public LevelScene(GraphicsConfiguration graphicsConfiguration,
|
public LevelScene(GraphicsConfiguration graphicsConfiguration,
|
||||||
MarioComponent renderer, long seed, int levelDifficulty, int type) {
|
MarioComponent renderer, long seed/*, int levelDifficulty, int type*/) {
|
||||||
this.graphicsConfiguration = graphicsConfiguration;
|
this.graphicsConfiguration = graphicsConfiguration;
|
||||||
this.levelSeed = seed;
|
this.levelSeed = seed;
|
||||||
this.marioComponent = renderer;
|
this.marioComponent = renderer;
|
||||||
this.levelDifficulty = levelDifficulty;
|
//this.levelDifficulty = levelDifficulty;
|
||||||
this.levelType = type;
|
//this.levelType = type;
|
||||||
|
|
||||||
widthArrow = 25;
|
widthArrow = 25;
|
||||||
tipWidthArrow = 10;
|
tipWidthArrow = 10;
|
||||||
@@ -282,7 +282,7 @@ public class LevelScene extends Scene implements SpriteContext {
|
|||||||
|
|
||||||
private DecimalFormat df = new DecimalFormat("00");
|
private DecimalFormat df = new DecimalFormat("00");
|
||||||
private DecimalFormat df2 = new DecimalFormat("000");
|
private DecimalFormat df2 = new DecimalFormat("000");
|
||||||
|
|
||||||
public void render(Graphics g, float alpha) {
|
public void render(Graphics g, float alpha) {
|
||||||
int xCam = (int) (mario.xOld + (mario.x - mario.xOld) * alpha) - 160;
|
int xCam = (int) (mario.xOld + (mario.x - mario.xOld) * alpha) - 160;
|
||||||
int yCam = (int) (mario.yOld + (mario.y - mario.yOld) * alpha) - 120;
|
int yCam = (int) (mario.yOld + (mario.y - mario.yOld) * alpha) - 120;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class LevelSceneCustom extends LevelScene {
|
|||||||
public LevelSceneCustom(GraphicsConfiguration graphicsConfiguration,
|
public LevelSceneCustom(GraphicsConfiguration graphicsConfiguration,
|
||||||
MarioComponent renderer, long seed, int levelDifficulty, int type,
|
MarioComponent renderer, long seed, int levelDifficulty, int type,
|
||||||
boolean isCustom, LevelGenerator levelGenerator) {
|
boolean isCustom, LevelGenerator levelGenerator) {
|
||||||
super(graphicsConfiguration, renderer, seed, levelDifficulty, type);
|
super(graphicsConfiguration, renderer, seed/*, levelDifficulty, type*/);
|
||||||
this.isCustom = isCustom;
|
this.isCustom = isCustom;
|
||||||
this.clg = levelGenerator;
|
this.clg = levelGenerator;
|
||||||
}
|
}
|
||||||
@@ -46,21 +46,26 @@ public class LevelSceneCustom extends LevelScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GamePlay gp = GamePlay.read("player.txt");
|
GamePlay gp = GamePlay.read("player.txt");
|
||||||
currentLevel = (Level) clg.generateLevel(gp);
|
|
||||||
|
|
||||||
String detailedInfo = FileHandler.readFile("DetailedInfo.txt");
|
|
||||||
|
|
||||||
File xmlInfoFile = new File("DetailedInfo.xml");
|
File xmlInfoFile = new File("DetailedInfo.xml");
|
||||||
|
DataRecorder dataRecorder;
|
||||||
if (xmlInfoFile.exists()) {
|
if (xmlInfoFile.exists()) {
|
||||||
try {
|
try {
|
||||||
DataRecorder dataRecorder = DataRecorder.fromXML(xmlInfoFile);
|
dataRecorder = DataRecorder.fromXML(xmlInfoFile);
|
||||||
System.out.println("DetailedInfo (from xml file): " + detailedInfo);
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
System.out.println("Reading from DataRecorder failed due to: ");
|
||||||
|
ioe.printStackTrace(System.out);
|
||||||
|
System.out.println("Initializing blank record");
|
||||||
|
dataRecorder = DataRecorder.BLANK_RECORD;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("DetailedInfo (from txt file): " + detailedInfo);
|
dataRecorder = DataRecorder.BLANK_RECORD;;
|
||||||
|
String detailedInfo = FileHandler.readFile("DetailedInfo.txt");
|
||||||
|
System.out.println("Read detailedInfo from DetailedInfo.txt (not parsed): ");
|
||||||
|
System.out.println(detailedInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int levelType = clg.generateLevelType(gp,dataRecorder);
|
||||||
|
currentLevel = (Level) clg.generateLevel(gp,dataRecorder);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
level = currentLevel.clone();
|
level = currentLevel.clone();
|
||||||
@@ -68,9 +73,7 @@ public class LevelSceneCustom extends LevelScene {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO change this
|
Art.startMusic(levelType);
|
||||||
// level is always overground
|
|
||||||
Art.startMusic(2);
|
|
||||||
|
|
||||||
paused = false;
|
paused = false;
|
||||||
Sprite.spriteContext = this;
|
Sprite.spriteContext = this;
|
||||||
|
|||||||
Reference in New Issue
Block a user