Exemplo n.º 1
0
  // Function who return weapon infos
  public String getWeaponInfos() {
    String res = "";

    res = res + activeWeapon.getName() + "(" + activeWeapon.getDamage() + ")";

    return res;
  }
Exemplo n.º 2
0
 public final void addAmmo(int amount, Class weaponType) {
   for (Weapon w : weapons) {
     if (w.getClass().equals(weaponType)) {
       w.addAmmo(amount);
     }
   }
 }
Exemplo n.º 3
0
 public void renderWeapon() {
   if (currentWeapon.isActivated()) {
     currentWeapon
         .getImage()
         .draw(
             currentWeapon.getPosition().x,
             currentWeapon.getPosition().y,
             currentWeapon.getScale());
     currentWeapon.changeScale();
   }
 }
Exemplo n.º 4
0
 public boolean equipWeapon(Weapon w) {
   if (realSlot == 0) {
     return false;
   } else {
     w.setIsEquipped(true);
     weaponList.add(w);
     realCapacity -= w.getWeight();
     realSlot -= 1;
     return true;
   }
 }
Exemplo n.º 5
0
 public int getMaxRange() {
   int maxRange = 0;
   for (int i = 0; i < weaponList.size(); i++) {
     Weapon w = weaponList.get(i);
     int range = w.getRange();
     if (range > maxRange) {
       maxRange = range;
     }
   }
   return maxRange;
 }
Exemplo n.º 6
0
 public boolean removeWeapon(int n) {
   if (n > weaponList.size() || n == 0) {
     return false;
   } else {
     realCapacity += weaponList.get(n - 1).getWeight();
     Weapon w = weaponList.get(n - 1);
     w.setIsEquipped(false);
     weaponList.remove(n - 1);
     realSlot += 1;
     return true;
   }
 }
Exemplo n.º 7
0
 public final void cycleWeapon(int direction) {
   do {
     weaponIndex += direction;
     if (weaponIndex < 0) {
       weaponIndex = weapons.size() - 1;
     } else if (weaponIndex >= weapons.size()) {
       weaponIndex = 0;
     }
     weapon = weapons.get(weaponIndex);
   } while (weapon.getAmmo() + weapon.getRounds() == 0);
   ViewFrame.getInstance().setWeapon(weapon.toString());
   displayAmmo();
 }
Exemplo n.º 8
0
 public static Weapon makeDagger() {
   Weapon dagger = new Weapon();
   dagger.setId("dagger-01");
   dagger.setBrief("a dagger");
   dagger.setAlias("dagger");
   dagger.setDamage("20");
   dagger.setWear("PRIMARY SECONDARY");
   dagger.setType("SHARP");
   dagger.setSkill("piercing");
   dagger.setCost(10);
   return dagger;
 }
Exemplo n.º 9
0
  @Override
  public Weapon playRound(int roundNumber) {
    // default strategy is 1/3, 1/3, 1/3 : used in case of first game, tie round,
    int strategy = (int) (Math.random() * 3);

    if (previousWeapon != null) {

      if (roundNumber > 0) { // more than one rounds

        // if the AI wins, it will play the same game // this can happen
        // only two successive times
        if (score.get(roundNumber - 1)) {
          strategy = previousWeapon.ordinal();
        } else {
          // if the AI loses, it will play different weapon in the
          // order ROCK, PAPER, SCISSORS
          switch (previousWeapon) {
            case ROCK:
              strategy = Weapon.PAPER.ordinal();
              break;
            case PAPER:
              strategy = Weapon.SCISSORS.ordinal();
              break;
            case SCISSORS:
              strategy = Weapon.ROCK.ordinal();
              break;
          }
        }
      }
    }
    return Weapon.values()[strategy];
  }
Exemplo n.º 10
0
  public void move() {
    vCat.set(
        pointX - halfwidth + 20,
        pointY - halfheight + 30,
        pointX + halfwidth - 20,
        pointY + halfheight - 30);
    if (pointX + halfwidth > xMax) {
      speedX = -speedX;
      pointX = xMax - halfwidth;
      ori_state = CAT_LEFT;
      stage++;
    } else if (pointX - halfwidth < xMin) {
      speedX = -speedX;
      pointX = xMin + halfwidth;
      ori_state = CAT_RIGHT;
      stage++;
      // update();
    }
    if (pointY + halfheight > yMax) {

    } else if (pointY - halfheight < yMin) {

    }

    speedY -= 0.098 * 3;
    pointX += speedX;
    pointY -= speedY;
    cat_state = ori_state + ani_state;
    weapon.update();
  }
