Exemplo n.º 1
0
  /**
   * Обработка активации ловушки.
   *
   * @param object объект, который изменил свое положение.
   */
  public boolean activate(TObject object) {

    if (!object.isCharacter()) return false;

    Character owner = getOwner();
    Character target = object.getCharacter();

    if (owner == null || owner == target || !owner.checkTarget(target)) {
      return false;
    }

    float dist = target.getGeomDistance(x, y);

    if (dist > radius) {
      return false;
    }

    if (lifeTask != null) {
      lifeTask.cancel(false);
      lifeTask = null;
    }

    ExecutorManager executor = ExecutorManager.getInstance();
    executor.scheduleGeneral(this, 100);

    return true;
  }
Exemplo n.º 2
0
  /**
   * Спавн в мир ловушку.
   *
   * @param owner владелец.
   * @param skill скил ловушки.
   * @param lifeTime время жизни.
   * @param radius радиус активации.
   */
  public void spawnMe(Character owner, Skill skill, int range, int lifeTime, int radius) {
    this.owner = owner;
    this.skill = skill;
    this.radius = radius;

    spawnMe(
        Coords.calcX(owner.getX(), range, owner.getHeading()),
        Coords.calcY(owner.getY(), range, owner.getHeading()),
        owner.getZ(),
        0);

    LocalObjects local = LocalObjects.get();

    Array<Character> chars =
        World.getAround(Character.class, local.getNextCharList(), this, radius);

    ExecutorManager executor = ExecutorManager.getInstance();

    if (chars.isEmpty()) this.lifeTask = executor.scheduleGeneral(this, lifeTime * 1000);
    else {

      Character[] array = chars.array();

      for (int i = 0, length = chars.size(); i < length; i++) {

        Character target = array[i];

        if (owner.checkTarget(target)) {
          executor.scheduleGeneral(this, 100);
          return;
        }
      }

      this.lifeTask = executor.scheduleGeneral(this, lifeTime * 1000);
    }
  }