Пример #1
0
 // -------------------------------------------------------------------------------------------------------------------------------------------------------
 // Drawing
 public void drawCoin(Graphics g) {
   // draws the coins
   for (Coin i : coinList) {
     g.drawImage(
         i.getPics().get(i.getCounter()), i.getX(), i.getY(), i.getWidth(), i.getHeight(), null);
     i.count();
     i.setDirection();
   }
 }
Пример #2
0
 public void scrollCoins() {
   for (Coin i : coinList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
     i.setYPos(i.getYPos() + (int) (player1.getVelocity() * 0.3));
     i.setYMax(i.getYMax() + (int) (player1.getVelocity() * 0.3));
   }
 }
Пример #3
0
  public void checkPupCollision() {
    // pretty much the same thing as before, however it alsoe does the powerup effects
    for (Powerup p : pupList) {
      if (p.getOnScreen()) { // can be removed later on
        if (p.checkCollision(player1)) {
          pupRemove.add(p);
          player1.setPower(p.getType());
          player1.setVelo(50);
        }
      } else {
        pupRemove.add(p);
      }
    }
    if (player1.getPower().equals("Lucky")) { // changes everything to stars
      for (Coin c : coinList) {
        starList.add(new Star(c.getX(), c.getY(), 2));
        cRemove.add(c);
      }
      for (Box b : boxList) {
        starList.add(new Star(b.getX(), b.getY(), 2));
        bRemove.add(b);
      }
      for (Enemy e : enemyList) {
        starList.add(new Star(e.getX(), e.getY(), 2));
        eRemove.add(e);
      }
    } else if (player1.getPower().equals("Magnet")) { // moves the coins towards the player
      for (Coin c : coinList) {
        c.moveTowards(player1);
      }
    } else { // else do nothing

    }
    for (Powerup p : pupRemove) {
      poofList.add(new Poof(p.getX(), p.getY(), 2));
      pupList.remove(p);
    }
    pupRemove = new ArrayList<Powerup>();
  }
Пример #4
0
 public void checkCoinCollision() {
   for (Coin c : coinList) {
     if (c.getOnScreen()) { // check if the coin is on the screen
       if (c.checkCollision(
           c.getPics().get(c.getCounter()), player1)) { // if the player collides with the coin
         cRemove.add(c); // remove the coin
         player1.setVelo(50); // set the velocity so the player moves up
         player1.setDown(false); // set the down false (players moving up)
         coins += c.getValue(); // check the coins collected
         score += c.getPoints(); // get the score
         if (musicOn) {
           coinSound.play(); // play the sound
         }
       }
     } else {
       cRemove.add(c); // remove the coin
     }
   }
   for (Coin c : cRemove) {
     poofList.add(new Poof(c.getX(), c.getY(), 0));
     coinList.remove(c);
   }
   cRemove = new ArrayList<Coin>();
 }