Exemplo n.º 11
0
 public ArrayList<CombatTrigger> getTriggers() {
   ArrayList<CombatTrigger> triggers = new ArrayList<CombatTrigger>();
   triggers.addAll(skills);
   if (clazz.masterSkill != null) triggers.add(clazz.masterSkill);
   if (weapon != null) triggers.addAll(weapon.getTriggers());
   return triggers;
 }
Exemplo n.º 12
0
 @Override
 public void reset() {
   arena = new Arena();
   player = new Player(0, WIDTH / 2, HEIGHT / 2);
   wave = new Wave();
   wait = 0;
   slot = 0;
   weapon.setWeapon(inv[0].getName());
   inv[1] = null;
   inv[2] = null;
   wep2.pickedUp = false;
   wep3.pickedUp = false;
   delay = 0;
   spDelay = 0;
   swordSpec = false;
 }
Exemplo n.º 13
0
 public int getMagicalDamage() {
   if (weapon == null)
     return (magicalDamage + playerRace.getMagicalDamageBonus()) * (intelligent + 1);
   else
     return (magicalDamage + playerRace.getMagicalDamageBonus() + weapon.getMagicalDamage())
         * (intelligent + 1);
 }
Exemplo n.º 14
0
 public int getPhysicalDamage() {
   if (weapon == null)
     return (physicalDamage + playerRace.getPhysicalDamageBonus()) * (strength + 1);
   else
     return (physicalDamage + playerRace.getPhysicalDamageBonus() + weapon.getPhysicalDamage())
         * (strength + 1);
 }
 @Override
 public void fire() {
   if (timer.isDone() && !overheated) {
     super.fire();
     currentHeatLevel += 1;
   }
 }
Exemplo n.º 16
0
  /**
   * Create a weapon for a ship
   *
   * @param type type of weapon to create
   * @param ship the ship getting the weapon
   * @return the created weapon
   * @throws WeaponCreationException
   */
  public Weapon create(WeaponType type, Ship ship) {
    ArrayList<Weapon> alw = pools.get(type.ordinal());
    if (alw.size() <= 0) return null;

    Weapon w = alw.get(0);
    if (w == null) return null;
    alw.remove(0);

    w.init(ship, type.wd);
    board.actors.add(w);
    if (ship.body == null) return null;
    if (w.fdef == null) return null;
    if (w.fdef.shape == null) return null;
    ship.body.createFixture(w.fdef);

    return w;
  }
Exemplo n.º 17
0
  /** Returns the range modifier for attacks. */
  public static int getRangeModifier(double distance, Weapon weapon, int gridSize) {
    int modifier = 0;
    int range = (int) distance / gridSize;

    if (range > weapon.getMediumRange()) {
      modifier = modifier + 4;
    } else if (range > weapon.getShortRange()) {
      modifier = modifier + 2;
    }

    if (range <= weapon.getMinRange()) {
      int minRangeModifier = weapon.getMinRange() - range;
      modifier = modifier + minRangeModifier;
    }

    return (modifier);
  }
Exemplo n.º 18
0
 @Override
 public int damage(Hunter hunter, Enemy enemy) {
   // TODO 自动生成的方法存根
   if (weapon.damage(hunter, enemy) > 0) {
     decreaseAglie(enemy);
   }
   return 0;
 }
Exemplo n.º 19
0
  /** Writes <code>this</code> to a stream for client/server transmission. */
  @Override
  public void flatten(DataOutputStream stream) throws IOException {
    super.flatten(stream);
    stream.writeInt(speed);

    // Flatten all of the units.
    stream.writeInt(units.size());
    for (Unit u : units) ((Bullet) u).flatten(stream);
  }
Exemplo n.º 20
0
 public final void setFiring(boolean firing) {
   if (this.firing == firing) {
     return;
   } else {
     this.firing = firing;
     if (!firing) {
       weapon.c**k();
     }
   }
 }
