Ejemplo n.º 1
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.º 2
0
  @Override
  public void setTransient(Registry rg) {
    super.setTransient(rg);

    spawnCoolDowns = new HashMap<String, Integer>();

    try {
      for (String key : monsters.keySet()) {
        Monster monster = (Monster) monsters.get(key);
        monster.setTransient(rg, this);
      }
    } 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
    }
  }