コード例 #1
0
  protected TowerPulseCannon(String spr, Vector2f pos) {
    super(spr, pos);

    turret = Utils.getImageFromPath("canun2.png");

    baseDamage = 11;
    baseFireRate = 1500;
    baseRange = 500;
  }
コード例 #2
0
  @Override
  public void update(int dt) {

    // TODO: Debug
    /*
    if (statEffects.contains(StatEffect.EMP)) {

    	return;
    }
    */

    // debug
    if (parent == null) {

      System.out.println("Somehow parent is null! WTF");
    }
    if (owner == null) {

      System.out.println("Somehow owner is null! WTF");
    }

    setPos(getPos().add(step));

    life += dt;

    if (life >= lifeTime) {

      parent.removeChild(this);
    }

    EntityLiving e =
        (EntityLiving)
            Utils.getNearestEntity(
                Utils.sortByType(MainGame.instance.lc.getCopyOfChildren(), "Enemy"),
                this.getCenterPos(),
                50);

    if (e != null) {

      e.damage(owner.getDamage());

      parent.removeChild(this);
    }
  }
コード例 #3
0
 @Override
 public void render(Graphics g) {
   super.render(g);
   if (target != null) {
     turret.setRotation(Utils.getAngle(this.getPos(), target.getPos()));
     g.setColor(Color.green);
     // g.fillOval(target.getX()-10, target.getY()-10, target.getWidth()+20,
     // target.getHeight()+20);
   }
   g.drawImage(turret, getX(), getY());
 }
コード例 #4
0
  @Override
  public void update(int delta) {
    super.update(delta);

    t += delta;

    if ((firing && t > burstFireRate || t > getFireRate()) && target != null) {

      if (!firing) {

        firing = true;
      }

      t = 0;

      currentVolley++;

      if (currentVolley >= volleys) {

        currentVolley = 0;
        firing = false;
      }

      MainGame.instance.root.addChild(
          new BulletPulse(
              getCenterPos(),
              this,
              Utils.getAngle(this.getCenterPos(), target.getCenterPos()),
              getWidth() / 2));
    }

    if (target != null) {

      target.isTarget--;
    }

    target = getTarget();

    if (target != null) {

      target.isTarget++;
    }
  }