Example #1
0
  public Mortar() {
    mInaccuracy = getProperty("inaccuracy");
    mExplosionRadius = getProperty("explosionRadius");

    StaticData s = (StaticData) getStaticData();

    mSpriteBase = s.spriteBase.yieldStatic(Layers.TOWER_BASE);
    mSpriteBase.setIndex(getGame().getRandom(4));
    mSpriteBase.setListener(this);

    mSpriteCanon = s.spriteCanon.yieldAnimated(Layers.TOWER);
    mSpriteCanon.setIndex(getGame().getRandom(4));
    mSpriteCanon.setListener(this);
    mSpriteCanon.setSequence(mSpriteCanon.sequenceForwardBackward());
    mSpriteCanon.setInterval(REBOUND_DURATION);
  }
Example #2
0
  @Override
  public void tick() {
    super.tick();

    if (getTarget() != null && isReloaded()) {
      Vector2 targetPos = getTarget().getPositionAfter(MortarShot.TIME_TO_TARGET);
      targetPos.add(Vector2.polar(getGame().getRandom(mInaccuracy), getGame().getRandom(360f)));
      Vector2 shotPos = getPosition().copy().add(Vector2.polar(SHOT_SPAWN_OFFSET, mAngle));
      mAngle = getAngleTo(targetPos);

      getGame().add(new MortarShot(this, shotPos, targetPos, getDamage(), mExplosionRadius));

      setReloaded(false);
      mRebounding = true;
    }

    if (mRebounding && mSpriteCanon.tick()) {
      mRebounding = false;
    }
  }
Example #3
0
 @Override
 public void preview(Canvas canvas) {
   mSpriteBase.draw(canvas);
   mSpriteCanon.draw(canvas);
 }