コード例 #1
0
ファイル: Compost.java プロジェクト: root-voicenet/Konklex
  /* handle compost bin updating */
  private void updateCompostBin(int index) {
    CompostBinStages compostBinStages =
        CompostBinStages.forId(CompostBinLocations.forId(index).getBinObjectId());

    if (compostBinStages == null) {
      return;
    }
    int x = CompostBinLocations.forId(index).getBinPosition().getX();
    int y = CompostBinLocations.forId(index).getBinPosition().getY();
    int z = CompostBinLocations.forId(index).getBinPosition().getHeight();
    int finalObject;

    // handling the different ways to fill a compost bin
    if (compostBins[index] > 0) {
      if (compostBins[index] % 17 == 0) {
        finalObject = compostBinStages.getBinWithSuperCompostable();
      } else if (compostBins[index] % 77 == 0) {
        finalObject = compostBinStages.getBinWithTomatoes();
      } else {
        finalObject = compostBinStages.getBinWithCompostable();
      }
    } else {
      finalObject = compostBinStages.getBinEmpty();
    }

    // handling the different ways to complete a compost bin
    if (compostBins[index] == 255) {
      finalObject = compostBinStages.getBinFullOFSuperCompostable();
      tempCompostState = 2;
    } else if (compostBins[index] == 1155) {
      finalObject = compostBinStages.getBinFullOfTomatoes();
      tempCompostState = 3;
    } else if (organicItemAdded[index] == 15) {
      finalObject = compostBinStages.getBinFullOfCompostable();
      tempCompostState = 1;
    }
    // handling the closed state of the compost bin
    switch (compostBins[index]) {
      case 100:
      case 200:
      case 300:
        finalObject = compostBinStages.getClosedBin();
        break;

        // handling the rotted state of the compost in the bin
      case 150:
        finalObject = compostBinStages.getBinFullOfCompost();
        break;
      case 250:
        finalObject = compostBinStages.getBinFullOfSuperCompost();
        break;
      case 350:
        finalObject = compostBinStages.getBinFullOfRottenTomatoes();
        break;
    }

    // handle the compost bin state when the player retrieve the compost
    if (compostBins[index] == 150 && organicItemAdded[index] < 15) {
      finalObject = compostBinStages.getBinWithCompost();
    } else if (compostBins[index] == 250 && organicItemAdded[index] < 15) {
      finalObject = compostBinStages.getBinWithSuperCompost();
    }
    if (compostBins[index] == 350 && organicItemAdded[index] < 15) {
      finalObject = compostBinStages.getBinWithRottenTomatoes();
    }

    final Position pos = new Position(x, y, z);
    GameObject object =
        new GameObject(
            ObjectDefinition.forId(finalObject),
            pos,
            10,
            CompostBinLocations.forId(index).getObjectFace());
    player.send(new PositionEvent(player.getLastKnownRegion(), pos));
    player.send(new CreateObjectEvent(object));
  }
コード例 #2
0
ファイル: Compost.java プロジェクト: root-voicenet/Konklex
 static {
   for (CompostBinStages data : CompostBinStages.values()) {
     bins.put(data.binEmpty, data);
   }
 }