Ejemplo n.º 1
0
  void generateChildrenImpl(final int depth) {
    if (depth == 0) return;
    setStateOnlyNonPlayableImpl(false);
    childGrids = new GridCollection(this);
    states |= States.HAS_CHILDREN;
    ChangeBlockListener evtChange = new ChangeBlockListener();
    PlayListener evtPlay = new PlayListener();
    EndListener evtEnd = new EndListener();
    final int size = getHandle().getWidth() / GridConsts.DIMENSION;
    for (int i = 0; i < GridConsts.DIMENSION; ++i) {
      for (int j = 0; j < GridConsts.DIMENSION; ++j) {
        AWTGrid g = new AWTGrid(getGameManager(), eventKey);
        AWTGridHandle h = g.getHandle();
        h.setSize(size);
        h.setLocation(i * size, j * size);
        addImpl(g);
        g.changeBlockEvent().addListener(evtChange);
        g.playEvent().addListener(evtPlay);
        g.endEvent().addListener(evtEnd);
        g.peerGrids = childGrids;
        childGrids.putGrid(new GridCoord(i, j), g);
      }
    }
    childGrids.forEach(
        new Consumer<Grid>() {

          public void accept(Grid t) {
            if (t instanceof AWTGrid) {
              ((AWTGrid) t).generateChildrenImpl(depth - 1);
            }
          }
        });
  }
Ejemplo n.º 2
0
 private void addImpl(AWTGrid g) {
   getHandle().add(g.getHandle());
 }