Exemplo n.º 1
0
 private static void savePlayerStatus(BufferedWriter w, Player p) throws IOException {
   w.newLine();
   w.write(Integer.toString(p.getX()));
   w.newLine();
   w.write(Integer.toString(p.getY()));
   w.newLine();
   w.write(Integer.toString(p.EXP));
   w.newLine();
   w.write(Integer.toString(p.HP));
   w.newLine();
   w.write(Integer.toString(p.MP));
   w.newLine();
   w.write(InteractiveEntity.getInventoryAsString(p.getInventory(), p.inventorySize));
   w.newLine();
   w.write(InteractiveEntity.getInventoryAsString(p.getEquips(), p.inventorySize));
 }
Exemplo n.º 2
0
 private static void setPlayerPosition(Player player, GameBoard b, String lastMap) {
   // find the landing pad if it's coming from the old map. Otherwise, use the player's coords
   if (!lastMap.equals("")) {
     Tile target = null;
     for (int x = 0; x < b.getWidth(); x++) {
       for (int y = 0; y < b.getHeight(); y++) {
         if (!b.getTileAt(x, y).isOpen(Tile.LAYER_PASSIVE_MAP)) {
           if (LandingPad.class.isAssignableFrom(
               b.getTileAt(x, y).getEntity(Tile.LAYER_PASSIVE_MAP).getClass())) {
             LandingPad pad =
                 LandingPad.class.cast(b.getTileAt(x, y).getEntity(Tile.LAYER_PASSIVE_MAP));
             if (pad.fromFloor.equals(lastMap)) {
               target = b.getTileAt(x, y);
               break;
             }
           }
         }
       }
     }
     b.insertEntity(0, target, player, Tile.LAYER_ACTIVE);
   } else {
     b.insertEntity(0, b.getTileAt(player.getX(), player.getY()), player, Tile.LAYER_ACTIVE);
   }
 }