Ejemplo n.º 1
0
  public void removeAllMonsters() {
    Monster monster = null;

    ArrayList deadMonsters = new ArrayList();

    try {
      for (String key : monsters.keySet()) {
        monster = (Monster) monsters.get(key);
        if (!monster.getName().equals("Pig")
            && !monster.getName().equals("BlueThorn")
            && !monster.getName().equals("VineThorn")) {
          deadMonsters.add(key);
          if (gameController.multiplayerMode == gameController.multiplayerMode.SERVER
              && registry.getNetworkThread() != null) {
            if (registry.getNetworkThread().readyForUpdates()) {
              UpdateMonster um = new UpdateMonster(monster.getId());
              um.mapX = monster.getMapX();
              um.mapY = monster.getMapY();
              um.action = "Die";
              registry.getNetworkThread().sendData(um);
            }
          }
        }
      }

      if (deadMonsters.size() > 0) {
        for (int i = 0; i < deadMonsters.size(); 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
    }
  }
Ejemplo n.º 2
0
  @Override
  public void update() {
    if (!transmitting) {
      super.update();

      ArrayList deadMonsters = new ArrayList();

      Monster monster = null;

      try {
        for (String key : monsters.keySet()) {
          monster = (Monster) monsters.get(key);
          if (monster != null) {
            monster.update();
            if (monster.getIsDead()) {
              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
      }
    }
  }
Ejemplo n.º 3
0
  private void removeMonster(String monsterType) {
    Monster monster = null;

    ArrayList deadMonsters = new ArrayList();

    try {
      for (String key : monsters.keySet()) {
        monster = (Monster) monsters.get(key);
        if (monster.getName().equals(monsterType)) {
          deadMonsters.add(key);
          break;
        }
      }

      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
    }
  }
Ejemplo n.º 4
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
      }
    }
  }
Ejemplo n.º 5
0
  public void generatePlants() {
    int passes = 0;
    int blueThornCount = 0;
    int vineThornCount = 0;

    do {
      blueThornCount = this.getCountByType("BlueThorn");
      vineThornCount = this.getCountByType("VineThorn");
      spawnPlants();

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

      try {
        for (String key : monsters.keySet()) {
          monster = (Monster) monsters.get(key);
          if (monster != null) {
            monster.update();
            if (monster.getIsDead()) {
              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
      }

      passes++;
    } while ((blueThornCount < 200 || vineThornCount < 200) && passes < 50);
    int g = 1;
  }