Examples of Creep


Examples of de.creepsmash.client.creep.Creep

        return lastCreep;
      }
    }

    lastCreep = null;
    Creep found = null;

    int size = tower.getContext().getCreeps().size();

    float distanceMax = tower.getRange() * tower.getRange();
    for (int i = 0; i < size; i++) {
      if (tower.getContext().getCreeps().get(i).isValidTarget()) {
        float dX = (tower.getContext().getCreeps().get(i).getX() + Grid.SIZE / 2)
            - (tower.getGrid().getLocation()[0] + Grid.SIZE / 2);
        float dY = (tower.getContext().getCreeps().get(i).getY() + Grid.SIZE / 2)
            - (tower.getGrid().getLocation()[1] + Grid.SIZE / 2);

        // squared distance
        float dist = dX * dX + dY * dY;
        if (dist <= distanceMax) {
          if (found == null)
            found = tower.getContext().getCreeps().get(i);
          else {
            if (tower.getContext().getCreeps().get(i).getTotalSegmentSteps() > found.getTotalSegmentSteps())
              found = tower.getContext().getCreeps().get(i);
          }
        }

      }
View Full Code Here

Examples of de.creepsmash.client.creep.Creep

    }
   
    if (this.getCoolDownNow() > 0) {
      this.setCoolDownNow(this.getCoolDownNow() - 1);
    } else {
      Creep c = this.getStrategy().findCreep();

      if (c != null) {
        Projectile p = new Projectile();
        p.setTarget(c);
        p.setX(this.getGrid().getLocation()[0] + Grid.SIZE / 2);
        p.setY(this.getGrid().getLocation()[1] + Grid.SIZE / 2);
        p.setSpeed(this.projectileSpeed);
        this.projectiles.add(p);
        this.setCoolDownNow(this.getCoolDown());
        // play shoot-sound
        if (sound != null) {
          sound.towerShootsSound(this.getType());
        }
      }
    }

    for (int ip = this.projectiles.size() - 1; ip >= 0; ip--) {
      Projectile p = this.projectiles.get(ip);

      if (!p.getTarget().isValidTarget()) {
        Creep cNew = this.getStrategy().findCreep();
        if (cNew != null) {
          p.setTarget(cNew);
        } else {
          p.setTarget(null);
          this.projectiles.remove(ip);
        }
      } else {
        float dx, dy, r, factor;
        if (p.getStatus() == 0) {
          dx = p.getTarget().getX() + Grid.SIZE / 2 - p.getX();
          dy = p.getTarget().getY() + Grid.SIZE / 2 - p.getY();
          r = (float) Math.sqrt(dx * dx + dy * dy);
          factor = p.getSpeed() / (r / 1.5f);
          if (r > 2) {
            dx *= factor;
            dy *= factor;
            p.setSpeed(p.getSpeed() + 0.02f);
            p.setX(p.getX() + dx);
            p.setY(p.getY() + dy);
          } else {
            // HIT!
            p.setX(p.getTarget().getX() + Grid.SIZE / 2);
            p.setY(p.getTarget().getY() + Grid.SIZE / 2);
            p.setStatus(1);
          }
        } else if (p.getStatus() == 1) {
          float x = p.getX();
          float y = p.getY();
          Creep next;

          for (int i = 0; i < getContext().getCreeps().size(); i++) {
            if (getContext().getCreeps().get(i).isValidTarget()) {
              next = getContext().getCreeps().get(i);

              float dX = (next.getX() + Grid.SIZE / 2) - x;
              float dY = (next.getY() + Grid.SIZE / 2) - y;

              // squared distance
              float dist = dX * dX + dY * dY;
              if (dist < getSplashRadius() * getSplashRadius()) {
                p.getSplashTargets().add(next);
View Full Code Here

Examples of de.creepsmash.client.creep.Creep

        return lastCreep;
      }
    }

    lastCreep = null;
    Creep found = null;
    int size = tower.getContext().getCreeps().size();
    int health = Integer.MAX_VALUE;
    float distanceMin = tower.getRange() * tower.getRange();
    for (int i = 0; i < size; i++) {
      if (tower.getContext().getCreeps().get(i).isValidTarget()) {
View Full Code Here

Examples of de.creepsmash.client.creep.Creep

        return lastCreep;
      }
    }

    lastCreep = null;
    Creep found = null;
    int size = tower.getContext().getCreeps().size();
    float distance = 99999f;
    float distanceMin = tower.getRange() * tower.getRange();
    for (int i = 0; i < size; i++) {
      if (tower.getContext().getCreeps().get(i).isValidTarget()) {
View Full Code Here

Examples of de.creepsmash.client.creep.Creep

        copyTo = findNextContext(copyTo);
      }
     

      for (Creep c : transCopy) {
        Creep copy = CreepFactory.createCreep(copyTo, c.getType());
        copy.setHealth(c.getHealth());
        copy.setBuildTime(c.getBuildTime());
        copy.setSenderId(c.getSenderId());
        if (c.getSenderId() == copyTo.getPlayerId()) { // If sender and receiver the same Player
          copyTo.getTransfer().add(copy);
        } else {
          copyTo.getCreeps().add(copy);
         
View Full Code Here

Examples of de.creepsmash.client.creep.Creep

      }
      System.out.println(strm.getRoundId() - roundId);
    } else if (gm instanceof BuildCreepRoundMessage) {

      BuildCreepRoundMessage bcrm = (BuildCreepRoundMessage) gm;
      Creep c = CreepFactory.createCreep(this, IConstants.Creeps.valueOf(
          IConstants.Creeps.class, bcrm.getCreepType()));
      c.setBuildTime((int) (bcrm.getRoundId() - roundId));
      c.setSenderId(bcrm.getSenderId());
      c.setPlayerID(bcrm.getPlayerId());

      if (!this.isDead()) {
        this.getCreeps().add(c)
      } else {
        this.getTransfer().add(c);
      }
      System.out.println("build creep: " + (bcrm.getRoundId() - roundId));

      // play sound now
      if (managementSound != null) {
        managementSound.creepStartsSound(c.getType());
      }
    }
  }
View Full Code Here

Examples of de.creepsmash.client.creep.Creep

    // find Creep
    if (this.getCoolDownNow() == 0) {
      double xDiff, yDiff, dist, reduction;
      int damage;
      Creep target = this.getStrategy().findCreep();
      this.setTarget(target);

      // splash shoot
      if (this.getSplashRadius() > 0) {
        if (getTarget() != null
            && this.getTarget().isValidTarget()) {
         
          getTargets().clear();
          float x = target.getX();
          float y = target.getY();
          Creep next;

          // find creeps in splashradius
          for (int i = 0; i < getContext().getCreeps().size(); i++) {
            if (getContext().getCreeps().get(i).isValidTarget()) {
              next = getContext().getCreeps().get(i);

              if ((x - next.getX() <= getSplashRadius())
              && (x - next.getX() >= (getSplashRadius() * -1))
              && (y - next.getY() <= getSplashRadius())
              && (y - next.getY() >= (getSplashRadius() * -1))) {
                getTargets().add(next);

              }

            }
View Full Code Here

Examples of de.creepsmash.client.creep.Creep

        return lastCreep;
      }
    }

    lastCreep = null;
    Creep found = null;
    int size = tower.getContext().getCreeps().size();
    float speed = 0;
    float distanceMin = tower.getRange() * tower.getRange();
    for (int i = 0; i < size; i++) {
      if (tower.getContext().getCreeps().get(i).isValidTarget()) {
View Full Code Here

Examples of de.creepsmash.client.creep.Creep

        return lastCreep;
      }
    }
    GameContext context = tower.getContext();
    lastCreep = null;
    Creep found = null;
    int health = 0;
    for (Creep creep : context.getCreeps()) {
      if (creep.isValidTarget()) {
        float dX = creep.getX() - tower.getGrid().getX();
        float dY = creep.getY() - tower.getGrid().getY();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.