use of src.model.MazeDimension.RectInMaze in project Labyrinthe3d by FauconFan.
the class ContentMazeFactory method initiateSpecialCases.
public void initiateSpecialCases(boolean genStart, boolean genEnd) {
ArrayList<Point> oldPoints;
ArrayList<RectInMaze> li;
RectInMaze rim;
Random ran;
int x;
int y;
int max;
Point tmp;
Point tmp2;
ran = new Random();
li = this.mazeDim.getListRectMaze();
oldPoints = new ArrayList<>();
if (genStart) {
tmp = this.genRandomPoint(ran, li, oldPoints);
this.contentSpecialCases.add(new StartCase(tmp.x, tmp.y));
}
if (genEnd) {
tmp = this.genRandomPoint(ran, li, oldPoints);
this.contentSpecialCases.add(new EndCase(tmp.x, tmp.y));
}
max = 0;
if (this.mazeDim.size() >= 200) {
max = 3;
} else if (this.mazeDim.size() >= 100) {
max = 2;
}
for (int i = 0; i < max; i++) {
tmp = this.genRandomPoint(ran, li, oldPoints);
this.contentSpecialCases.add(new SpeedCase(tmp.x, tmp.y, 0.5f));
tmp = this.genRandomPoint(ran, li, oldPoints);
this.contentSpecialCases.add(new TimeCase(tmp.x, tmp.y, 1000));
tmp = this.genRandomPoint(ran, li, oldPoints);
tmp2 = this.genRandomPoint(ran, li, oldPoints);
this.contentSpecialCases.add(new TeleportCase(tmp.x, tmp.y, tmp2.x, tmp2.y));
tmp = this.genRandomPoint(ran, li, oldPoints);
this.contentSpecialCases.add(new JumpCase(tmp.x, tmp.y, 0.05f));
}
}
use of src.model.MazeDimension.RectInMaze in project Labyrinthe3d by FauconFan.
the class ContentMazeFactory method genRandomPoint.
private Point genRandomPoint(Random ran, ArrayList<RectInMaze> li, ArrayList<Point> oldPoints) {
Point res;
RectInMaze rim;
int x;
int y;
rim = li.get(ran.nextInt(li.size()));
x = ran.nextInt(rim.x2 - rim.x1) + rim.x1;
y = ran.nextInt(rim.y2 - rim.y1) + rim.y1;
res = new Point(x, y);
if (oldPoints.contains(res)) {
return (genRandomPoint(ran, li, oldPoints));
}
oldPoints.add(res);
return (res);
}
Aggregations