Exemplo n.º 21
0
 @Override
 public int castingQuality(MOB mob, Physical target) {
   if ((mob != null) && (target != null) && (target instanceof MOB)) {
     final Race R = ((MOB) target).charStats().getMyRace();
     if (R.bodyMask()[Race.BODY_HEAD] <= 0) return Ability.QUALITY_INDIFFERENT;
     LegalBehavior B = null;
     if (mob.location() != null) B = CMLib.law().getLegalBehavior(mob.location());
     List<LegalWarrant> warrants = new Vector<LegalWarrant>();
     if (B != null)
       warrants = B.getWarrantsOf(CMLib.law().getLegalObject(mob.location()), (MOB) target);
     if (warrants.size() == 0) return Ability.QUALITY_INDIFFERENT;
     final Item w = mob.fetchWieldedItem();
     Weapon ww = null;
     if ((w == null) || (!(w instanceof Weapon))) return Ability.QUALITY_INDIFFERENT;
     ww = (Weapon) w;
     if (ww.weaponDamageType() != Weapon.TYPE_SLASHING) return Ability.QUALITY_INDIFFERENT;
     if (mob.isInCombat() && (mob.rangeToTarget() > 0)) return Ability.QUALITY_INDIFFERENT;
     if (!CMLib.flags().isBoundOrHeld(target)) return Ability.QUALITY_INDIFFERENT;
   }
   return super.castingQuality(mob, target);
 }
Exemplo n.º 22
0
  public void addItem(float x, float y) throws SlickException {
    int j = random.nextInt(2);
    switch (j) {
      case 0:
        HealthPack HP = new HealthPack(20);
        items.addHealthPack(HP);
        HP.initItem();
        HP.setPosition((int) x, (int) y);
        break;
      case 1:
        int k = random.nextInt(10) + 1;
        if (k < 7) {
          Weapon gun = new Weapon(150, 1000, -10, "Gun");
          items.addWeapon(gun);
          gun.initItem();
          gun.setPosition((int) x, (int) y);

        } else if (k >= 7) {
          Weapon shotGun = new Weapon(70, 1500, -30, "Shotgun");
          items.addWeapon(shotGun);
          shotGun.initItem();
          shotGun.setPosition((int) x, (int) y);
        }
        break;
    }
  }
Exemplo n.º 23
0
 public int hit(Character annan) {
   Random randomGenerator = new Random();
   int bonk = randomGenerator.nextInt(100);
   if (bonk < skill) {
     int tjoff = weapon.damage() - annan.getShield().absorbDamage();
     if (tjoff > 0) {
       System.out.println(name + " träffade och gav " + tjoff + " i skada");
       return tjoff;
     }
   }
   System.out.println(name + " missade. Klang");
   return 0;
 }
Exemplo n.º 24
0
 public boolean tick(Tickable ticking, int tickID) {
   if (!super.tick(ticking, tickID)) return false;
   if ((tickID == Tickable.TICKID_MOB) && (affected != null) && (affected instanceof MOB)) {
     MOB mob = (MOB) affected;
     if ((mob.isInCombat())
         && (CMLib.flags().aliveAwakeMobileUnbound(mob, true))
         && (mob.rangeToTarget() == 0)
         && (mob.charStats().getBodyPart(Race.BODY_HAND) > 1)
         && (!anyWeapons(mob))) {
       if (CMLib.dice().rollPercentage() > 95) helpProficiency(mob, 0);
       if ((naturalWeapon == null) || (naturalWeapon.amDestroyed())) {
         naturalWeapon = CMClass.getWeapon("GenWeapon");
         naturalWeapon.setName("a knife hand");
         naturalWeapon.setWeaponType(Weapon.TYPE_PIERCING);
         naturalWeapon.basePhyStats().setDamage(7);
         naturalWeapon.recoverPhyStats();
       }
       CMLib.combat().postAttack(mob, mob.getVictim(), naturalWeapon);
     }
   }
   return true;
 }
Exemplo n.º 25
0
  public boolean okMessage(final Environmental myHost, final CMMsg msg) {
    if (!super.okMessage(myHost, msg)) return false;

    if ((affected == null) || (!(affected instanceof MOB))) return true;

    MOB mob = (MOB) affected;
    if (msg.amISource(mob)
        && (msg.targetMinor() == CMMsg.TYP_DAMAGE)
        && (msg.tool() instanceof Weapon)
        && (msg.tool() == naturalWeapon))
      msg.setValue(msg.value() + naturalWeapon.basePhyStats().damage() + super.getXLEVELLevel(mob));
    return true;
  }
  @Override
  public boolean shoot() {
    Random random = new Random();

    if (random.nextFloat() > (isAim ? 0.4 : 0.3)) {
      submachineGun.shoot();
      System.out.println("Caused damage!");
      return true;
    } else {
      System.out.println("Missed!");
      return false;
    }
  }
