예제 #1
0
  @Override
  public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
    if (!end) {
      g.drawImage(background, 0, 0);
      g.drawImage(currentItem.getItemImage(), 75, fixed_y + 25);
      g.setFont(titleFont.get());
      g.drawString("> " + start_message + "" + ticker, header_x, header_y);
      g.drawImage(scorebackground, 0, 0);
      g.setFont(mainFont.get());
      g.drawString("" + winString, header_x, header_y + 30);
      g.drawImage(player1.getPlayerCharacter().getCharacterImage(), 13, 13);
      g.drawImage(player2.getPlayerCharacter().getCharacterImage(), 13, 55);
      g.drawString("" + player1.getName(), 65, 22);
      g.drawString("" + player2.getName(), 65, 64);
      g.drawString("" + player1.getScore(), 204, 22);
      g.drawString("" + player2.getScore(), 204, 64);

      g.setFont(timerFont.get());
      if (timer < 100) g.drawString("TIME: 0" + timer, timer_x, timer_y);
      else if (timer < 10) g.drawString("TIME: 00" + timer, timer_x, timer_y);
      else g.drawString("TIME: " + timer, timer_x, timer_y);
      g.setFont(timerMFont.get());
      if (timer2 < 100) g.drawString("0" + timer2, timer_x + 145, timer_y - 10);
      else if (timer2 < 10) g.drawString("00" + timer2, timer_x + 145, timer_y - 10);
      else g.drawString("" + timer2, timer_x + 145, timer_y - 10);

      g.setFont(readyFont.get());
      if (ready) {
        if (playerID == 1) g.drawString("FINISHED", 92, 19);
        else g.drawString("FINISHED", 92, 61);
      }
      if (otherPlayerReady == 1) {
        if (otherPlayerID == 1) g.drawString("FINISHED", 92, 19);
        else g.drawString("FINISHED", 92, 61);
      }
    } else if (end) {
      g.drawImage(background, 0, 0);
      g.setFont(titleFont.get());
      g.drawString("> " + start_message + "" + ticker, header_x, header_y);
      g.setFont(mainFont.get());
      g.drawString("" + winString, header_x, header_y + 30);
      g.drawImage(currentItem.getItemImage(), 75, fixed_y + 25);
      g.drawImage(scorebackground, 0, 0);
      g.setFont(mainFont.get());
      g.drawImage(player1.getPlayerCharacter().getCharacterImage(), 13, 13);
      g.drawImage(player2.getPlayerCharacter().getCharacterImage(), 13, 55);
      g.drawString("" + player1.getName(), 65, 22);
      g.drawString("" + player2.getName(), 65, 64);
      g.drawString("" + player1.getScore(), 204, 22);
      g.drawString("" + player2.getScore(), 204, 64);
      g.setFont(readyFont.get());
      if (ready) {
        if (playerID == 1) g.drawString("FINISHED", 92, 19);
        else g.drawString("FINISHED", 92, 61);
      }
      if (otherPlayerReady == 1) {
        if (otherPlayerID == 1) g.drawString("FINISHED", 92, 19);
        else g.drawString("FINISHED", 92, 61);
      }
      g.setFont(timerFont.get());
      if (timer < 100) g.drawString("TIME: 0" + timer, timer_x, timer_y);
      else if (timer < 10) g.drawString("TIME: 00" + timer, timer_x, timer_y);
      else g.drawString("TIME: " + timer, timer_x, timer_y);
      g.setFont(timerMFont.get());
      if (timer2 < 100) g.drawString("0" + timer2, timer_x + 145, timer_y - 10);
      else if (timer2 < 10) g.drawString("00" + timer2, timer_x + 145, timer_y - 10);
      else g.drawString("" + timer2, timer_x + 145, timer_y - 10);

      if (finished) {
        g.drawImage(background, 0, 0);
        g.setFont(titleFont.get());
        g.drawString("> " + start_message + "" + ticker, 25, 25);
        g.drawString("" + timer, 750, 50);
        g.drawImage(currentItem.getItemImage(), 75, 125);
        g.drawImage(new Image("simple/playerbg.png"), 146, 435);
        g.drawImage(new Image("simple/playerbg.png"), 506, 435);
        g.drawImage(player1.getPlayerCharacter().getCharacterImage(), 146, 435);
        g.drawImage(player2.getPlayerCharacter().getCharacterImage(), 506, 435);
        g.setFont(mainFont.get());
        g.drawString(winString, 50, 60);
        g.drawString("" + player1.getName(), 198, 444);
        g.drawString("" + player2.getName(), 558, 444);
      }
    }
  }
