示例#1
0
 public void randomMove() {
   int minimumDifferenceInMovements = 10000;
   if ((System.nanoTime() - lastTimeRandomlyMoved) > minimumDifferenceInMovements) {
     int maximumRandom = 500;
     int minimumRandom = 0;
     Random r = new Random(System.nanoTime());
     int x = r.nextInt(maximumRandom - minimumRandom + 1) + minimumRandom;
     if (x == 3 && !right) setRight();
     if (x == 5 && !left) setLeft();
     if (x == 7 && !up) setUp();
     if (x == 9 && !down) setDown();
   }
 }
示例#2
0
  public boolean applyDamage(Ability playerAttack) {
    Random r = new Random(System.nanoTime());
    double d = r.nextDouble();
    double damage = playerAttack.getDamage();
    System.out.println("applying damage");
    if (d > playerAttack.getAccuracy()) {
      return false;
    } else {

      if (weaknesses.size() > 0) {
        for (int j = 0; j < weaknesses.size(); j++) {
          if (playerAttack.getTypeOfDamage() == weaknesses.get(j)) {
            damage = damage * 1.5;
            break;
          }
        }
      } else if (resistances.size() > 0) {
        for (int j = 0; j < resistances.size(); j++) {
          if (playerAttack.getTypeOfDamage() == resistances.get(j)) {
            damage = damage * .667;
          }
        }
      }

      health = health - (int) damage;
      if (health <= 0) dead = true;
      return true;
    }
  }
示例#3
0
 public Enemy(TileMap tm) {
   super(tm);
   lastTimeRandomlyMoved = System.nanoTime();
 }