public static void switchCurrentScreen(GameScreen newScreen, boolean doTransition) {

    currentScreen.unloadResources();
    currentScreen = newScreen;
    screenTitle = newScreen.getTitle();
    transition = doTransition;
    newScreen = null;
  }
  public void processInput() {

    if (transition) {
      return;
    }

    currentScreen.processInput();
  }
  /*
   * SHOREST PATH FOR MIND CONTROL
   */
  private void setShortestPath() {
    powerUp = true;

    shortestPath =
        game.GameScreen.getGraphManager().shortestNoRLDijkstraPath(currentIntersection, tempTarget);
    currentRoad = 0;

    if (shortestPath == null) return;

    if (currentIntersection == shortestPath.get(currentRoad).getNode1()) {
      targetIntersection = shortestPath.get(currentRoad).getNode2();
    } else {
      targetIntersection = shortestPath.get(currentRoad).getNode1();
    }
  }
  public void update(double elapsedMilliseconds) {

    if (transition) {

      timer += elapsedMilliseconds;

      if (timer >= 3000d) {

        transition = false;
        timer = 0d;
      }

    } else {

      currentScreen.update(elapsedMilliseconds);
    }
  }
  public void draw(Graphics2D g) {

    if (transition) {

      g.setColor(new Color(0x13, 0x1B, 0x1B));
      g.fillRect(0, 0, 640, 480);

      displayFont.setScaling(2.5f);
      displayFont.setColor(new Color(0xDC, 0x3D, 0x24));
      displayFont.setBackgroundColor(new Color(0xE3, 0xAE, 0x57));

      displayFont.drawShadowedText(
          screenTitle,
          (640 / 2) - (displayFont.getStringSize(screenTitle).width / 2),
          (480 / 2) - (displayFont.getStringSize(screenTitle).height / 2),
          g);

      displayFont.setScaling(1);

    } else {

      currentScreen.draw(g);
    }
  }
  /*
   *  RANDOMNESS FOR SHORTEST PATH
   */
  private void mindlessTerror() {
    mtEnd = System.currentTimeMillis();
    mtDelta = (mtEnd - mtStart) / 1000;

    if (mtDelta == 20) {
      Sprite.setState(BANDIT_STATE);
      mindlessTerror = false;
      mtStart = 0;
      mtEnd = 0;
      mtDelta = 0;
      powerUp = false;

      shortestPath = null;

      currentRoad = 0;

      return;
    }

    // CHECK COLLISION
    Iterator<PathXPolice> pIt = game.GameScreen.getPolice().iterator();
    while (pIt.hasNext()) {
      PathXPolice p = pIt.next();

      if (p.stunned) {
        continue;
      }
      if (p.mindlessTerror) {
        continue;
      }

      if (p.getSprite().containsPoint(Sprite.getX() + 20, Sprite.getY() + 20)) {
        p.stunStart = System.currentTimeMillis();
        p.stunned = true;
      }
    }

    Iterator<PathXBandit> bIt = game.GameScreen.getBandits().iterator();
    while (bIt.hasNext()) {
      PathXBandit b = bIt.next();

      if (b == this) {
        continue;
      }
      if (b.stunned) {
        continue;
      }
      if (b.mindlessTerror) {
        continue;
      }

      if (b.getSprite().containsPoint(Sprite.getX() + 20, Sprite.getY() + 20)) {
        b.stunStart = System.currentTimeMillis();
        b.stunned = true;
      }
    }

    Iterator<PathXZombie> zIt = game.GameScreen.getZombies().iterator();
    while (zIt.hasNext()) {
      PathXZombie z = zIt.next();

      if (z.stunned) {
        continue;
      }
      if (z.mindlessTerror) {
        continue;
      }

      if (z.getSprite().containsPoint(Sprite.getX() + 20, Sprite.getY() + 20)) {
        z.stunStart = System.currentTimeMillis();
        z.stunned = true;
      }
    }

    if (atIntersection) {
      // IF THERE ARE NO POSSIBLE INTERSECTIONS AVAILABLE, DO NOTHING
      boolean open = false;
      for (int i = 0; i < currentIntersection.getIntersections().size(); i++) {
        if (currentIntersection.getIntersections().get(i).open
            && !currentIntersection.getIntersections().get(i).closed) {
          open = true;
        }
      }
      if (!open) {
        return;
      }

      // RUN WHILE WE DON'T HAVE A TARGET
      int min = 0;
      int max = currentIntersection.getRoads().size();
      while (targetIntersection == null) {
        // GET RANDOM INTERSECTION ATTATCHED TO THE CURRENT INTERSECTION
        int r = (int) ((min + Math.random() * (max - min)));
        Intersection tempIntersection = currentIntersection.getIntersections().get(r);

        if ((tempIntersection == level.getStartingLocation())
            || (tempIntersection == level.getDestination())) {
          continue;
        }

        // FIND A THE ROAD TO TRAVEL ON
        Iterator<Road> roadIt = currentIntersection.getRoads().iterator();
        Road road = null;
        while (roadIt.hasNext()) {
          Road tempRoad = roadIt.next();

          if ((tempRoad.node1 == currentIntersection) && (tempRoad.node2 == tempIntersection)) {

            road = tempRoad;
            break;
          } else if (((tempRoad.node1 == tempIntersection)
                  && (tempRoad.node2 == currentIntersection))
              && !tempRoad.oneWay) {
            road = tempRoad;
            break;
          }
        }

        if (road != null) {
          targetIntersection = tempIntersection;
          currentR = road;
          atIntersection = false;
        }

        if (road == null) {
          targetIntersection = null;
          return;
        }
      }
    } // move
    else {
      // CREATE VELOCITY
      float x = (targetIntersection.getX() - currentIntersection.getX()) * .0005f;
      float y = (targetIntersection.getY() - currentIntersection.getY()) * .0005f;

      // SET VELOCITY
      Sprite.setVx(x * currentR.getSpeedLimit() * d.gameSpeed * 2);
      Sprite.setVy(y * currentR.getSpeedLimit() * d.gameSpeed * 2);

      // GET SPRITE OF TARGET INTERSECTION
      Sprite tempIntersection =
          ((GameScreen) game.getCurrentScreen()).getIntersections().get(targetIntersection.ID - 1);

      // IF THE PLAYER HAS REACHED TARGET INTERSECTION
      if (tempIntersection.containsPoint(Sprite.getX() + 20, Sprite.getY() + 20)) {
        Sprite.setVx(0);
        Sprite.setVy(0);

        // SET THE X AND Y COORDS OF THE PLAYER ON TO THE SPRITE
        Sprite.setX(tempIntersection.getX());
        Sprite.setY(tempIntersection.getY());

        // PREPARE NEXT LOOP FOR CREATING A NEW TARGET INTERSECTION
        currentIntersection = targetIntersection;
        targetIntersection = null;
        atIntersection = true;
      }
    }
  }