Beispiel #1
0
  private void addPiece(TrackPiece piece, float tripOffset) {

    String placedPieceId = Integer.toString(placedPiecekIdSeq.incrementAndGet());

    PlacedPiece placed = new PlacedPiece(placedPieceId, piece, tripOffset);
    world.trackPieces.addLast(placed);
    for (ObstacleDef obstacleDef : piece.getObstacleDefs()) {
      Obstacle obstacle = world.createObstacle(placedPieceId, obstacleDef, tripOffset);
      placed.instantiatedObstacles.put(obstacle.defId, obstacle);
      world.addObstacle(obstacle);
    }

    // ühenda väljundid
    for (Obstacle obstacle : placed.instantiatedObstacles.values()) {
      if (obstacle instanceof Trigger) {
        Trigger trigger = (Trigger) obstacle;
        trigger.setOutput((Wireable) placed.instantiatedObstacles.get(trigger.outputId));
      }
    }
  }
Beispiel #2
0
  public void update(float delta) {
    world.trip += delta * MAP_SCROLL_SPEED;

    if (world.trackPieces.isEmpty()) {
      addPiece(pieces[0]);
    }

    // TODO: miks alati ei eemaldata?
    PlacedPiece first = world.trackPieces.getFirst();
    if (world.trip > first.tripOffset + first.track.getLength() - 10) {
      world.trackPieces.removeFirst();
      remove(first);
    }
  }