Ejemplo n.º 1
1
  @Override
  public void update(float delta) {
    if (!isGameOver) {
      List<TouchEvent> events = stateManager.getTouchHandler().getTouchEvents();
      if (!isExitDialogShowing) isExitDialogShowing = stateManager.isBackPressed();
      if (isExitDialogShowing) {
        events = yesButton.update(events);
        events = noButton.update(events);
        if (yesButton.state == Button.ACTIVATED) {
          yesButton.disarm();
          stateManager.setState(new MainMenuState(stateManager));
        }
        if (noButton.state == Button.ACTIVATED) {
          noButton.disarm();
          isExitDialogShowing = false;
        }
      } else {
        if (switchTurns) {

          if (map.getPlayer2() == map.getCurrentPlayersTurn()) events.clear();

          events = switchTurnsOKButton.update(events);
          events.clear();
          if (switchTurnsOKButton.state == Button.ACTIVATED) {
            switchTurnsOKButton.disarm();
            switchTurns = false;
            checkWin = true;
            map.doneSwitchingTurns();
          }
        }
        map.update(events);
      }
    } else {
      // TODO: maybe take us to a game breakdown state which records stats for the match
      // right now, just take us back to the main menu
      stateManager.setState(new MainMenuState(stateManager));
    }
  }
Ejemplo n.º 2
0
  @Override
  public void render(Graphics2D g, float delta) {
    map.render(g);
    switchTurns = map.isSwitchingTurns();
    if (switchTurns) {

      checkWin = false;

      if (map.getPlayer1() == map.getCurrentPlayersTurn()) {
        g.drawRect(0, 0, Game.G_WIDTH, Game.G_HEIGHT, switchTurnsFill);
        g.drawText(
            map.getCurrentPlayersTurn().getGamertag() + "'s turn",
            Game.G_WIDTH / 2,
            Game.G_HEIGHT / 2,
            switchTurnsFont);
        switchTurnsOKButton.render(g);
      } else {
        g.drawRect(0, 0, Game.G_WIDTH, Game.G_HEIGHT, switchTurnsFill);
        g.drawText("Computer is moving", Game.G_WIDTH / 2, Game.G_HEIGHT / 2, switchTurnsFont);
      }
    }

    if (isExitDialogShowing) {
      g.drawRect(0, 0, Game.G_WIDTH, Game.G_HEIGHT, exitDialogPaint);
      g.drawBitmap(
          GameplayAssets.exitDialogIcon,
          Game.G_WIDTH / 2 - GameplayAssets.exitDialogIcon.getWidth() / 2,
          Game.G_HEIGHT / 2 - GameplayAssets.exitDialogIcon.getHeight() / 2,
          null); // TODO: scale for larger devices
      yesButton.render(g);
      noButton.render(g);
    }
  }