コード例 #1
0
  public void nextLevel() {
    //		if (!firstStage)
    this.getInfo().writeText("You moved to the next stage!");
    //		else
    //			firstStage = false;
    //		boolean check = false;
    Dungeon d;
    floorLevel++;
    if (floorLevel == 6)
      JOptionPane.showMessageDialog(
          null, "Great Job! You beat the game (as it is right now). If you want you can continue.");
    d = new Dungeon(60, 60); // creates a dungeon
    ArrayList<Room> roo = d.getRooms();
    boolean reDo = d.checkRooms();
    while (reDo == true) {
      d = new Dungeon(50, 50);
      reDo = d.checkRooms();
    }

    land = d.getDungeon(); // / change to land
    openSpaces = openLocations(); // gets locations of the rooms/corridors
    hero.setLand(this.land);
    grid = new BoundedGrid<>(land.length, land[1].length);
    world = new ActorWorld(grid);

    int counter = 0;
    for (int i = 0; i < numEnemies * floorLevel; i++) {
      addEnemy();
      counter++;
    }
    for (int i = 0; i < numItems + floorLevel; i++) {
      addItem();
    }

    Location l = (openSpaces.get((int) (Math.random() * openSpaces.size())));
    world.add(openSpaces.get((int) (Math.random() * openSpaces.size())), hero.main);
    hero.setGrid(grid);
    hero.setPanel(this);

    addStairs();

    ArrayList<ArrayList<Location>> a = d.getCorridors();
    for (ArrayList<Location> lo : a) {
      for (int i = 0; i < lo.size(); i++) {
        openSpaces.add(lo.get(i));
      }
    }
    repaint();
  }
コード例 #2
0
  public void startGame() {
    JOptionPane.showMessageDialog(
        null, "Welcome to Pokemon Mystery Dungeon! Reach the 6th stage to beat the game!");
    //			if (!firstStage)
    //				this.getInfo().writeText("You moved to the next stage!");
    //			else
    //				firstStage = false;
    //			boolean check = false;
    Dungeon d;

    d = new Dungeon(60, 60); // creates a dungeon
    ArrayList<Room> roo = d.getRooms();
    boolean reDo = d.checkRooms();
    while (reDo == true) {
      d = new Dungeon(50, 50);
      reDo = d.checkRooms();
    }

    land = d.getDungeon(); // / change to land
    openSpaces = openLocations(); // gets locations of the rooms/corridors
    grid = new BoundedGrid<>(land.length, land[1].length);
    world = new ActorWorld(grid);

    int counter = 0;
    for (int i = 0; i < numEnemies * floorLevel; i++) {
      addEnemy();
      counter++;
    }
    for (int i = 0; i < numItems + floorLevel; i++) {
      addItem();
    }
    PersonalityTest t = new PersonalityTest(land);
    Pokemon z = t.chooseCharacter(this);
    hero = new Hero(z, land, this);
    Location l = (openSpaces.get((int) (Math.random() * openSpaces.size())));
    world.add(openSpaces.get((int) (Math.random() * openSpaces.size())), hero.main);
    hero.setGrid(grid);
    hero.setPanel(this);

    addStairs();

    ArrayList<ArrayList<Location>> a = d.getCorridors();
    for (ArrayList<Location> lo : a) {
      for (int i = 0; i < lo.size(); i++) {
        openSpaces.add(lo.get(i));
      }
    }
    repaint();
  }