예제 #2
0
  @Override
  public void enter(GameContainer gc, StateBasedGame sbg) throws SlickException {
    super.enter(gc, sbg);
    client = HRRUClient.conn.getClient();
    rootPane.removeAllChildren();
    itemPanel.removeAllChildren();

    end = false;
    finished = false;
    resume = false;
    ready = false;
    otherPlayerReady = 0;
    currentBid = 0;
    amountWon = 0;
    maximumBid = 0;
    clock2 = 0;
    clock3 = 0;
    timer = 60;
    timer2 = 999;
    overallTimer = 0;
    otherPlayerBid = 0;
    otherPlayerWon = 0;
    winCheck = false;

    start_message = "";
    full_start_message = "MAKE YOUR BID...";
    full_start_counter = 0;
    ticker = "";
    tickerBoolean = true;
    winString = "Think carefully.";

    // Testing
    /*
    Character characters[] = (new CharacterSheet()).getCharacters();
    player1 = new Player("player1");
    player2 = new Player("player2");
    player1.setPlayerCharacterID(2);
    player1.setPlayerCharacter(characters[2]);
    player2.setPlayerCharacter(characters[4]);
    player2.setPlayerCharacterID(4);
    player1.setScore(5000);
    HRRUClient.cs.setState(6);
    HRRUClient.cs.setP1(player1);
    HRRUClient.cs.setP2(player2);
    HRRUClient.cs.setPlayer(1);
    */

    // Retrieve player information
    player1 = HRRUClient.cs.getP1();
    player2 = HRRUClient.cs.getP2();
    playerID = HRRUClient.cs.getPlayer();
    if (playerID == 1) {
      player = player1;
      otherPlayer = player2;
      otherPlayerID = 2;
      maximumBid = player.getScore();
    } else {
      player = player2;
      otherPlayer = player1;
      otherPlayerID = 1;
      maximumBid = player.getScore();
    }

    // setup description
    descriptionModel.setHtml(
        "<html><body><div><p style='text-align: center;'>"
            + "You and "
            + otherPlayer.getName()
            + " are both "
            + "<a style='font-family: name;'>bidding</a> for the item using your <a style='font-family: name;'>points</a>.</p>"
            + "<p style='margin-top: 10px; text-align: center;'>The player with the <a style='font-family: name;'>highest bid</a> wins the item for the <a style='font-family: name;'>cost of their winning bid.</a></p>"
            + "<p style='margin-top: 10px; text-align: center;'>The highest bidder will then win the <a style='font-family: name;'>value</a> of the item in <a style='font-family: name;'>points!</a></p>"
            + "</div></body></html>");

    // Setup new item variables
    item_id = HRRUClient.cs.getSecondary_id();
    currentItem = items[item_id];
    itemValue = HRRUClient.cs.getSecondary_value();

    itemPanel.setPosition(50, fixed_y);
    lblItemName = new Label(currentItem.getName());
    lblItemValue = new Label("" + itemValue);
    itemDescriptionModel.setText(currentItem.getDescription());
    lblItemName.setTheme("itematari16");
    lblItemValue.setTheme("itematari16");
    itemDescription.setTheme("questiontextarea");

    DialogLayout.Group hItemLabel = itemPanel.createSequentialGroup(lItemName);
    DialogLayout.Group hItemResult = itemPanel.createSequentialGroup(lblItemName);
    DialogLayout.Group hDescriptionLabel = itemPanel.createSequentialGroup(lDescription);
    DialogLayout.Group hDescriptionResult = itemPanel.createSequentialGroup(itemDescription);
    DialogLayout.Group hItemValueLabel = itemPanel.createSequentialGroup(lItemValue);
    DialogLayout.Group hItemValueResult = itemPanel.createSequentialGroup(lblItemValue);

    itemPanel.setHorizontalGroup(
        itemPanel
            .createParallelGroup()
            .addGroup(hItemLabel)
            .addGroup(hItemResult)
            .addGroup(hDescriptionLabel)
            .addGroup(hDescriptionResult)
            .addGroup(hItemValueLabel)
            .addGroup(hItemValueResult));

    itemPanel.setVerticalGroup(
        itemPanel
            .createSequentialGroup()
            .addWidget(lItemName)
            .addWidget(lblItemName)
            .addGap(30)
            .addWidget(lDescription)
            .addWidget(itemDescription)
            .addGap(60)
            .addWidget(lItemValue)
            .addWidget(lblItemValue));

    lblConfirmation.setPosition((gcw / 2) - lblConfirmation.getWidth() / 2, fixed_y + 320);
    // Setup bidding GUI
    vaBid.setMinMaxValue(0, maximumBid);
    vaBid.setValue(0);
    vaBid.setVisible(true);
    btnSubmit.setVisible(true);
    btnYes.setVisible(false);
    btnNo.setVisible(false);
    lblConfirmation.setVisible(false);
    p1ResultPanel.setVisible(false);
    p2ResultPanel.setVisible(false);
    description.setVisible(true);
    rootPane.add(description);
    rootPane.add(p1ResultPanel);
    rootPane.add(p2ResultPanel);
    rootPane.add(btnYes);
    rootPane.add(btnNo);
    rootPane.add(lblConfirmation);
    rootPane.add(btnSubmit);
    rootPane.add(vaBid);
    rootPane.add(itemPanel);
  }