예제 #1
0
파일: Game.java 프로젝트: jgacitua/PacMan
  /** _feast. */
  private void _feast() {
    pacmanFueComido = false;

    for (GHOST ghost : GHOST.values()) fantasmaComido.put(ghost, false);

    for (Ghost ghost : fantasmas.values()) {
      int distance = getShortestPathDistance(pacman.currentNodeIndex, ghost.currentNodeIndex);

      if (distance <= EAT_DISTANCE && distance != -1) {
        if (ghost.edibleTime > 0) // pac-man eats ghost
        {
          score += GHOST_EAT_SCORE * fastamasComerMultiplicador;
          fastamasComerMultiplicador *= 2;
          ghost.edibleTime = 0;
          ghost.lairTime =
              (int)
                  (COMMON_LAIR_TIME
                      * (Math.pow(LAIR_REDUCTION, cuentaElLvl % LEVEL_RESET_REDUCTION)));
          ghost.currentNodeIndex = laberintoActua.lairNodeIndex;
          ghost.lastMoveMade = MOVE.NEUTRAL;

          fantasmaComido.put(ghost.type, true);
        } else // ghost eats pac-man
        {
          pacman.numberOfLivesRemaining--;
          pacmanFueComido = true;

          if (pacman.numberOfLivesRemaining <= 0) juegoTerminado = true;
          else _levelReset();

          return;
        }
      }
    }

    for (Ghost ghost : fantasmas.values()) if (ghost.edibleTime > 0) ghost.edibleTime--;
  }