예제 #1
0
  @Override
  public void updateLong() {
    if (!transmitting) {
      if (nextBossOrcSpawn == 0) {
        // spawn melvin every 10 - 30 min
        nextBossOrcSpawn = registry.currentTime + Rand.getRange(10 * 60 * 1000, 30 * 60 * 1000);
      }
      if (nextSnailRiderSpawn == 0) {
        // spawn melvin every 10 - 30 min
        nextSnailRiderSpawn = registry.currentTime + Rand.getRange(10 * 60 * 1000, 30 * 60 * 1000);
      }

      Monster monster = null;
      ArrayList deadMonsters = new ArrayList();

      // make sure we have enough bad guys on the map
      if (gameController.multiplayerMode != gameController.multiplayerMode.CLIENT) {
        spawnNearPlayers();
        spawnNearPlaceable();
      }

      try {
        for (String key : monsters.keySet()) {
          monster = (Monster) monsters.get(key);
          if (!monster.isFeared()) {
            gameController.checkIfFeared(monster);
          }
          gameController.checkPlaceableDamageAgainstMob(monster);

          monster.updateLong();
          if (monster.isDirty()) {
            deadMonsters.add(key);
          }
        }

        if (deadMonsters.size() > 0) {
          for (int i = 0; i < deadMonsters.size(); i++) {
            // EIError.debugMsg((String) deadMonsters.get(i));
            monsters.remove((String) deadMonsters.get(i));
          }
        }
      } catch (ConcurrentModificationException concEx) {
        // another thread was trying to modify monsters while iterating
        // we'll continue and the new item can be grabbed on the next update
      }
    }
  }
예제 #2
0
  private void spawnPlants() {
    if (gameController.multiplayerMode != gameController.multiplayerMode.CLIENT) {
      // Blue Thorns
      int blueThornCount = this.getCountByType("BlueThorn");
      if (blueThornCount < 200) {
        for (int i = 0; i < 200 - blueThornCount; i++) {
          boolean canSpawn = true;
          int level = Rand.getRange(1, 3);
          Point vinePosition = new Point();
          vinePosition.x = Rand.getRange(1, gameController.getMapWidth());
          vinePosition.y =
              Rand.getRange(
                  registry.getBlockManager().getLevelBottom(level),
                  registry.getBlockManager().getLevelTop(level));

          vinePosition.y = this.findNextFloor(vinePosition.x, vinePosition.y, 60);

          if (this.doesRectContainBlocks(vinePosition.x, vinePosition.y + 100, 17, 16)) {
            Monster monster = null;
            try {
              for (String key : monsters.keySet()) {
                monster = (Monster) monsters.get(key);
                if (monster.getName().equals("BlueThorn")
                    || monster.getName().equals("VineThorn")) {
                  double distance = vinePosition.distance(monster.getCenterPoint());
                  if (distance < 750) {
                    canSpawn = false;
                    break;
                  }
                }
              }
            } catch (ConcurrentModificationException concEx) {
              // another thread was trying to modify monsters while iterating
              // we'll continue and the new item can be grabbed on the next update
            }
            if (canSpawn) {
              spawn("BlueThorn", "Roaming", vinePosition.x, vinePosition.y);
            }
          }
        }
      }

      // Vine Thorns
      int vineThornCount = this.getCountByType("VineThorn");
      if (vineThornCount < 200) {
        for (int i = 0; i < 200 - vineThornCount; i++) {
          boolean canSpawn = true;
          int level = Rand.getRange(1, 3);
          Point vinePosition = new Point();
          vinePosition.x = Rand.getRange(1, gameController.getMapWidth());
          vinePosition.y =
              Rand.getRange(
                  registry.getBlockManager().getLevelBottom(level),
                  registry.getBlockManager().getLevelTop(level));

          vinePosition.y = this.findNextFloor(vinePosition.x, vinePosition.y, 60);

          if (this.doesRectContainBlocks(vinePosition.x, vinePosition.y + 100, 17, 16)) {
            Monster monster = null;
            try {
              for (String key : monsters.keySet()) {
                monster = (Monster) monsters.get(key);
                if (monster.getName().equals("BlueThorn")
                    || monster.getName().equals("VineThorn")) {
                  double distance = vinePosition.distance(monster.getCenterPoint());
                  if (distance < 750) {
                    canSpawn = false;
                    break;
                  }
                }
              }
            } catch (ConcurrentModificationException concEx) {
              // another thread was trying to modify monsters while iterating
              // we'll continue and the new item can be grabbed on the next update
            }
            if (canSpawn) {
              spawn("VineThorn", "Roaming", vinePosition.x, vinePosition.y);
            }
          }
        }
      }
    }
  }