コード例 #1
0
ファイル: Crew.java プロジェクト: RebelKeithy/FTL-Hyperion
  public void move(Room target, int x, int y) {
    System.out.println("state " + state);
    boolean removeFromTile = false;
    if (this.state != CrewStates.WALKING) {
      removeFromTile = true;
    }

    Tile tile = target.getTile(x, y);
    if (tile.getProperties().containsValue("crew")) return;

    Tile targetTile = pathfinder.setPath(this, target, x, y);

    if (targetTile != null) {
      if (removeFromTile) {
        System.out.println("removing");
        room.getTile((int) getX() - getRoom().getX(), (int) getY() - getRoom().getY())
            .getProperties()
            .removeProperty("crew");
      }

      if (state == CrewStates.MANNING) {
        room.getSystem().unmann();
      }
      state = CrewStates.WALKING;
    }
  }
コード例 #2
0
ファイル: Crew.java プロジェクト: RebelKeithy/FTL-Hyperion
  public boolean addToRoom(Room room) {
    if (room.getSystem() != null && room.getSystem().canMann() && !room.getSystem().isManned()) {
      int x = room.getSystem().getStationX();
      int y = room.getSystem().getStationY();
      System.out.println("adding crew at " + x + " " + y);
      setPosition(room, x, y);
      state = CrewStates.MANNING;
      room.getSystem().mann(this);
      return true;
    }

    for (int tileX = 0; tileX < room.getWidth(); tileX++) {
      for (int tileY = room.getHeight() - 1; tileY >= 0; tileY--) {
        Tile tile = room.getTile(tileX, tileY);
        if (!tile.getProperties().containsValue("crew")) {
          setPosition(room, tileX, tileY);
          return true;
        }
      }
    }

    return false;
  }