fixed error after game ends
This commit is contained in:
@@ -88,7 +88,7 @@ class TurtleGame extends StatelessGame {
|
|||||||
turtle.kill();
|
turtle.kill();
|
||||||
this.bombs.remove(bomb);
|
this.bombs.remove(bomb);
|
||||||
bomb.remove();
|
bomb.remove();
|
||||||
this.generateNewBomb();
|
this.generateNewBomb(2);
|
||||||
this.getScore().insertResult(p, this.scoreMap.get(p));
|
this.getScore().insertResult(p, this.scoreMap.get(p));
|
||||||
this.speed += 0.5;
|
this.speed += 0.5;
|
||||||
});
|
});
|
||||||
@@ -133,6 +133,12 @@ class TurtleGame extends StatelessGame {
|
|||||||
return new Pos(x, 1, z).withLookAt(new Pos(0, 0, 0));
|
return new Pos(x, 1, z).withLookAt(new Pos(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void generateNewSnack(int count) {
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
this.generateNewSnack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void generateNewSnack() {
|
private void generateNewSnack() {
|
||||||
Entity snack = new Entity(EntityType.FALLING_BLOCK);
|
Entity snack = new Entity(EntityType.FALLING_BLOCK);
|
||||||
FallingBlockMeta meta = (FallingBlockMeta) snack.getEntityMeta();
|
FallingBlockMeta meta = (FallingBlockMeta) snack.getEntityMeta();
|
||||||
@@ -147,6 +153,12 @@ class TurtleGame extends StatelessGame {
|
|||||||
this.snacks.add(snack);
|
this.snacks.add(snack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void generateNewBomb(int count) {
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
this.generateNewBomb();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void generateNewBomb() {
|
private void generateNewBomb() {
|
||||||
Entity bomb = new Entity(EntityType.FALLING_BLOCK);
|
Entity bomb = new Entity(EntityType.FALLING_BLOCK);
|
||||||
FallingBlockMeta meta = (FallingBlockMeta) bomb.getEntityMeta();
|
FallingBlockMeta meta = (FallingBlockMeta) bomb.getEntityMeta();
|
||||||
@@ -190,11 +202,7 @@ class TurtleGame extends StatelessGame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
for (int i = 0; i < 10; i++) {
|
this.generateNewSnack((int) Math.ceil(this.turtlePlayerMap.size() * 1.5));
|
||||||
this.generateNewSnack();
|
this.generateNewBomb((int) Math.ceil(this.snacks.size() * 0.5));
|
||||||
}
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
this.generateNewBomb();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ public class TurtleGameFactory implements GameFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
||||||
return new TurtleGame(configuration.get("radius").getAsInt());
|
return new TurtleGame(configuration.get("radius").getAsInt()).setParent(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user