Exemplo n.º 1
0
  public void fight() {
    inRange = false;
    if (currentTarget != null) {
      targetPosition = currentTarget.position;
      if (position.dst(currentTarget.position) <= range) {
        inRange = true;

        if (secondsUntilShoot <= 0) {

          int multiplier = team == Team.Left ? -1 : 1;

          secondsUntilShoot = secondsPerShot * Particle.rand(.9f, 1.1f);
          switch (type) {
            case Melee:
              currentTarget.damage((int) damage);
              setRotation(.3f * multiplier);
              addAction(Actions.rotateTo(0, .2f));
              break;
            case Ranged:
              pop.play(Slider.SFX.getValue());
              GameScreen.self.addParticle(
                  new MinionShot((int) position.x, (int) position.y, currentTarget, (int) damage));
              setRotation(.3f * -multiplier);
              addAction(Actions.rotateTo(0, .2f));
              break;
            default:
              break;
          }
        }
        return;
      }
    } else {
      if (!player) targetPosition = defaultAttackPosition;
    }
  }