コード例 #1
0
 public NPC() {
   location = new Location(10 * StaticVar.terrainImageWidth, 10 * StaticVar.terrainImageHeight);
   direction = 270;
   canPassMountain = false; // if anything this should be under skills (Sam)
   canPassWater = false;
   inventory = new Inventory();
   equipment = new Equipment();
   stats = new NPCStats();
   stats.setLife(100);
   stats.setCurrentLife(100);
   stats.setAttackTime(StaticVar.fps);
 }
コード例 #2
0
  // Should be named updatePosition -Sam
  @Override
  public void update(int xMovement, int yMovement, long elapsed) {
    if (xMovement == 0 && yMovement == 0) {
      currentlyMoving = false;
    } else {
      location.incrementX(
          Math.round(xMovement * elapsed * StaticVar.entitySpeed * stats.getMovement()));
      location.incrementY(
          Math.round(yMovement * elapsed * StaticVar.entitySpeed * stats.getMovement()));

      if (yMovement > 0) yMovement = 1;
      else if (yMovement < 0) yMovement = -1;

      xMovement /= 26;

      changeDirection(xMovement, yMovement);
      currentlyMoving = true;
    }
  }
コード例 #3
0
 public void resetTimeUntilAttack() {
   timeUntilAttack = stats.getAttackTime();
 }
コード例 #4
0
 public boolean isAlive() {
   if (stats.getCurrentLife() <= 0) return false;
   else return true;
 }