Пример #1
0
  public Tower(Main m, int x, int y, TowerType towerType) {
    this.m = m;
    this.towerType = towerType;
    setX(x);
    setY(y);

    setAttackSpeed(0.0D);
    setDamage(0.0D);
    setRange(0.0D);
    setAAcd(0.0D);
    setProjectileAnimationDeath(null);
    setProjectileAnimationStand(null);
    setProjectileAnimationDeathDuration(1);
    setProjectileAnimationStandDuration(1);
    setProjectileSpeed(0.0D);
    setSprite(null);
    setAnimation(ANIMATION_STAND);
    setAnimationTime(0);
    setShootingAir(true);
    setShootingGround(true);
    setBuffs(new ArrayList<Buff>());
  }
Пример #2
0
  public void drawLogic(int delta) {
    int duration = getAnimationStandDuration();
    BufferedImage animation = getAnimationStand();

    if (getAnimation() == ANIMATION_PRE_ATTACK) {
      duration = getAnimationPreAttackDuration();
      animation = getAnimationPreAttack();
    }
    if (getAnimation() == ANIMATION_POST_ATTACK) {
      duration = getAnimationPostAttackDuration();
      animation = getAnimationPostAttack();
    }

    if (getAnimationTime() + delta >= duration && getAnimation() == ANIMATION_POST_ATTACK) {
      setAnimation(ANIMATION_STAND);
      duration = getAnimationStandDuration();
      animation = getAnimationStand();
    } else if (getAnimationTime() + delta >= duration && getAnimation() == ANIMATION_PRE_ATTACK) {
      setAnimationTime(getAnimationTime() - delta);
    } else if (getAAcd() * 1000D <= getAnimationPreAttackDuration()
        && getAnimation() == ANIMATION_STAND) {
      setAnimation(ANIMATION_PRE_ATTACK);
      duration = getAnimationPreAttackDuration();
      animation = getAnimationPreAttack();
    }
    setAnimationTime((getAnimationTime() + delta) % duration);
    int phase =
        (int)
            ((double) getAnimationTime()
                / (double) duration
                * (double) Animation.getImagePhases(animation));
    if (getSprite() == null) {
      Sprite s =
          new Sprite(
              m,
              (int) getX(),
              (int) getY(),
              Animation.getImagePhase(animation, phase, m),
              this,
              false);
      m.getGame().setNewSprite(s);
      setSprite(s);
    } else {
      if ((getSprite().getX() == getX()
          && getSprite().getY() == getY()
          && getSprite().getImage() == Animation.getImagePhase(animation, phase, m))) {
      } else {
        m.getGame().destroySprite(getSprite());
        Sprite s =
            new Sprite(
                m,
                (int) getX(),
                (int) getY(),
                Animation.getImagePhase(animation, phase, m),
                this,
                false);
        m.getGame().setNewSprite(s);
        setSprite(s);
      }
    }
  }