Пример #5
0
  private static void applyRace(Thing h, String r) {
    if (r.equals("human")) {
      // humans are the most common inhabitants in the world of Tyrant
      // they are good all-round characters

      Coin.addMoney(h, 10 * RPG.d(4, 10));
      h.addThing(Lib.create("[IsDagger]"));
      h.addThing(Lib.create("[IsFood]"));
    } else if (r.equals("dwarf")) {
      // dwarves are sturdy and industrious cave dwellers
      // they are famed for their skill in smithing and mining

      Coin.addMoney(h, 10 * RPG.d(5, 10));

      h.addThing(Lib.create("iron hand axe"));
      h.addThing(Lib.create("loaf of dwarf bread"));
    } else if (r.equals("hobbit")) {
      // hobbits are just three feet high
      // they are peaceful folk, renowned as farmers
      Coin.addMoney(h, RPG.d(6, 10));
      h.addThing(Lib.create("stone knife"));
      h.addThing(Lib.create("[IsFood]"));
      h.addThing(Lib.create("[IsFood]"));
      h.addThing(Lib.create("[IsFood]"));
      h.addThing(Lib.create("[IsEquipment]"));
      h.addThing(Lib.create("sling"));
      h.addThing(Lib.create("10 pebble"));
    } else if (r.equals("high elf")) {
      // high elves are noble and wise

      Coin.addMoney(h, 10 * RPG.d(6, 10));
      h.addThing(Lib.create("ornate mithril ring"));
      h.addThing(Lib.create("elven steel dagger"));
    } else if (r.equals("wood elf")) {
      // wood elves are shy of other races
      // they are agile and talented archers
      h.addThing(Lib.create("short bow"));
      h.addThing(Lib.create("lesser elven arrow"));
    } else if (r.equals("dark elf")) {
      // dark elves are vicious and powerful
      // they prefer throwing weapons, darts and shurikens

      h.addThing(Lib.create("iron dagger"));
      h.addThing(Lib.create("[IsPotion]"));
    } else if (r.equals("gnome")) {
      // gnomes are disadvantage by their small size
      // they make up for this with igenuity

      Thing n = Lib.createType("IsMagicItem", 5);
      Item.identify(n);
      h.addThing(n);
      Coin.addMoney(h, 100 * RPG.d(10, 10));

    } else if (r.equals("half orc")) {
      // half orcs are volatile and dangerous

      h.addThing(Lib.createType("IsWeapon", RPG.d(3)));
      h.addThing(Lib.create("[IsMeat]"));
      Coin.addMoney(h, RPG.d(4, 10));

    } else if (r.equals("half troll")) {
      // trolls are lumbering hunks of muscle
      // with fearsome regenerative powers
      // they are not very bright

      h.incStat(RPG.ST_SKILLPOINTS, -1);

      h.addThing(Lib.createType("IsClub", RPG.d(6)));
      h.addThing(Lib.create("[IsMeat]"));
      h.addThing(Lib.create("[IsMeat]"));
      h.addThing(Lib.create("meat ration"));

    } else if (r.equals("argonian")) {
      // some equipment
      // in line with argonian style
      h.addThing(Lib.create("[IsTrident]"));
      h.addThing(Lib.create("[IsMeat]"));
      h.addThing(Lib.create("[IsFish]"));

    } else if (r.equals("hawken")) {
      // some equipment
      // in line with hawken style
      h.addThing(Lib.create("[IsDagger]"));
      h.addThing(Lib.create("[IsMeat]"));
      Coin.addMoney(h, RPG.d(4, 10));

    } else if (r.equals("pensadorian")) {
      // some equipment
      // in line with pensadorian style
      h.addThing(Lib.create("[IsDagger]"));
      h.addThing(Lib.create("[IsFruit]"));
      Coin.addMoney(h, RPG.d(4, 10));

    } else {

      throw new Error("Race [" + r + "] not recognised");
    }
  }
  private void readTransaction(Protos.Transaction txProto, NetworkParameters params)
      throws UnreadableWalletException {
    Transaction tx = new Transaction(params);
    if (txProto.hasUpdatedAt()) {
      tx.setUpdateTime(new Date(txProto.getUpdatedAt()));
    }

    for (Protos.TransactionOutput outputProto : txProto.getTransactionOutputList()) {
      Coin value = Coin.valueOf(outputProto.getValue());
      byte[] scriptBytes = outputProto.getScriptBytes().toByteArray();
      TransactionOutput output = new TransactionOutput(params, tx, value, scriptBytes);
      tx.addOutput(output);
    }

    for (Protos.TransactionInput inputProto : txProto.getTransactionInputList()) {
      byte[] scriptBytes = inputProto.getScriptBytes().toByteArray();
      TransactionOutPoint outpoint =
          new TransactionOutPoint(
              params,
              inputProto.getTransactionOutPointIndex() & 0xFFFFFFFFL,
              byteStringToHash(inputProto.getTransactionOutPointHash()));
      Coin value = inputProto.hasValue() ? Coin.valueOf(inputProto.getValue()) : null;
      TransactionInput input = new TransactionInput(params, tx, scriptBytes, outpoint, value);
      if (inputProto.hasSequence()) {
        input.setSequenceNumber(inputProto.getSequence());
      }
      tx.addInput(input);
    }

    for (int i = 0; i < txProto.getBlockHashCount(); i++) {
      ByteString blockHash = txProto.getBlockHash(i);
      int relativityOffset = 0;
      if (txProto.getBlockRelativityOffsetsCount() > 0)
        relativityOffset = txProto.getBlockRelativityOffsets(i);
      tx.addBlockAppearance(byteStringToHash(blockHash), relativityOffset);
    }

    if (txProto.hasLockTime()) {
      tx.setLockTime(0xffffffffL & txProto.getLockTime());
    }

    if (txProto.hasPurpose()) {
      switch (txProto.getPurpose()) {
        case UNKNOWN:
          tx.setPurpose(Transaction.Purpose.UNKNOWN);
          break;
        case USER_PAYMENT:
          tx.setPurpose(Transaction.Purpose.USER_PAYMENT);
          break;
        case KEY_ROTATION:
          tx.setPurpose(Transaction.Purpose.KEY_ROTATION);
          break;
        case ASSURANCE_CONTRACT_CLAIM:
          tx.setPurpose(Transaction.Purpose.ASSURANCE_CONTRACT_CLAIM);
          break;
        case ASSURANCE_CONTRACT_PLEDGE:
          tx.setPurpose(Transaction.Purpose.ASSURANCE_CONTRACT_PLEDGE);
          break;
        case ASSURANCE_CONTRACT_STUB:
          tx.setPurpose(Transaction.Purpose.ASSURANCE_CONTRACT_STUB);
          break;
        default:
          throw new RuntimeException("New purpose serialization not implemented");
      }
    } else {
      // Old wallet: assume a user payment as that's the only reason a new tx would have been
      // created back then.
      tx.setPurpose(Transaction.Purpose.USER_PAYMENT);
    }

    if (txProto.hasExchangeRate()) {
      Protos.ExchangeRate exchangeRateProto = txProto.getExchangeRate();
      tx.setExchangeRate(
          new ExchangeRate(
              Coin.valueOf(exchangeRateProto.getCoinValue()),
              Fiat.valueOf(
                  exchangeRateProto.getFiatCurrencyCode(), exchangeRateProto.getFiatValue())));
    }

    if (txProto.hasMemo()) tx.setMemo(txProto.getMemo());

    // Peercoin: Include time
    tx.setTime(txProto.getTime());

    // Transaction should now be complete.
    Sha256Hash protoHash = byteStringToHash(txProto.getHash());
    if (!tx.getHash().equals(protoHash))
      throw new UnreadableWalletException(
          String.format(
              "Transaction did not deserialize completely: %s vs %s", tx.getHash(), protoHash));
    if (txMap.containsKey(txProto.getHash()))
      throw new UnreadableWalletException(
          "Wallet contained duplicate transaction " + byteStringToHash(txProto.getHash()));
    txMap.put(txProto.getHash(), tx);
  }
Пример #7
0
 public void moveCoins() {
   for (Coin i : coinList) {
     i.move();
   }
 }