Exemple #1
0
  /**
   * Updates all entities in this Round.
   *
   * @param delta the time elapsed since the last update
   */
  public void update(float delta) {

    powerUpManager.update(delta);
    floatyNumbersManager.update(delta);

    if (objective != null) {
      objective.update(delta);

      if (objective.getStatus() == Objective.OBJECTIVE_COMPLETED) {
        parent.showWinScreen(player.getScore());
      } else if (player.isDead()) {
        parent.showLoseScreen();
      }
    }

    // int updateNumber =0, totalNumber=entities.size(), numMobs=0;
    for (int i = 0; i < entities.size(); i++) {
      Entity entity = entities.get(i);
      /*            if(entity instanceof Mob)
      numMobs++;*/

      if (entity.isRemoved()) {
        if (entity instanceof Mob && ((Mob) entity).isDead()) {
          int score =
              (int)
                  (((Mob) entity).getScore()
                      * (powerUpManager.getIsActive(PowerupManager.powerupTypes.SCORE_MULTIPLIER)
                          ? Player.PLAYER_SCORE_MULTIPLIER
                          : 1));
          player.addScore(score);
          floatyNumbersManager.createScoreNumber(score, entity.getX(), entity.getY());
          if (objective.getObjectiveType() == Objective.objectiveType.BOSS) {
            spawnRandomMobs(1, 0, 0, 1000, 1000);
          }
        }

        entities.remove(i);
      } else if ((entity.distanceTo(player.getX(), player.getY()) < UPDATE_DISTANCE_X)
          && (entity.distanceTo(player.getX(), player.getY()) < UPDATE_DISTANCE_Y)) {
        // Don't bother updating entities that aren't on screen.
        entity.update(delta);
        // updateNumber++;
      }
    }

    if (Gdx.input.isKeyJustPressed(Input.Keys.P)) {
      for (int x = 0; x < 1000; x++) {
        createProjectile(
            MathUtils.random(300, 1500),
            MathUtils.random(300, 1500),
            MathUtils.random(300, 1500),
            MathUtils.random(300, 1500),
            500,
            0,
            0,
            0,
            player);
      }
    }
    // System.out.println("total:"+totalNumber+" updated:"+updateNumber+" numMobs:"+numMobs);
  }
Exemple #2
0
 /**
  * Converts screen coordinates to world coordinates.
  *
  * @param x the x coordinate on screen
  * @param y the y coordinate on screen
  * @return a Vector3 containing the world coordinates (x and y)
  */
 public Vector3 unproject(int x, int y) {
   return parent.getGameScreen().unproject(x, y);
 }