コード例 #1
0
  public static Actor findActorInFilm(Collection<Film> films, String film, String actorName) {
    Film foundedFilm = Film.findFilmInCollection(films, film);
    Iterator<Actor> itActor = foundedFilm.getActors().iterator();
    Actor foundedActor = new Actor();
    while (itActor.hasNext()) {
      Actor a = itActor.next();
      if (actorName.equals(a.getActorName())) {
        foundedActor = a;
        System.out.println("I found this actor");

      } else {
        System.out.println("I didn't find this actor");
      }
    }
    return foundedActor;
  }
コード例 #2
0
  public ArrayList<String> attackDamageAndKnockBack(
      Actor source,
      Arc2D.Double arc,
      Point mapPoint,
      int damage,
      int knockBackX,
      int knockBackY,
      int maxHits,
      String weaponType) {
    int dmg = 0;
    int hits = 0;
    Monster monster = null;
    ArrayList<String> monstersHit = new ArrayList<String>();

    try {
      for (String key : monsters.keySet()) {
        monster = (Monster) monsters.get(key);

        if (weaponType != null) {
          if (weaponType.equals("Net")) {
            damage = 1;
          }
        }

        dmg =
            monster.attackDamageAndKnockBack(
                source, arc, mapPoint, damage, knockBackX, knockBackY, weaponType);
        if (dmg > 0) {
          if (weaponType != null) {
            if (weaponType.equals("FangClaw")) {
              monster.poison(10);
            }
          }
          monstersHit.add(monster.getName());
          hits++;
        }
        if (hits >= maxHits) {
          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 (hits == 0) {
      if (source != null) {
        SoundClip cl = new SoundClip(registry, "Weapon/Miss", source.getCenterPoint());
      } else {
        SoundClip cl = new SoundClip("Weapon/Miss");
      }
    }

    return monstersHit;
  }