Exemplo n.º 27
0
 @Override
 protected void genericInit() {
   super.genericInit();
   ammo = -1;
   BONUS_INTERVALSHOOT = getNewBonusID();
   BONUS_RADIUS = getNewBonusID();
   BONUS_DAMAGE = getNewBonusID();
   BONUS_THREEWAYSHOT = getNewBonusID();
   bonusValues.put(BONUS_INTERVALSHOOT, new BonusValue(4, 1, "Rapid fire"));
   bonusValues.put(BONUS_RADIUS, new BonusValue(2, 6, "Huge bullets"));
   bonusValues.put(BONUS_DAMAGE, new BonusValue(10, 60, "More damaging bullets"));
   bonusValues.put(BONUS_THREEWAYSHOT, new BonusValue(0, 1, "Three way shoot"));
 }
Exemplo n.º 28
0
 @Override
 public boolean mayICraft(final Item I) {
   if (I == null) return false;
   if (!super.mayBeCrafted(I)) return false;
   if ((I.material() & RawMaterial.MATERIAL_MASK) != RawMaterial.MATERIAL_LEATHER) return false;
   if (CMLib.flags().isDeadlyOrMaliciousEffect(I)) return false;
   if (I.basePhyStats().level() < 31) return (isANativeItem(I.Name()));
   if (I instanceof Armor) {
     final long noWearLocations =
         Wearable.WORN_LEFT_FINGER | Wearable.WORN_RIGHT_FINGER | Wearable.WORN_EARS;
     if ((I.rawProperLocationBitmap() & noWearLocations) > 0) return (isANativeItem(I.Name()));
     return true;
   }
   if (I instanceof Rideable) {
     final Rideable R = (Rideable) I;
     final int rideType = R.rideBasis();
     switch (rideType) {
       case Rideable.RIDEABLE_SLEEP:
       case Rideable.RIDEABLE_SIT:
       case Rideable.RIDEABLE_TABLE:
         return true;
       default:
         return false;
     }
   }
   if (I instanceof Shield) return true;
   if (I instanceof Weapon) {
     final Weapon W = (Weapon) I;
     if (((W instanceof AmmunitionWeapon) && ((AmmunitionWeapon) W).requiresAmmunition())
         || (W.weaponClassification() == Weapon.CLASS_FLAILED)) return true;
     return (isANativeItem(I.Name()));
   }
   if (I instanceof Container) return true;
   if ((I instanceof Drink) && (!(I instanceof Potion))) return true;
   if (I instanceof FalseLimb) return true;
   if (I.rawProperLocationBitmap() == Wearable.WORN_HELD) return true;
   return (isANativeItem(I.Name()));
 }
Exemplo n.º 29
0
  @Override
  public void update() {
    if (autoPilot.getStatus() == AutoPilot.SystemStatus.ON) {
      autoPilot.update();
    }

    switch (rotation) {
      case RIGHT:
        direction.x = (direction.x * cos) - (direction.y * sin);
        direction.y = (direction.x * sin) + (direction.y * cos);
        break;
      case LEFT:
        direction.x = (direction.x * cos) + (direction.y * sin);
        direction.y = -(direction.x * sin) + (direction.y * cos);
        break;
    }

    direction = direction.direction();

    if (boosting) {
      vel.add(direction);

      vel.x = (Math.abs(vel.x) > 35) ? Math.signum(vel.x) * 35 : vel.x;
      vel.y = (Math.abs(vel.y) > 35) ? Math.signum(vel.y) * 35 : vel.y;
    } else if (breaking) {
      slow();
    }

    pos.x += vel.x;
    pos.y += vel.y;
    rectangle.setLocation(pos.getPoint());

    // bounds checking:
    if (pos.x < 0) {
      pos.x = ViewFrame.size.width - 1;
    } else if (pos.x > ViewFrame.size.width - 1) {
      pos.x = 0;
    }

    if (pos.y < 0) {
      pos.y = ViewFrame.size.height - 1;
    } else if (pos.y > ViewFrame.size.height - 1) {
      pos.y = 0;
    }

    if (firing) {
      weapon.fire();
      displayAmmo();
    }
  }
Exemplo n.º 30
0
  // Function called on weapon equiping
  public void equipWeapon(Weapon w) {
    displayBlue("Armure équipée!" + w.getItemInfos());

    if (activeWeapon == null) {
      activeWeapon = w;
    } else {
      Weapon currentWeapon = activeWeapon;
      addInventary(currentWeapon, 1);

      activeWeapon = w;

      deleteItem(w);
    }
  }