Пример #1
0
  private void initStartedFromPositions(ScoringInfo scoringInfo) {
    startedPositions = new int[scoringInfo.getNumVehicles()];

    for (int j = 0; j < scoringInfo.getNumVehicles(); j++)
      startedPositions[j] = scoringInfo.getVehicleScoringInfo(j).getDriverId();

    startedPositionsInitialized = true;
  }
Пример #2
0
  @Override
  protected Boolean updateVisibility(LiveGameData gameData, boolean isEditorMode) {
    super.updateVisibility(gameData, isEditorMode);

    ScoringInfo scoringInfo = gameData.getScoringInfo();

    if (!startedPositionsInitialized) initStartedFromPositions(scoringInfo);
    if (RaceInfosWidget.visible()) return false;

    currentLap.update(scoringInfo.getLeadersVehicleScoringInfo().getLapsCompleted());

    if (currentLap.hasChanged()
            && currentLap.getValue() > 0
            && (short) (Math.random() * randMulti.getValue()) == 0
        || isEditorMode) {

      // fetch what data is shown others-gaps 1-places gained/lost
      if (scoringInfo.getLeadersVehicleScoringInfo().getFinishStatus().isFinished() || isEditorMode)
        shownData = 1;
      else shownData = (short) (Math.random() * 2);

      if (scoringInfo.getGamePhase() == GamePhase.SESSION_OVER)
        visibleEnd = scoringInfo.getSessionNanos() + visibleTime.getDelayNanos() * 3;
      else visibleEnd = scoringInfo.getSessionNanos() + visibleTime.getDelayNanos();

      clearArrayValues(scoringInfo.getNumVehicles());
      FillArrayValues(1, scoringInfo, isEditorMode, gameData);
      if (!isEditorMode) forceCompleteRedraw(true);

      return true;
    }

    if (scoringInfo.getSessionNanos() < visibleEnd || isEditorMode) {
      // how many on the same lap?
      int onlap = 0;
      for (int j = 0; j < scoringInfo.getNumVehicles(); j++) {
        if (scoringInfo.getVehicleScoringInfo(j).getLapsCompleted()
            == scoringInfo.getLeadersVehicleScoringInfo().getLapsCompleted()) onlap++;
      }

      carsOnLeadLap.update(onlap);
      if (carsOnLeadLap.hasChanged() && !isEditorMode) {
        FillArrayValues(onlap, scoringInfo, false, gameData);
        forceCompleteRedraw(true);
      }
      return true;
    }

    return false;
  }
Пример #3
0
  private void FillArrayValues(
      int onLeaderLap, ScoringInfo scoringInfo, boolean isEditorMode, LiveGameData gameData) {
    if (isEditorMode) {
      // data = 4;
      onLeaderLap = numVeh.getValue();
    }
    int negrand[] = new int[2];
    negrand[0] = 1;
    negrand[1] = -1;

    for (int i = 0; i < onLeaderLap; i++) {

      if (positions[i] == -1) {

        VehicleScoringInfo vsi = scoringInfo.getVehicleScoringInfo(i);
        positions[i] = vsi.getPlace(false);
        number[i] = vsi.getVehicleInfo().getCarNumber();
        names[i] = ShortName(vsi.getDriverName().toUpperCase());
        if (i == 0) gaps[i] = "";
        else gaps[i] = TimingUtil.getTimeAsGapString(-vsi.getTimeBehindLeader(false));

        switch (shownData) // 0-2-4-gaps 1-place gained
        {
          case 1: // places
            int startedfrom = 0;
            for (int p = 0; p < scoringInfo.getNumVehicles(); p++) {
              if (vsi.getDriverId() == startedPositions[p]) {
                startedfrom = p + 1;
                break;
              }
            }
            if (isEditorMode) {
              gainedPlaces[i] =
                  (short) ((Math.random() * 2) * negrand[(short) (Math.random() * 2)]);
              pit[i] = Math.abs(gainedPlaces[i]);

            } else {
              gainedPlaces[i] = (short) (startedfrom - vsi.getPlace(false));
              pit[i] = Math.abs(startedfrom - vsi.getPlace(false));
            }
            break;
          default: // pit
            pit[i] = vsi.getNumPitstopsMade();

            break;
        }
      }
    }
  }
Пример #4
0
  @Override
  protected void drawBackground(
      LiveGameData gameData,
      boolean isEditorMode,
      TextureImage2D texture,
      int offsetX,
      int offsetY,
      int width,
      int height,
      boolean isRoot) {
    super.drawBackground(gameData, isEditorMode, texture, offsetX, offsetY, width, height, isRoot);
    // logCS("test");
    ScoringInfo scoringInfo = gameData.getScoringInfo();
    int maxNumItems = numVeh.getValue();
    int rowHeight = height / maxNumItems;
    int drawncars = Math.min(scoringInfo.getNumVehicles(), maxNumItems);
    short posOffset;

    for (int i = 0; i < drawncars; i++) {
      if (carsOnLeadLap.getValue() > numVeh.getValue() && i != 0)
        posOffset = (short) (carsOnLeadLap.getValue() - numVeh.getValue());
      else posOffset = 0;

      if (positions[i + posOffset] != -1 || isEditorMode) {

        if (scoringInfo
                .getVehicleScoringInfo(positions[i + posOffset] - 1)
                .getVehicleInfo()
                .getManufacturer()
                .toUpperCase()
                .equals("FORD")
            || (isEditorMode && (short) (Math.random() * 2) == 0))
          texture.clear(imgFord.getTexture(), offsetX, offsetY + rowHeight * i, false, null);
        else texture.clear(imgHolden.getTexture(), offsetX, offsetY + rowHeight * i, false, null);

        if (shownData == 1) {
          if (gainedPlaces[i + posOffset] > 0)
            texGainedPlaces =
                imgPositive
                    .getImage()
                    .getScaledTextureImage(
                        width * 9 / 100, rowHeight, texGainedPlaces, isEditorMode);
          else if (gainedPlaces[i + posOffset] < 0)
            texGainedPlaces =
                imgNegative
                    .getImage()
                    .getScaledTextureImage(
                        width * 9 / 100, rowHeight, texGainedPlaces, isEditorMode);
          else
            texGainedPlaces =
                imgNeutral
                    .getImage()
                    .getScaledTextureImage(
                        width * 9 / 100, rowHeight, texGainedPlaces, isEditorMode);

          texture.drawImage(
              texGainedPlaces, offsetX + width * 171 / 200, offsetY + rowHeight * i, true, null);
        }
      }
    }
  }