示例#1
0
 public void setDices(int dice1, int dice2) {
   infoScreen.setDice1(dice1);
   infoScreen.setDice2(dice2);
 }
示例#2
0
 public void setPlayerTurn(int turn) {
   infoScreen.setPlayerTurn(monopolyView.getTokenName(turn));
   infoScreen.setPlayerMoney(monopolyView.getPlayerMoney(turn));
   infoScreen.setPlayerDeeds(monopolyView.getPlayerDeeds(turn));
 }
示例#3
0
  // creates a hero according to specified parameters
  public Thing createHero(boolean prompts) {
    long start = System.currentTimeMillis();
    String race = null;
    String profession = null;

    if (!prompts) {
      race = "human";
      profession = "fighter";
      Game.setDebug(true);
    }

    // get list of races
    String[] raceherostrings = Hero.heroRaces();
    String[] racedescriptions = Hero.heroRaceDescriptions();
    if (race == null) {
      DetailedListScreen ls =
          new DetailedListScreen("What race are you?", raceherostrings, racedescriptions);
      ls.setForeground(new Color(128, 128, 128));
      ls.setBackground(new Color(0, 0, 0));
      ls.bottomString = "Press a letter key to select your race";
      switchScreen(ls);
      while (true) {
        race = (String) ls.getObject();
        // Game.warn(race);
        if ((race != null) || Game.isDebug()) break;
      }
    }

    if (race == null) {
      // Debug mode only
      // have escaped, so choose randomly
      race = raceherostrings[Rand.r(raceherostrings.length)];
      String[] herostrings = Hero.heroProfessions(race);
      profession = herostrings[Rand.r(herostrings.length)];
    }

    // get list of possible prfessions
    String[] professionstrings = Hero.heroProfessions(race);
    String[] professiondescriptions = Hero.heroProfessionDescriptions(race);
    if (profession == null) {

      DetailedListScreen ls =
          new DetailedListScreen(
              "What is your profession?", professionstrings, professiondescriptions);
      ls.bottomString = "Press a letter key to select your profession";
      ls.setForeground(new Color(128, 128, 128));
      ls.setBackground(new Color(0, 0, 0));
      switchScreen(ls);

      while (profession == null) {
        profession = (String) ls.getObject();
      }
    }

    Thing h = Hero.createHero(prompts ? null : "QuickTester", race, profession);

    // hero name and history display
    String name = "QuickTester";
    if (prompts) {
      // setup screen to get name
      Screen ss = new Screen(this);
      ss.setBackground(new Color(0, 0, 0));
      ss.setLayout(new BorderLayout());
      {
        InfoScreen ts = new InfoScreen(this, h.getString("HeroHistory"));
        ts.setBackground(new Color(0, 0, 0));
        ss.add("Center", ts);
      }
      MessagePanel mp = new MessagePanel(this);
      Game.messagepanel = mp;
      ss.add("South", mp);

      switchScreen(ss);

      name = getHeroName(true);
      if (name == null) return null;
    }
    Hero.setHeroName(h, name);

    System.out.println((System.currentTimeMillis() - start) + "ms to createHero");
    return h;
  }
