blob: 951d1826575a4836426a619dfbcce91ce6258cfb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package fr.umlv.java.wallj.block;
import fr.umlv.java.wallj.board.TileVec2;
import fr.umlv.java.wallj.controller.BlockControllerFactory;
import org.jbox2d.common.Vec2;
/**
* A block factory.
*
* @author Pacien TRAN-GIRARD
*/
public final class BlockFactory {
private static Block forType(BlockType t, Vec2 pos) {
switch (t) {
case WALL:
return new WallBlock(pos);
case TRASH:
return new TrashBlock(pos);
case GARBAGE:
return new GarbageBlock(pos);
case ROBOT:
return new RobotBlock(pos);
case BOMB:
return new BombBlock(pos);
case FREE:
default:
return null;
}
}
public static Block build(BlockType type, TileVec2 pos) {
Block block = forType(type, pos.toVec2());
if (block != null) block.setControllers(BlockControllerFactory.build(block));
return block;
}
private BlockFactory() {
// static class
}
}
|