示例#4
0
  // this is the actual game thread start
  // it loops for each complete game played
  public void run() {
    while (true) {

      Screen ss = new Screen(this);
      ss.setBackground(new Color(0, 0, 0));
      ss.setLayout(new BorderLayout());
      {
        TitleScreen ts = new TitleScreen(this);
        ts.setBackground(new Color(0, 0, 0));
        ss.add("Center", ts);
      }
      MessagePanel mp = new MessagePanel(this);
      Game.messagepanel = mp;
      ss.add("South", mp);

      switchScreen(ss);

      repaint();

      if (!isapplet && gameFileFromCommandLine != null) {
        Game.message("Loading " + gameFileFromCommandLine + " game file...");
        final String ret = Game.tryToRestore(gameFileFromCommandLine);
        if (ret == null) {
          setupScreen();
          getScreen().mainLoop();
          continue;
        }

        Game.message("Load game failed: " + ret);
        Game.message("Press any key (except Tab) to continue");
        Game.getInput(false); // !!! not very good - this does not
        // recognize Tab key, for instance

      }

      Game.message("");
      Game.message(
          "Welcome to Tyrant. You are playing version " + Game.VERSION + ". Would you like to:");
      Game.message(" [a] Create a new character");
      Game.message(" [b] Load a previously saved game");
      Game.message(" [c] Play in debug mode");
      Game.message(" [d] QuickStart debug mode");
      Game.message(" [e] Edit a map");
      mp.repaint();

      // create lib in background
      Game.asynchronousCreateLib();

      char c = Game.getOption("abcdeQ");

      Game.setDebug(false);
      Game.visuals = true;

      if (c == 'b') {
        if (Game.restore()) {
          setupScreen();
          getScreen().mainLoop();
        }

      } else if (c == 'c') {
        // do hero creation
        Game.create();
        Thing h = createHero(true);
        if (h == null) continue;

        Game.setDebug(true);
        setupScreen();
        gameStart();

      } else if (c == 'e') {
        // Designer
        Game.message("");
        Game.message("Launching Designer...");
        mikera.tyrant.author.Designer.main(new String[] {"embedded"});
        continue;

      } else {

        Game.create();
        Thing h = createHero(true);

        if (h == null) continue;

        // first display starting info....
        InfoScreen l =
            new InfoScreen(
                this,
                "                                 Introduction\n"
                    + "\n"
                    + "Times are hard for the humble adventurer. Lawlessness has ravaged the land, and few can afford to pay for your services.\n"
                    + "\n"
                    + "After many weeks of travel, you find yourself in the valley of North Karrain. This region has suffered less badly from the incursions of evil, and you hear that some small towns are still prosperous. Perhaps here you can find a way to make your fortune.\n"
                    + "\n"
                    + "After a long day of travel, you see a small inn to the west. Perhaps this would be a good place to meet some and learn some more about these strange lands.\n"
                    + "\n"
                    + "                           [ Press a key to continue ]\n"
                    + "\n"
                    + "\n"
                    + "\n"
                    + "\n"
                    + "\n");

        l.setForeground(new Color(192, 160, 64));
        l.setBackground(new Color(0, 0, 0));
        switchScreen(l);
        Game.getInput();
        setupScreen();
        gameStart();

        // Debug mode should not start when pressing Enter!!
        // Game.create();
        // Game.setDebug(true);
        // createHero(false);
        // setupScreen();
        // gameStart();
      }
    }
  }
示例#5
0
  @Override
  public void keyPressed(KeyEvent e) {

    switch (e.getKeyCode()) {
      case KeyEvent.VK_A:
        if (panel.isVisible()) {
          panel.setVisible(false);
          tempPanel = "achievements";
          achievementsPanel.setVisible(true);
        }
        break;
      case KeyEvent.VK_S:
        if (panel.isVisible()) {
          panel.setVisible(false);
          tempPanel = "highscores";
          highScoresPanel.setVisible(true);
        }
        break;
      case KeyEvent.VK_I:
        if (panel.isVisible()) {
          panel.setVisible(false);
          tempPanel = "about";
          aboutPanel.setVisible(true);
        }
        break;
      case KeyEvent.VK_P:
        if (panel.isVisible()) {
          introPanel.setVisible(true);
        }
        break;
      case KeyEvent.VK_Q:
        if (panel.isVisible()) {
          System.exit(0);
        }
        break;
      case KeyEvent.VK_ENTER:
        if (introPanel.isVisible()) {
          if (((InfoScreen) introPanel).getInfo().equals("introone"))
            ((InfoScreen) introPanel).setInfo("introfelix");
          else if (((InfoScreen) introPanel).getInfo().equals("introfelix"))
            ((InfoScreen) introPanel).setInfo("introtwo");
          else {
            menuMusic.stop();
            dispose();
            WordSearch ws = new WordSearch();
          }
        }
        break;
      case KeyEvent.VK_H:
        try {
          Runtime.getRuntime().exec("hh.exe assets/Help/FelixHelpMenu.chm");
        } catch (Exception ee) {
        }
        break;
      case KeyEvent.VK_B:
        if (!panel.isVisible()) {
          getPanel(tempPanel).setVisible(false);
          panel.setVisible(true);
        }
        break;
    }
  }